anki_vector.nav_map

A 2D navigation memory map of the world around Vector.

Vector builds a memory map of the navigable world around him as he drives around. This is mostly based on where objects are seen (the cubes, charger, and any custom objects), and also includes where Vector detects cliffs/drops, and visible edges (e.g. sudden changes in color).

This differs from a standard occupancy map in that it doesn’t deal with probabilities of occupancy, but instead encodes what type of content is there.

To use the map you must first call anki_vector.nav_map.NavMapComponent.init_nav_map_feed() with a positive frequency so that the data is streamed to the SDK.

Classes

EvtNavMapUpdate(nav_map)

Dispatched when a new nav map is received.

NavMapComponent(robot)

Represents Vector’s navigation memory map.

NavMapGrid(msg, logger)

A navigation memory map, stored as a quad-tree.

NavMapGridNode(depth, size, center, parent, …)

A node in a NavMapGrid.

NavNodeContentTypes

The content types for a NavMapGridNode.

class anki_vector.nav_map.EvtNavMapUpdate(nav_map)

Dispatched when a new nav map is received.

Parameters

nav_map – The current state of the robot’s nav map.

class anki_vector.nav_map.NavMapComponent(robot)

Represents Vector’s navigation memory map.

The NavMapComponent object subscribes for nav memory map updates from the robot to store and dispatch.

The anki_vector.robot.Robot or anki_vector.robot.AsyncRobot instance hosts this component.

import anki_vector

with anki_vector.Robot(enable_nav_map_feed=True) as robot:
        # Make sure Vector drives around so the nav map will update
        robot.behavior.drive_off_charger()
        robot.motors.set_wheel_motors(-100, 100)
        latest_nav_map = robot.nav_map.latest_nav_map
Parameters

robot – A reference to the owner Robot object.

close_nav_map_feed()

Cancel nav map feed task.

Return type

None

init_nav_map_feed(frequency=0.5)

Begin nav map feed task.

Parameters

frequency (float) – How frequently to send nav map updates.

Return type

None

property latest_nav_map

The most recently processed image received from the robot.

import anki_vector

with anki_vector.Robot(enable_nav_map_feed=True) as robot:
    # Make sure Vector drives around so the nav map will update
    robot.behavior.drive_off_charger()
    robot.motors.set_wheel_motors(-100, 100)
    latest_nav_map = robot.nav_map.latest_nav_map
Return type

NavMapGrid

Type

NavMapGrid

class anki_vector.nav_map.NavMapGrid(msg, logger)

A navigation memory map, stored as a quad-tree.

add_quad(content, depth)

Adds a new quad to the nav map.

Parameters
  • content (EnumTypeWrapper) – What content this node contains.

  • depth (int) – How deep in the navMap this node is.

property center

The center of this map.

Return type

Vector3

contains_point(x, y)

Test if the map contains the given x,y coordinates.

Parameters
  • x (float) – x coordinate for the point.

  • y (float) – y coordinate for the point.

Returns

True if the map contains the point, False otherwise.

Return type

bool

get_content(x, y)

Get the map’s content at the given x,y coordinates.

Parameters
  • x (float) – x coordinate for the point.

  • y (float) – y coordinate for the point.

import anki_vector

with anki_vector.Robot(enable_nav_map_feed=True) as robot:
    # Make sure Vector drives around so the nav map will update
    robot.behavior.drive_off_charger()
    robot.motors.set_wheel_motors(-100, 100)
    latest_nav_map = robot.nav_map.latest_nav_map
    content = latest_nav_map.get_content(0.0, 100.0)
    print(f"Sampling point at 0.0, 100.0 and found content: {content}")
Returns

The content included at that point. Will be NavNodeContentTypes.Unknown if the point is outside of the map.

Return type

EnumTypeWrapper

get_node(x, y)

Get the node at the given x,y coordinates.

Parameters
  • x (float) – x coordinate for the point.

  • y (float) – y coordinate for the point.

Returns

The smallest node that includes the point. Will be None if the point is outside of the map.

Return type

NavMapGridNode

origin_id = None

The origin ID for the map. Only maps and Pose objects of the same origin ID are in the same coordinate frame and can therefore be compared.

property root_node

The root node for the grid, contains all other nodes.

Return type

NavMapGridNode

property size

The size (width or length) of the square grid.

Return type

float

class anki_vector.nav_map.NavMapGridNode(depth, size, center, parent, logger)

A node in a NavMapGrid.

Leaf nodes contain content, all other nodes are split into 4 equally sized children.

Child node indices are stored in the following X,Y orientation:

^

2

0

Y

3

1

X->

add_child(content, depth)

Add a child node to the quad tree.

The quad-tree is serialized to a flat list of nodes, we deserialize back to a quad-tree structure here, with the depth of each node indicating where it is placed.

Parameters
  • content (EnumTypeWrapper) – The content to store in the leaf node.

  • depth (int) – The depth that this leaf node is located at.

Returns

True if parent should use the next child for future add_child calls.

Return type

bool

center = None

The center of this node.

children: List[NavMapGridNode] = None

None for leaf nodes, a list of 4 child nodes otherwise.

contains_point(x, y)

Test if the node contains the given x,y coordinates.

Parameters
  • x (float) – x coordinate for the point.

  • y (float) – y coordinate for the point.

Returns

True if the node contains the point, False otherwise.

Return type

bool

content: protocol.NavNodeContentType = None

The content type in this node. Only leaf nodes have content, this is None for all other nodes.

depth = None

The depth of this node (i.e. how far down the quad-tree it is).

get_content(x, y)

Get the node’s content at the given x,y coordinates.

Parameters
  • x (float) – x coordinate for the point.

  • y (float) – y coordinate for the point.

Returns

The content included at that point. Will be NavNodeContentTypes.Unknown if the point is outside of the map.

Return type

EnumTypeWrapper

get_node(x, y)

Get the node at the given x,y coordinates.

Parameters
  • x (float) – x coordinate for the point.

  • y (float) – y coordinate for the point.

Returns

The smallest node that includes the point. Will be None if the point is outside of the map.

Return type

NavMapGridNode

parent = None

The parent of this node. Is None for the root node.

size = None

The size (width or length) of this square node.

class anki_vector.nav_map.NavNodeContentTypes

The content types for a NavMapGridNode.

ClearOfCliff = 2

The node is clear of any cliffs (a sharp drop) or obstacles.

ClearOfObstacle = 1

The node is clear of obstacles, because Vector has seen objects on the other side, but it might contain a cliff. The node will be marked as either Cliff or ClearOfCliff once Vector has driven there.

Cliff = 7

The node contains a cliff (a sharp drop).

InterestingEdge = 8

The node contains a visible edge (based on the camera feed).

ObstacleCube = 3

The node contains a LightCube.

ObstacleProximity = 4

The node contains a proximity detected obstacle which has not been explored.

ObstacleProximityExplored = 5

The node contains a proximity detected obstacle which has been explored.

ObstacleUnrecognized = 6

The node contains an unrecognized obstacle.

Unknown = 0

The contents of the node is unknown.