cozmo.run

The run module contains helper classes and functions for opening a connection to the engine.

To get started, the run_program() function can be used for most cases, it handles connecting to a device and then running the function you provide with the SDK-provided Robot object passed in.

The connect() function can be used to open a connection and run your own code connected to a cozmo.conn.CozmoConnection instance. It takes care of setting up an event loop, finding the Android or iOS device running the Cozmo app and making sure the connection is ok.

You can also use the connect_with_tkviewer() or connect_with_3dviewer() functions which works in a similar way to connect(), but will also display either a a window on the screen showing a view from Cozmo’s camera (using Tk), or a 3d viewer (with optional 2nd window showing Cozmo’s camera) (using OpenGL), if supported on your system.

Finally, more advanced progarms can integrate the SDK with an existing event loop by using the connect_on_loop() function.

All of these functions make use of a DeviceConnector subclass to deal with actually connecting to an Android or iOS device. There shouldn’t normally be a need to modify them or write your own.

Module Attributes

COZMO_PORT

The TCP port number we expect the Cozmo app to be listening on.

Functions

connect(f[, conn_factory, connector])

Connects to the Cozmo Engine on the mobile device and supplies the connection to a function.

connect_on_loop(loop[, conn_factory, connector])

Uses the supplied event loop to connect to a device.

connect_with_3dviewer(f[, conn_factory, ...])

Setup a connection to a device and run a user function while displaying Cozmo's 3d world.

connect_with_tkviewer(f[, conn_factory, ...])

Setup a connection to a device and run a user function while displaying Cozmo's camera.

run_program(f[, use_viewer, conn_factory, ...])

Connect to Cozmo and run the provided program/function f.

setup_basic_logging([general_log_level, ...])

Helper to perform basic setup of the Python logging machinery.

Classes

AndroidConnector([adb_cmd, serial])

Connects to an attached Android device over USB.

DeviceConnector([cozmo_port, enable_env_vars])

Base class for objects that setup the physical connection to a device.

FirstAvailableConnector()

Connects to the first Android or iOS device running the Cozmo app in SDK mode.

IOSConnector([serial])

Connects to an attached iOS device over USB.

TCPConnector([tcp_port, ip_addr])

Connects to the Cozmo app directly via TCP.