Tuesday, August 22, 2017
Home » Bonus Content » RoombaVEX


Download the C source file: 

Programming on Earth and on H99


Coding for Multiple Environments

Differences of many kinds manifest themselves when coding for the real and virtual worlds. For example, there is no game controller on planet H99 Tech Demo, so code to read the game controller fails to compile. Along similar lines, Roomba requires a string of characters to be sent to it over a serial link to tell it what to do, whereas the H99 robot has motor power for each track under direct program control.

A general approach to dealing with these issues is conditional compilation. One set of code or variable values is compiled into the program when building for planet H99, and a different set when building for RoombaVex. A #define statement sets the build environment: VEX or Simulator. Then environment-specific code is wrapped in

#if defined(VEX)



The code “disappears” when compilation for the other environment happens.

An alternate technique, sometimes preferred, is runtime adaptation. The runtime code senses its environment and behaves differently. There is no support for that in these two environments.

The differences between real and virtual worlds that affected the design are listed below.

  • The H99 environment has no game controller.
  • The program has to ignore all attempts to send bytes to Roomba when compiling for H99.
  • roomba_drive() has to send command bytes to Roomba, or modulate the H99 motors, depending on the environment.
  • The H99 sonar emulates Roomba left & right bump sensors. Note: the sonar is center-mounted and can fail to detect obstacles which can stop the robot, such as a lamp-post which impinges on one track.
  • Roomba and H99 accept different speed values, and ramp their speed at different rates, so different constant values for the different robots are compiled in to compensate.
  • Roomba is round, so can spin on its axis and not get stuck. The H99 robot is rectangular, so as it’s spinning, its back end can hit things, or it can get wedged in a corner.

Software Design Notes

I modified the original “Hacking Roomba” software to produce roombavex.c containing a loop function which reads the game controller joystick and buttons and called the roombalib.c functions to put Roomba into remote control mode. Some of the interesting adaptations needed were:

  • Roombacmd was written assuming a Linux command-line input. The Vex system doesn’t have a command-line for input, but a game controller instead. The joystick and control buttons needed to trigger robot-control actions and provide autonomous and tele-operated operation.
  • roombacmd.c and roombalib.c assumed a POSIX environment; RobotC is not that.
  • The serial port functions in RobotC are documented but the Vex Cortex connector pinout is not. A test program and scope made quick work of that problem. Figure 2 shows the wiring between the Coretex controller and Roomba.

Using the RoombaVEX/H99 Software

Download the source code: roombavex.c and roombavex.h

Installing and Running the Chumby Image Streaming Software



Here are the instructions for installing the mjpg_streamer program. Commands you should type are in bold.

1.   Connect Chumby to your home wifi network and get it configured for normal use as described in the Chumby installation instructions provided with the unit.


2.   Find Chumbys IP address by pressing the top button to go to the control panel. Touch the settings button on the touch screen, then the Chumby Info button. Note the IP address displayed.


3.   Log into chumby at the IP address from the previous step using an ssh client such as PuTTY. Username root, no password.


4.   Plug a webcam into Chumby’s USB port and check that it’s recognized: