Cozmo Backpack Light RGB Python

We’ll show you how to control the Cozmo backpack light using rgb in Python. Kinvert’s colors are blue and orange, so we’ll set rgb values and write the code for that. First Cozmo’s backpack light will shine blue, then Cozmo’s backpack light will turn orange.

Cozmo Backpack Light

If you look at Cozmo you’ll see the backpack light on top of him, behind his head.

Cozmo has 3 lights in the center of the overall backpack light, and 2 on the outside in that wide part of the diamond shape.

Cozmo’s 3 center backpack lights can support full 8 bit rgb. The out two backpack lights on Cozmo can only display shades of red.

Due to this, we want to only control the center lights when using rgb values.

Kinvert controls the anki cozmo backpack lights using rgb in python set_center_backpack_lights

How to Control Cozmo Backpack Lights

First, let’s take a look at some of the tools we have to use:

  • cozmo.robot.Robot.set_all_backpack_lights
  • cozmo.robot.Robot.set_backpack_lights
  • cozmo.robot.Robot.set_backpack_lights_off
  • cozmo.robot.Robot.set_center_backpack_lights

Students, before moving on, please think for a while about which of these methods we should use. If this was one of our in person or virtual Courses we wouldn’t have the answer right in front of you like this. We want you to make your prediction before moving on.

These methods can be found here:

http://cozmosdk.anki.com/docs/generated/cozmo.robot.html?#cozmo.robot.Robot.set_center_backpack_lights

Setting Cozmo Backpack Light Colors With RGB

Since we want full rgb control of Cozmo’s backpack lights, we’ll want to exclusively set the color of the center backpack lights. To do this we will be using cozmo.robot.Robot.set_center_backpack_lights.

Let’s take a look at the code


"""
Copyright Kinvert All Rights Reserved
If you would like to use this code for
business or education please contact
us for permission at:
www.kinvert.com/
"""
import cozmo
import time

def kinvert_colors(robot: cozmo.robot.Robot):
    color = cozmo.lights.Light(cozmo.lights.Color(rgb=(0,0,177)))
    robot.set_center_backpack_lights(color)
    time.sleep(2)
    color = cozmo.lights.Light(cozmo.lights.Color(rgb=(255,100,0)))
    robot.set_center_backpack_lights(color)
    time.sleep(2)

cozmo.robot.Robot.drive_off_charger_on_connect = False
cozmo.run_program(kinvert_colors)

As you can see, this will first shine Cozmo’s backpack lights as blue, and then the backpack lights will turn orange. We just successfully controlled Cozmo backpack lights using rgb values.

In Conclusion – set_center_backpack_lights RGB

If you’re interested in learning more with Cozmo, check out one of the following:

Robotics Course for Kids and Teens

Anki Cozmo SDK Programmable Robot for Kids in Python

Are you an educator looking for help developing curriculum for this lovable robot? Check out Cozmo Curriculum for STEM Education K-12.

Cozmo Examples, Tutorials, and Projects for K-12 STEM Education Curriculum

Does Python seem like a big step? Check out Kinvert’s Ultimate Guide to Block Coding and What is Robotics?

Leave a Reply

Your email address will not be published. Required fields are marked *