iRobot's Create: Python API introduction

Part 1. Connecting to Create


Setting up your bluetooth connection

Windows PC: Mac:

Check your serial port

Windows PC: Mac/Linux:

Start a terminal window and get connected!

If successful, the robot should report something to the effect of
	PORT is /dev/tty.RooTooth-COM0-1 (or your port name)
	Serial port did open, presumably to a roomba...
	Putting the robot into safe mode...	
This "mode" is one of four internal states that the robot can be in. They are You can read the current mode along with other sensors, as described a bit below. Note that you can change to safe mode via
>>> r.toSafeMode()
and to full mode via
>>> r.toFullMode()
You can even change to passive mode by running a demo or by running
>>> r.start()
So, if you are connected to the robot in safe mode and pick it up, remember that it will send you back to passive mode.

Turning off!

To shut down the connection to the robot cleanly, you should run
>>> r.close()
if the connections gets lost less cleanly, you may need to power-cycle the robot. In really bad cases, you may need to remove and reinsert the battery of the robot.

Basic commands at the interpreter

If you've never used python before, here are some simple examples to get you started.

>>> import math             # loads in the math module to the interpreter
>>> dir(math)               # you'll see the contents of the math module
>>> help(math.degrees)      # you'll see what math.degrees does
>>> math.degrees(math.e)    # should be about 155 or so
There are built-in lists and dictionaries:

>>> L = [42,43,44]          # a list (square braces)
>>> L[0]                    # should be 42
>>> D = { 'red': 42, 'green': 43 }  # a dictionary (curly braces)
>>> D['red']                # should also be 42
and much more that's probably better picked up on the fly.

Check out the tutorial at
The library reference is at

but dir and help go a long way, as well.