cozmo.nav_memory_map

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

Cozmo 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 Cozmo 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 cozmo.world.World.request_nav_memory_map() with a positive frequency so that the data is streamed to the SDK.

Classes

EvtNewNavMemoryMap(**kwargs) Dispatched when a new memory map is received.
NavMemoryMapGrid(origin_id, root_depth, …) A navigation memory map, stored as a quad-tree.
NavMemoryMapGridNode(depth, size, center, parent) A node in a NavMemoryMapGrid.
NodeContentTypes The content types for a NavMemoryMapGridNode.
class cozmo.nav_memory_map.EvtNewNavMemoryMap(**kwargs)

Dispatched when a new memory map is received.

nav_memory_map = 'A NavMemoryMapGrid object'
class cozmo.nav_memory_map.NavMemoryMapGrid(origin_id, root_depth, root_size, root_center_x, root_center_y)

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

center

The center of this map.

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
Returns:

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

Return type:

_NodeContentType

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:

NavMemoryMapGridNode

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.

Type:int
root_node

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

Type:NavMemoryMapGridNode
size

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

Type:float
class cozmo.nav_memory_map.NavMemoryMapGridNode(depth, size, center, parent)

A node in a NavMemoryMapGrid.

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->  
center = None

The center of this node.

Type:Vector3
children = None

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

Type:list of NavMemoryMapGridNode
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 = None

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

Type:An attribute of NodeContentTypes
depth = None

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

Type:int
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 NodeContentTypes.Unknown if the point is outside of the map.

Return type:

_NodeContentType

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:

NavMemoryMapGridNode

parent = None

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

Type:NavMemoryMapGridNode
size = None

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

Type:float
class cozmo.nav_memory_map.NodeContentTypes

The content types for a NavMemoryMapGridNode.

ClearOfCliff = _NodeContentType(name='ClearOfCliff', id=2)

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

ClearOfObstacle = _NodeContentType(name='ClearOfObstacle', id=1)

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

Cliff = _NodeContentType(name='Cliff', id=6)

The node contains a cliff (a sharp drop).

ObstacleCharger = _NodeContentType(name='ObstacleCharger', id=4)

The node contains a Charger.

ObstacleCube = _NodeContentType(name='ObstacleCube', id=3)

The node contains a LightCube.

Unknown = _NodeContentType(name='Unknown', id=0)

The contents of the node is unknown.

VisionBorder = _NodeContentType(name='VisionBorder', id=7)

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