Package: pycozmo
PyCozmoPyCozmois a pure-Python communication library, alternative SDK, and application for theCozmo robot. 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 theAnki Cozmo Python SDKand thecozmoclad("C-Like Abstract Data") library.This project is a tool for exploring the hardware and software of the Digital Dream Labs (originally Anki) Cozmo robot.
It is unstable and heavily under development.UsageBasic:importtimeimportpycozmowithpycozmo.connect()ascli:cli.set_head_angle(angle=0.6)time.sleep(1)Advanced:importpycozmocli=pycozmo.Client()cli.start()cli.connect()cli.wait_for_robot()cli.drive_wheels(lwheel_speed=50.0,rwheel_speed=50.0,duration=2.0)cli.disconnect()cli.stop()Documentationhttps://pycozmo.readthedocs.io/Robot SupportSensors:CameraCliff sensorAccelerometersGyroBattery voltageCube battery voltageCube accelerometersBackpack button (v1.5 hardware and newer)Actuators:Wheel motorsHead motorLift motorOLED displaySpeakerBackpack LEDsIR LEDCube LEDsPlatform LEDs (when available)On-board functions (seedocs/functions.mdfor details:Wi-Fi APBluetooth LELocalizationPath trackingNV RAM storageOver-the-air (OTA) firmware updatesOff-board functions (seedocs/offboard_functions.mdfor details:Procedural face generationCozmo animations from FlatBuffers .bin filesPersonality engine - work in progressCozmo behaviors - work in progressMotion detectionObject (cube and platform) detectionCube marker recognitionFace detectionFace recognitionFacial expression estimationPet detectionCamera calibrationNavigation map buildingText-to-speechSongsExtra off-board functions:Vector animations from FlatBuffers .bin filesVector behaviorsArUco marker recognitionCozmo and Vector robot detectionDrivable area estimationVoice commandsIf you have ideas for other functionalityshare them via GitHub.Toolspycozmo_app.py- an alternative Cozmo application, implementing off-board functions
(video).pycozmo_dump.py- a command-line application that can read and annotate Cozmo communication
frompcap filesor capture it live usingpypcap.pycozmo_replay.py- a basic command-line application that can replay .pcap files back to
Cozmo.pycozmo_anim.py- a tool for examining and manipulating animation files.pycozmo_update.py- a tool for over-the-air (OTA) updates of Cozmo's firmware.pycozmo_protocol_generator.py- a tool for generating Cozmo protocol encoder
code.Note: PyCozmo andpycozmo_protocol_generator.pyin particular could be used as a base for creating a Cozmo protocol
encoder code generator for languages other than Python (C/C++, Java, etc.).ExamplesBasic:minimal.py- minimal code to communicate with Cozmo, using PyCozmoextremes.py- demonstrates Cozmo lift and head controlbackpack_lights.py- demonstrates Cozmo backpack LED controldisplay_image.py- demonstrates visualization of image files on Cozmo's displayevents.py- demonstrates event handlingcamera.py- demonstrates capturing a camera imagego_to_pose.py- demonstrates moving to a specific pose (position and orientation)path.py- demonstrates following a predefined pathAdvanced:display_lines.py- demonstrates 2D graphics, usingPIL.ImageDrawon Cozmo's display
(video)rc.py- turns Cozmo into an RC tank that can be driven with an XBox 360 Wireless controller or
Logitech Gamepad F310video.py- demonstrates visualizing video captured from the camera back on displaycube_lights.py- demonstrates cube connection and LED controlcube_light_animation.py- demonstrates cube LED animation controlcharger_lights.py- demonstrates Cozmo charging platform LED controlaudio.py- demonstrates 22 kHz, 16-bit, mono WAVE file playback through Cozmo's speakernvram.py- demonstrates reading data from Cozmo's NVRAM (non-volatile memory)procedural_face.py- demonstrates drawing a procedural face on Cozmo's displayprocedural_face_show.py- demonstrates generating a procedural faceprocedural_face_expressions.py- demonstrates displaying various facial
expressions (video)anim.py- demonstrates animating CozmoPyCozmo In The WildExpressive Eyes- rendering various facial expressions using
PyCozmo's procedural_face moduleanapplicationthat recognizesArUco markers, using OpenCVaROS2 driveranotherROS2 driverConnecting to Cozmo over Wi-FiA Wi-Fi connection needs to be established with Cozmo before using PyCozmo applications.Wake up Cozmo by placing it on the charging platformMake Cozmo display it's Wi-Fi PSK by rising and lowering its liftScan for Cozmo's Wi-Fi SSID (depends on the OS)Connect using Cozmo's Wi-Fi PSK (depends on the OS)This videosummarizes the connection process.PyCozmo vs. the Cozmo SDKA 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 thecozmocladlibrary.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     |       Cozmo       |      Cozmo       |
|      "game"      |     cozmoclad     |     "engine"     |      protocol     |     "robot"      |
|                  | ----------------> |   Wi-Fi client   | ----------------> |     Wi-Fi AP     |
|                  |        USB        |    UDP client    |     UDP/Wi-Fi     |    UDP Server    |
+------------------+                   +------------------+                   +------------------+RequirementsPython3.6.0 or newerPillow6.0.0 - Python image libraryFlatBuffers- serialization librarydpkt- TCP/IP packet parsing libraryInstallationUsing pip:pip install --user pycozmo

pycozmo_resources.py downloadFrom source:git clone https://github.com/zayfod/pycozmo.git
cd pycozmo
python setup.py install --user

pycozmo_resources.py downloadFrom source, for development:git clone git@github.com:zayfod/pycozmo.git
cd pycozmo
python setup.py develop --user
pip install --user -r requirements-dev.txt

pycozmo_resources.py downloadSupportBug reports and changes should be sent via GitHub:https://github.com/zayfod/pycozmoDDL Robot Discord server, channel #development-cozmo:https://discord.gg/ew92haSDisclaimerThis project is not affiliated withDigital Dream LabsorAnki.