For my senior design project at my university, my group and I decided to attempt to make a robot out of an iRobot Create, Windows tablet, and Kinect that would find a person and follow him or her around a room and allow the person to control the Create with gestures and speech recognition. We called all this Project Asimov, and at the time of this writing, it’s still under development. However, one of the first pieces of code that needed written was an API to more easily interface with the Create. Thus, after some experimentation and a thorough reading of the Create Open Interface, I had a working API written in C called libBiscuit. Why? Because the Create sort of looks like a biscuit and I like biscuits.

Anyway, first up, all the code is open source and on GitHub under the LGPL. Moreover, a quick overview of the functions, compiling instructions, and basic usage are in the README in the GitHub repo so I won’t repeat all that here.  However, here’s a short example program that uses libbiscuit to control the Create.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <stdio.h>
#include <stdlib.h>

#include "bisc.h"

int main(void) {
   // Connect to the Create
   // This should always be the first API function called
   if(biscInit("/dev/ttyUSB0") !=  BISC_SUCCESS) {
      fprintf(stderr, "Could not connect to the Create.\n");
      return 1;
   }

   // Change to full mode
   biscChangeMode(BISC_MODE_FULL);

   // Drive forward 2.5 meters at half the max speed
   biscDriveDistanceStraight(BISC_DRIVE_FORWARD_HALF_SPEED, 2.5 * 1000);

   // Turn right 90 degrees CW at half the max speed
   // Actually turn a little less than 90 degrees since the Create tends
   // to overshoot angles slightly when already moving
   biscSpinAngle(BISC_DRIVE_FORWARD_HALF_SPEED, -78);

   // Drive forward 3.75 meters at half the max speed
   biscDriveDistanceStraight(BISC_DRIVE_FORWARD_HALF_SPEED, 3.75 * 1000);

   // Spin 360 degrees CCW at half the max speed
   biscSpinAngle(BISC_DRIVE_FORWARD_HALF_SPEED, -355);

   // Drive backward 2.5 meters at the max speed
   biscDriveDistanceStraight(BISC_DRIVE_BACKWARD_FULL_SPEED, -2.5 * 1000);

   // Flash the advance LED 5 times for 500ms each time
   biscFlashLed(BISC_ADVANCE_LED, 5, 500);

   // Play a song!
   // Such a long song is a lot of commands that seem to confused the Create.
   // Sleep until the above commands are finished before sending the commands to
   // play the song.
   sleep(35);
   biscPlayFireflies();

   // Disconnect from the Create
   biscDisconnect();

   return 0;
}

And here it is in action: