Cozmo Drive Wheels With drive_wheels

Kinvert will show you how to make Cozmo Drive Wheels using robot.drive_wheels() in Python with the Anki Cozmo SDK. Come check out the code and see how.

This is one of many Anki Cozmo Examples by Kinvert.

Cozmo and His Wheels

Cozmo gets around by driving on his little tracks. To do this we have to drive his wheels. There are multiple ways to drive Cozmo’s wheels and this time we’ll be showing you how to use the robot.drive_wheels() command.

Though there are many fun applications this initial article on driving wheels will be a bit short and only cover the actual way to drive them.

We will go over the commands we use, the code itself, some things you can do to change the code, and conclude with some other things you might be interested in reading.

Cozmo Drive Wheels Commands

This is a very short program and we don’t use a ton of commands.

Here is the list of commands we’ll be using to teach you how to drive Cozmo’s wheels:

  • cozmo.run_program()
  • robot.drive_wheels()
  • time.sleep()

Let’s take a look at the code we’ll be using to make this happen.

The Code That Drives Cozmo

Time to start describing the code.

After our imports of Cozmo and Time, we call cozmo.run_program(). This is what executes the kinvert_drive_wheels function that we wrote.

With robot defined as cozmo.robot.Robot, we call robot.drive_wheels(80, 40). You can pass in variables to this method as well. We chose to just toss in a couple integers.

Finally we call time.sleep(3). This makes Cozmo drive his wheels at this speed for 3 seconds.

Let’s take a look at the code itself.

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

def kinvert_drive_wheels(robot: cozmo.robot.Robot):
    robot.drive_wheels(80, 40)


This is one of our shortest programs. We’ll write more about how to use this drive_wheels command in actual applications in the future.

How to Change the Python Code

Cozmo drawing for online coding class learn to program anki cozmo robot in python

How would you get Cozmo to curve in the other direction?

What if you wanted Cozmo to drive for twice as long?

How do you think you’d get Cozmo to drive straight?

What about getting Cozmo to curve in one direction, and then another?

Other Stuff You Might Be Interested In

Kinvert exists to help people learn STEM. So we have a lot of articles about STEM related topics.

If Python isn’t your thing, you should check out What is Robotics, Block Coding, and Age to Teach Kids Python.

Perhaps 3D Printing is more up your ally, in which case you could read about 3D Printer Repair, What is ABS, and Flexible TPU Filament.

We have also written about Cozmo Curriculum, Homeschool Robotics, and the Anki Cozmo SDK.

Please note Anki Has Closed How to Save Anki Cozmo.

Finally, we have an awesome mailing list that keeps people up to date with all things Cozmo. You can unsub at any time.

Leave a Reply

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