This project provides an API for programming the iRobot create through a serial interface using Scheme.
The API is meant to connect to an iRobot create. The create is an open platform based off of the Roomba vacuum cleaner. It is meant to be a programable robot over the serial interface or using a compiled C program running on an optional processor unit. The API programs the robot over a serial interface, it constructs a list of bytes that will be sent and interpreted on the robot. For this particular project the serial interface is being provided over blue tooth with the use of a BAM blue tooth adapter on the Create.
This project is innovative because it provides a way to program the Create through scheme. Although libraries have been written in C and Python to program the robot there has not been one implemented in Scheme. Scheme provides the benefits of being able use functional programming to aid in programming the create over a serial interface. The functions in the API can be used to generate list of bytes to send to the create to perform operations. The list returned by these functions can be appended together and entire programs can be written to the robot at once. Using a standard terminal to write a program that loops in the robot you have to create a script on the robot and run the script continuously, with the scheme API you can create the list of commands in scheme and continually send them, handling the loop from scheme. This is beneficial because scripts running on the robot cannot be stopped, so scripts that run infinitely require turning off the robot, If that same script were to be run through scheme you could stop it at any point.
Technology Used Block Diagram
This API provides almost all of the functionality that can be found in the iRobot Create Open Interface (OI) Specification. The API provides functions that return a list of bytes. This list can then be appended to other list of bytes and passed to the send function, or be sent by itself. The send function included in the API accepts a flat list as an argument and maps the write-byte procedure to each element of the list. For example to start the robot after initiating a serial connection:
start returns a list of bytes which is passed directly to send. If you want to start and put the robot into full mode in one line you would append the result of start and full:
(send (append (start) (full)))
Appending ensures that the list being passed to send is a flat list.
There are two functions included in the API that do not return a list of bytes, these are the sensors and query-list functions, these functions invoke a response from the robot that must be read and processed immediately, so all sending and receiving is handled by the functions to ensure that no data is missed.
For requirements specific to each function please see the comments included in the code.
When the robot is started and a serial connection is made the robot sends a series of lines to tell the user it's status. These lines are cleared from the input file by resetting the file position to 0, however one byte always seems to get left behind. This byte is cleared by performing a single read-byte, in some situations the robot will not send data over the line when first connecting, when this happens the API will lock when starting up. This is because of the addition read-byte. To ensure this does not happen please start the robot with the serial port closed, and open the serial port once the robot has started completely. Even with the initial clearing of the serial line sometimes the first sensor reading from the robot will be incorrect.