cozmo.conn

Engine connection.

The SDK operates by connecting to the Cozmo “engine” - typically the Cozmo app that runs on an iOS or Android device.

The engine is responsible for much of the work that Cozmo does, including image recognition, path planning, behaviors and animation handling, etc.

The cozmo.run module takes care of opening a connection over a USB connection to a device, but the CozmoConnection class defined in this module does the work of relaying messages to and from the engine and dispatching them to the cozmo.robot.Robot instance.

Classes

CozmoConnection(*a, **kw) Manages the connection to the Cozmo app to communicate with the core engine.
EvtConnected(**kwargs) Triggered when the initial connection to the device has been established.
EvtConnectionClosed(**kwargs) Triggered when the connection to the controlling device is closed.
EvtRobotFound(**kwargs) Triggered when a Cozmo robot is detected, but before he’s initialized.
class cozmo.conn.EvtRobotFound(**kwargs)

Triggered when a Cozmo robot is detected, but before he’s initialized.

cozmo.robot.EvtRobotReady is dispatched when the robot is fully initialized.

robot = 'The Cozmo object for the robot'
class cozmo.conn.CozmoConnection(*a, **kw)

Manages the connection to the Cozmo app to communicate with the core engine.

An instance of this class is passed to functions used with cozmo.run.connect(). At the point the function is executed, the connection is already established and verified, and the EvtConnected has already been sent.

However, after the initial connection is established, programs will usually want to call wait_for_robot() to wait for an actual Cozmo robot to be detected and initialized before doing useful work.

abort(exc)

Abort the connection to the device.

anim_names = None

An cozmo.anim.AnimationNames object that references all available animation names

anim_names_factory = functools.partial(<class 'cozmo.anim.AnimationNames'>, loop=None)

The factory function that returns an cozmo.anim.AnimationNames class or subclass instance.

Type:callable
clad_decode_union

alias of cozmoclad.clad.externalInterface.messageEngineToGame.MessageEngineToGame

clad_encode_union

alias of cozmoclad.clad.externalInterface.messageGameToEngine.MessageGameToEngine

connection_lost(exc)

Called when the connection is lost or closed.

The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed).

connection_made(transport)

Called when a connection is made.

The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called.

device_info = None

A dict containing information about the device the connection is using.

is_connected

True if currently connected to the remote engine.

Type:bool
msg_received(msg)

Receives low level communication messages from the engine.

robot_factory = functools.partial(<class 'cozmo.robot.Robot'>, loop=None)

The factory function that returns a cozmo.robot.Robot class or subclass instance.

Type:callable
shutdown()

Close the connection to the device.

wait_for_robot(timeout=5)

Wait for a Cozmo robot to connect and complete initialization.

Parameters:timeout (float) – Maximum length of time to wait for a robot to be ready in seconds.
Returns:A cozmo.robot.Robot instance that’s ready to use.
Raises:asyncio.TimeoutError if there’s no response from the robot.