Page 44
Writing an iRobot Create Script
The iRobot Create Open Interface is described in a guide made available via the web
(
http://www.irobot.com/filelibrary/pdfs/hrd/create/Create%20Open%20Interface_v2.pdf
). Among
other things, the guide describes the serial byte codes used to govern the behavior of the iRobot Create
module.
The KIPR Link communicates with the iRobot Create via a (TTL) serial connection. Functions are included
in the KIPR Link Library for the iRobot Create, and send serial byte code sequences to the Create over
the serial connection, making it possible to operate the Create without having to reference the Open
Interface guide. These sequences cover the large majority of actions users typically want to have
performed by a Create module (e.g., drive forward at a given speed, determine how far the Create has
travelled, etc). They also provide a means for the KIPR Link to directly control an iRobot Create.
The Open Interface also provides for scripts, where a script is a (limited) sequence of iRobot Create byte
code commands ordered to perform some set of actions independent of external control. In contrast to
other commands, a command to start a script disables serial communications until the script has
finished.
The iRobot Create has several built in scripts, mostly to serve the needs of its cousin, the iRobot
Roomba. The Open Interface provides byte code commands for running these. It also has a byte code
command for loading a user defined script onto the iRobot Create along with a byte code command to
start it running. The user defined script remains available until the iRobot Create is power cycled.
Unlike high level languages, scripts for the iRobot Create have no provision for flow of control
commands such as if and while, but can use commands to wait for an elapsed time, or for a specified
distance or angle to be reached, or for an event such as a bump (wait commands are not available
except within scripts).
Memory for storing a user defined script is limited to 100 bytes.
The
create_write_byte
function in the KIPR Link Library is used for defining and sending a script (byte by
byte) to the iRobot Create. The KIPR Link Library provides 3 commands for serial communications
between the KIPR Link and an iRobot Create.
create_read_block(
<
data string
>
,
<
count
>
)
The Create sends the number of bytes specified into the data string.
create_write_byte (
<
byte
>
)
The KIPR Link send the specified byte to the iRobot Create.
create_clear_serial_buffer()
The internal serial buffer is emptied of any unaccessed send/receive data.