cozmo.objects

Object and Power Cube recognition.

Cozmo can recognize and track a number of different types of objects.

These objects may be visible (currently observed by the robot’s camera) and tappable (in the case of the Power Cubes that ship with the robot).

Power Cubes are known as a LightCube by the SDK. Each cube has controllable lights, and sensors that can determine when its being moved or tapped.

Objects can emit several events such as EvtObjectObserved when the robot sees (or continues to see) the object with its camera, or EvtObjectTapped if a power cube is tapped by a player. You can either observe the object’s instance directly, or capture all such events for all objects by observing them on cozmo.world.World instead.

All observable objects have a marker attached to them, which allows Cozmo to recognize the object and it’s position and rotation(“pose”). You can attach markers to your own objects for Cozmo to recognize by printing them out from the online documentation. They will be detected as CustomObject instances.

Classes

Charger(*a, **kw) Cozmo’s charger object, which the robot can observe and drive toward.
CustomObject(conn, world, object_type, …) An object defined by the SDK.
CustomObjectMarkers Defines all available custom object markers.
CustomObjectTypes Defines all available custom object types.
EvtObjectAppeared(**kwargs) Triggered whenever an object is first visually identified by a robot.
EvtObjectConnectChanged(**kwargs) Triggered when an active object has connected or disconnected from the robot.
EvtObjectConnected(**kwargs) Triggered when the engine reports that an object is connected (i.e.
EvtObjectDisappeared(**kwargs) Triggered whenever an object that was previously being observed is no longer visible.
EvtObjectLocated(**kwargs) Triggered when the engine reports that an object is located (i.e.
EvtObjectMoving(**kwargs) Triggered when an active object is currently moving.
EvtObjectMovingStarted(**kwargs) Triggered when an active object starts moving.
EvtObjectMovingStopped(**kwargs) Triggered when an active object stops moving.
EvtObjectObserved(**kwargs) Triggered whenever an object is visually identified by the robot.
EvtObjectTapped(**kwargs) Triggered when an active object is tapped.
FixedCustomObject(pose, x_size_mm, …) A fixed object defined by the SDK.
LightCube(cube_id, *a, **kw) A light cube object has four LEDs that Cozmo can actively manipulate and communicate with.
ObservableElement(conn, world, robot, **kw) The base type for anything Cozmo can see.
ObservableObject(conn, world[, object_id]) The base type for objects in Cozmo’s world.
cozmo.objects.LightCube1Id = 1

LightCube1Id’s markers look a bit like a paperclip

cozmo.objects.LightCube2Id = 2

LightCube2Id’s markers look a bit like a lamp (or a heart)

cozmo.objects.LightCube3Id = 3

LightCube3Id’s markers look a bit like the letters ‘ab’ over ‘T’

cozmo.objects.LightCubeIDs = [1, 2, 3]

An ordered list of the 3 light cube IDs for convenience

cozmo.objects.OBJECT_VISIBILITY_TIMEOUT = 0.4

Length of time in seconds to go without receiving an observed event before assuming that Cozmo can no longer see an object.

class cozmo.objects.EvtObjectAppeared(**kwargs)

Triggered whenever an object is first visually identified by a robot.

This differs from EvtObjectObserved in that it’s only triggered when an object initially becomes visible. If it disappears for more than OBJECT_VISIBILITY_TIMEOUT seconds and then is seen again, a EvtObjectDisappeared will be dispatched, followed by another EvtObjectAppeared event.

For continuous tracking information about a visible object, see EvtObjectObserved.

image_box = "A comzo.util.ImageBox defining where the object is within Cozmo's camera view"
obj = 'The object that was observed'
pose = 'The cozmo.util.Pose defining the position and rotation of the object'
updated = 'A set of field names that have changed'
class cozmo.objects.EvtObjectConnectChanged(**kwargs)

Triggered when an active object has connected or disconnected from the robot.

connected = 'True if the object connected, False if it disconnected'
obj = 'The object that connected or disconnected'
class cozmo.objects.EvtObjectConnected(**kwargs)

Triggered when the engine reports that an object is connected (i.e. exists).

This will usually occur at the start of the program in response to the SDK sending RequestConnectedObjects to the engine.

connected = 'True if the object connected, False if it disconnected'
obj = 'The object that is connected'
class cozmo.objects.EvtObjectDisappeared(**kwargs)

Triggered whenever an object that was previously being observed is no longer visible.

obj = 'The object that is no longer being observed'
class cozmo.objects.EvtObjectLocated(**kwargs)

Triggered when the engine reports that an object is located (i.e. pose is known).

This will usually occur at the start of the program in response to the SDK sending RequestLocatedObjectStates to the engine.

obj = 'The object that is located'
pose = 'The cozmo.util.Pose defining the position and rotation of the object'
updated = 'A set of field names that have changed'
class cozmo.objects.EvtObjectMoving(**kwargs)

Triggered when an active object is currently moving.

acceleration = 'The currently measured acceleration'
move_duration = 'The current duration of time (in seconds) that the object has spent moving'
obj = 'The object that is currently moving'
class cozmo.objects.EvtObjectMovingStarted(**kwargs)

Triggered when an active object starts moving.

acceleration = 'The currently measured acceleration'

The currently measured acceleration

Type:Vector3
obj = 'The object that started moving'
class cozmo.objects.EvtObjectMovingStopped(**kwargs)

Triggered when an active object stops moving.

move_duration = 'The duration of time (in seconds) that the object spent moving'
obj = 'The object that stopped moving'
class cozmo.objects.EvtObjectObserved(**kwargs)

Triggered whenever an object is visually identified by the robot.

A stream of these events are produced while an object is visible to the robot. Each event has an updated image_box field.

See EvtObjectAppeared if you only want to know when an object first becomes visible.

image_box = "A comzo.util.ImageBox defining where the object is within Cozmo's camera view"
obj = 'The object that was observed'
pose = 'The cozmo.util.Pose defining the position and rotation of the object'
updated = 'A set of field names that have changed'
class cozmo.objects.EvtObjectTapped(**kwargs)

Triggered when an active object is tapped.

obj = 'The object that was tapped'
tap_count = 'Number of taps detected'
tap_duration = 'The duration of the tap in ms'
tap_intensity = 'The intensity of the tap'
class cozmo.objects.ObservableElement(conn, world, robot, **kw)

The base type for anything Cozmo can see.

is_visible

True if the element has been observed recently.

“recently” is defined as visibility_timeout seconds.

Type:bool
last_event_time = None

The time the last event was received. None if no events have yet been received.

Type:float
last_observed_image_box = None

The ImageBox defining where the object was last visible within Cozmo’s camera view. None if the element has not yet been observed.

Type:ImageBox
last_observed_robot_timestamp = None

The robot’s timestamp of the last observed event. None if the element has not yet been observed. In milliseconds relative to robot epoch.

Type:int
last_observed_time = None

The time the element was last observed by the robot. None if the element has not yet been observed.

Type:float
pose

The pose of the element in the world.

Is None for elements that don’t have pose information.

Type:cozmo.util.Pose
time_since_last_seen

time since this element was last seen (math.inf if never)

Type:float
visibility_timeout = 0.4

Length of time in seconds to go without receiving an observed event before assuming that Cozmo can no longer see an element. Can be overridden in sub classes.

world = None

The robot’s world in which this element is located.

Type:cozmo.world.World
class cozmo.objects.ObservableObject(conn, world, object_id=None, **kw)

The base type for objects in Cozmo’s world.

See parent class ObservableElement for additional properties and methods.

descriptive_name

A descriptive name for this ObservableObject instance.

Type:str
object_id

The internal ID assigned to the object.

This value can only be assigned once as it is static in the engine.

Type:int
pickupable = False

True if this type of object can be physically picked up by Cozmo

Type:bool
place_objects_on_this = False

True if this type of object can have objects physically placed on it by Cozmo

Type:bool
class cozmo.objects.LightCube(cube_id, *a, **kw)

A light cube object has four LEDs that Cozmo can actively manipulate and communicate with.

See parent class ObservableObject for additional properties and methods.

EMPTY_VOLTAGE = 1.0

Voltage where a cube’s battery can be considered empty

FULL_VOLTAGE = 1.5

Voltage where a cube’s battery can be considered full

battery_percentage

Battery level as a percentage.

Type:float
battery_str

String representation of the battery level.

Type:str
battery_voltage = None

Battery voltage. None if no voltage reading has been received yet

Type:float
cube_id

The Light Cube ID.

This will be one of LightCube1Id, LightCube2Id and LightCube3Id. Note: the cube_id is not the same thing as the object_id.

Type:int
descriptive_name

A descriptive name for this LightCube instance.

Type:str
is_connected = None

True if the cube is currently connected to the robot via radio.

Type:bool
is_moving = None

True if the cube’s accelerometer indicates that the cube is moving.

Type:bool
last_moved_robot_timestamp = None

The robot’s timestamp of the last move event. None if the cube wasn’t moved yet. In milliseconds relative to robot epoch.

Type:int
last_moved_start_robot_timestamp = None

The robot’s timestamp of when the object started moving when last moved None if the cube wasn’t moved yet. In milliseconds relative to robot epoch.

Type:int
last_moved_start_time = None

The time the object started moving when last moved

Type:float
last_moved_time = None

The time the object was last moved None if the cube wasn’t moved yet.

Type:float
last_tapped_robot_timestamp = None

The robot’s timestamp of the last tapped event. None if the cube wasn’t tapped yet. In milliseconds relative to robot epoch.

Type:int
last_tapped_time = None

The time the object was last tapped None if the cube wasn’t tapped yet.

Type:float
set_light_corners(light1, light2, light3, light4)

Set the light for each corner

set_lights(light)

Set all lights on the cube

Parameters:light (cozmo.lights.Light) – The settings for the lights.
set_lights_off()

Turn off all the lights on the cube.

wait_for_tap(timeout=None)

Wait for the object to receive a tap event.

Parameters:timeout (float) – Maximum time to wait for a tap, in seconds. None for indefinite
Returns:A EvtObjectTapped object if a tap was received.
class cozmo.objects.Charger(*a, **kw)

Cozmo’s charger object, which the robot can observe and drive toward.

See parent class ObservableObject for additional properties and methods.

class cozmo.objects.CustomObject(conn, world, object_type, x_size_mm, y_size_mm, z_size_mm, marker_width_mm, marker_height_mm, is_unique, **kw)

An object defined by the SDK. It is bound to a specific objectType e.g CustomType00.

This defined object is given a size in the x,y and z axis. The dimensions of the markers on the object are also defined. We get an cozmo.objects.EvtObjectObserved message when the robot sees these markers.

See parent class ObservableObject for additional properties and methods.

These objects are created automatically by the engine when Cozmo observes an object with custom markers. For Cozmo to see one of these you must first define an object with custom markers, via one of the following methods: define_custom_box(). define_custom_cube(), or define_custom_wall()

descriptive_name

A descriptive name for this CustomObject instance.

Type:str
is_unique

True if there should only be one of this object type in the world.

Type:bool
marker_height_mm

Height in millimeters of the marker on this object.

Type:float
marker_width_mm

Width in millimeters of the marker on this object.

Type:float
x_size_mm

Size of this object in its X axis, in millimeters.

Type:float
y_size_mm

Size of this object in its Y axis, in millimeters.

Type:float
z_size_mm

Size of this object in its Z axis, in millimeters.

Type:float
class cozmo.objects.CustomObjectMarkers

Defines all available custom object markers.

For use with world.define_custom methods such as cozmo.world.World.define_custom_box(), cozmo.world.World.define_custom_cube(), and cozmo.world.World.define_custom_wall()

Circles2 = _CustomObjectMarker(name='Circles2', id=0)
../_images/SDK_2Circles.png
Circles3 = _CustomObjectMarker(name='Circles3', id=1)
../_images/SDK_3Circles.png
Circles4 = _CustomObjectMarker(name='Circles4', id=2)
../_images/SDK_4Circles.png
Circles5 = _CustomObjectMarker(name='Circles5', id=3)
../_images/SDK_5Circles.png
Diamonds2 = _CustomObjectMarker(name='Diamonds2', id=4)
../_images/SDK_2Diamonds.png
Diamonds3 = _CustomObjectMarker(name='Diamonds3', id=5)
../_images/SDK_3Diamonds.png
Diamonds4 = _CustomObjectMarker(name='Diamonds4', id=6)
../_images/SDK_4Diamonds.png
Diamonds5 = _CustomObjectMarker(name='Diamonds5', id=7)
../_images/SDK_5Diamonds.png
Hexagons2 = _CustomObjectMarker(name='Hexagons2', id=8)
../_images/SDK_2Hexagons.png
Hexagons3 = _CustomObjectMarker(name='Hexagons3', id=9)
../_images/SDK_3Hexagons.png
Hexagons4 = _CustomObjectMarker(name='Hexagons4', id=10)
../_images/SDK_4Hexagons.png
Hexagons5 = _CustomObjectMarker(name='Hexagons5', id=11)
../_images/SDK_5Hexagons.png
Triangles2 = _CustomObjectMarker(name='Triangles2', id=12)
../_images/SDK_2Triangles.png
Triangles3 = _CustomObjectMarker(name='Triangles3', id=13)
../_images/SDK_3Triangles.png
Triangles4 = _CustomObjectMarker(name='Triangles4', id=14)
../_images/SDK_4Triangles.png
Triangles5 = _CustomObjectMarker(name='Triangles5', id=15)
../_images/SDK_5Triangles.png
class cozmo.objects.CustomObjectTypes

Defines all available custom object types.

For use with world.define_custom methods such as cozmo.world.World.define_custom_box(), cozmo.world.World.define_custom_cube(), and cozmo.world.World.define_custom_wall()

CustomType00 = _CustomObjectType(name='CustomType00', id=17)

CustomType00 - the first custom object type

CustomType01 = _CustomObjectType(name='CustomType01', id=18)
CustomType02 = _CustomObjectType(name='CustomType02', id=19)
CustomType03 = _CustomObjectType(name='CustomType03', id=20)
CustomType04 = _CustomObjectType(name='CustomType04', id=21)
CustomType05 = _CustomObjectType(name='CustomType05', id=22)
CustomType06 = _CustomObjectType(name='CustomType06', id=23)
CustomType07 = _CustomObjectType(name='CustomType07', id=24)
CustomType08 = _CustomObjectType(name='CustomType08', id=25)
CustomType09 = _CustomObjectType(name='CustomType09', id=26)
CustomType10 = _CustomObjectType(name='CustomType10', id=27)
CustomType11 = _CustomObjectType(name='CustomType11', id=28)
CustomType12 = _CustomObjectType(name='CustomType12', id=29)
CustomType13 = _CustomObjectType(name='CustomType13', id=30)
CustomType14 = _CustomObjectType(name='CustomType14', id=31)
CustomType15 = _CustomObjectType(name='CustomType15', id=32)
CustomType16 = _CustomObjectType(name='CustomType16', id=33)
CustomType17 = _CustomObjectType(name='CustomType17', id=34)
CustomType18 = _CustomObjectType(name='CustomType18', id=35)
CustomType19 = _CustomObjectType(name='CustomType19', id=36)

CustomType19 - the last custom object type

class cozmo.objects.FixedCustomObject(pose, x_size_mm, y_size_mm, z_size_mm, object_id, *a, **kw)

A fixed object defined by the SDK. It is given a pose and x,y,z sizes.

This object cannot be observed by the robot so its pose never changes. The position is static in Cozmo’s world view; once instantiated, these objects never move. This could be used to make Cozmo aware of objects and know to plot a path around them even when they don’t have any markers.

To create these use create_custom_fixed_object()

object_id

The internal ID assigned to the object.

This value can only be assigned once as it is static in the engine.

Type:int
pose

The pose of the object in the world.

Type:cozmo.util.Pose
x_size_mm

The length of the object in its X axis, in millimeters.

Type:float
y_size_mm

The length of the object in its Y axis, in millimeters.

Type:float
z_size_mm

The length of the object in its Z axis, in millimeters.

Type:float