Skip to main content

A pure-Python Anki Cozmo communication library.

Project description

PyCozmo

PyCozmo is a pure-Python Anki Cozmo communication library. It allows controlling a Cozmo robot directly, without having to go through a mobile device, running the Cozmo app.

The library is loosely based on the Anki Cozmo Python SDK and the cozmoclad ("C-Like Abstract Data") library.

This project is a tool for exploring the hardware and software of Anki Cozmo. It is unstable and heavily under development.

Usage

Basic mode:

import time
import pycozmo

def pycozmo_program(cli):
    pkt = pycozmo.protocol_encoder.SetHeadAngle(angle_rad=0.6)
    cli.conn.send(pkt)
    time.sleep(1)

pycozmo.run_program(pycozmo_program)

Advanced mode:

import time
import pycozmo

cli = pycozmo.Client()
cli.start()
cli.connect()
cli.wait_for_robot()

pkt = pycozmo.protocol_encoder.DriveWheels(lwheel_speed_mmps=50.0, rwheel_speed_mmps=50.0) 
cli.conn.send(pkt)
time.sleep(2.0)
pkt = pycozmo.protocol_encoder.StopAllMotors()
cli.conn.send(pkt)

cli.disconnect()
cli.stop()

Documentation

Examples

Tools

Robot Support

Sensors:

  • Camera - supported
  • Cliff sensor - supported
  • Accelerometers - supported
  • Gyro - supported
  • Battery voltage - supported
  • Cube battery voltage - supported
  • Cube accelerometers - supported

Actuators:

  • Wheel motors - supported
  • Head motor - supported
  • Lift motor - supported
  • Backpack LEDs - supported
  • IR LED - supported
  • OLED display - work in progress
  • Speaker - work in progress
  • Cube LEDs - supported

Communication:

  • Wi-Fi AP - supported
  • Bluetooth LE - supported

Storage:

  • NVRAM - supported
  • Firmware update - supported

Other:

  • Animations - work in progress

Connecting to Cozmo over Wi-Fi

A Wi-Fi connection needs to be established with Cozmo before using PyCozmo applications.

  1. Wake up Cozmo by placing it on the charging platform
  2. Make Cozmo display it's Wi-Fi PSK by rising and lowering its lift
  3. Scan for Cozmo's Wi-Fi SSID (depends on the OS)
  4. Connect using Cozmo's Wi-Fi PSK (depends on the OS)

PyCozmo vs. the Cozmo SDK

A Cozmo SDK application (aka "game") acts as a client to the Cozmo app (aka "engine") that runs on a mobile device. The low-level communication happens over USB and is handled by the cozmoclad library.

In contrast, an application using PyCozmo basically replaces the Cozmo app and acts as the "engine". PyCozmo handles the low-level UDP communication with Cozmo.

+------------------+                     +------------------+                     +------------------+
|     SDK app      |      Cozmo SDK      |    Cozmo app     |       PyCozmo       |      Cozmo       |
|      "game"      |      cozmoclad      |     "engine"     |                     |     "robot"      |
|                  | ------------------> |   Wi-Fi client   | ------------------> |     Wi-Fi AP     |
|                  |         USB         |    UDP client    |      UDP/Wi-Fi      |    UDP Server    |
+------------------+                     +------------------+                     +------------------+

Limitations

  • some high-level Cozmo SDK features are implemented in the Cozmo app and have no equivalent in PyCozmo, today:
    • personality engine
    • behaviors
    • motion detection
    • face detection
    • facial expression estimation
    • text-to-speech
    • songs
  • there is no Wi-Fi control. The library assumes a Wi-Fi connection to Cozmo, established in advance.
  • frame retransmission is not implemented
  • transmission of multiple packets in a single frame is not implemented

Requirements

  • Python 3.5.4
  • Pillow 6.0.0 - Python image library
  • FlatBuffers - serialization library
  • dpkt - TCP/IP packet parsing library

Installation

Using pip:

pip install pycozmo

From source:

git clone https://github.com/zayfod/pycozmo.git
cd pycozmo
python setup.py install

Support

Bug reports and patches should be sent via GitHub:

https://github.com/zayfod/pycozmo

Anki Robot Discord server, channel #cozmo:

https://discord.gg/ew92haS

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycozmo-0.5.0.tar.gz (65.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycozmo-0.5.0-py3-none-any.whl (81.2 kB view details)

Uploaded Python 3

File details

Details for the file pycozmo-0.5.0.tar.gz.

File metadata

  • Download URL: pycozmo-0.5.0.tar.gz
  • Upload date:
  • Size: 65.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.3

File hashes

Hashes for pycozmo-0.5.0.tar.gz
Algorithm Hash digest
SHA256 1d612ffcf5926dfb9133b9ce265944bcb8e6ed4e980c4f2483a3e11705970164
MD5 2b4ee80a622d618f37fa1f61fa2fb8b5
BLAKE2b-256 480a0d3c58b8f8ac4bcbe0668eafaaf807529e938ea2fe4994e823e07ba2bb01

See more details on using hashes here.

File details

Details for the file pycozmo-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: pycozmo-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 81.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.3

File hashes

Hashes for pycozmo-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a83fabccd44637105f2f6c251e5845028450e8ebd2ec5d69fda75897c3d1adb0
MD5 ee4a3267a5f569477deb1ab6f44ddd6e
BLAKE2b-256 bff012f505030dcd9405986f6d448c1e4a406f0ddcb78c490ecfe175f54d5fba

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page