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
|
Dispatched when a new nav map is received. |
|
Represents Vector’s navigation memory map. |
|
A navigation memory map, stored as a quad-tree. |
|
A node in a |
The content types for a |
-
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
oranki_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
- Type
-
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.
-
contains_point
(x, y)¶ Test if the map contains the given x,y coordinates.
-
get_content
(x, y)¶ Get the map’s content at the given x,y coordinates.
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
- Returns
The smallest node that includes the point. Will be
None
if the point is outside of the map.- Return type
-
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
-
-
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.
-
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.
-
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
- 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
- Returns
The smallest node that includes the point. Will be
None
if the point is outside of the map.- Return type
-
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
orClearOfCliff
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).
-
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.
-