Page 111 - Hacking Roomba
P. 111
92 Part I — Interfacing
A planetary gear system has several benefits. For a robotic vacuum cleaner, the two most
important are that it is a sealed gear system (making it dirt resistant) and that it is very high
torque (making it able to climb steep inclines or thick carpet).The particular gearing used here
creates a 25:1 reduction. It takes 25 rotations of the main shaft driven by the motor for the
wheels to make one rotation. Electric motors are efficient only at high speeds, and even then
they do not have very much torque. A planetary gear system trades off high speed for high
torque. Such gearing is found in many electric drive systems, perhaps the most famous recently
is in the Toyota Prius.
The ROI DRIVE Command
In Chapter 2 and in the ROI specification, you might have noticed that the DRIVE command
takes a speed value in millimeters per second (mm/s) instead of something more direct like an
arbitrary motor speed value that may be familiar to you if you have programmed robots
before.This is because the DRIVE command triggers a pretty complex algorithm in the Roomba
firmware that takes into account the input from the drive motor sensors, performs math on
the sensor data, and feeds that data back into the routine that adjusts the voltage going to the
motors to get a consistent speed. All this work is done for you and all you have to do is specify
a speed in units you’re familiar with (in this case millimeters).
Recall from Chapter 2 that the DRIVE command is five bytes long: the command byte of 137
(0x89) followed by two bytes for velocity and two bytes for radius.
Velocity
The velocity value is specified in millimeters per second and describes the averaged velocity
of the two drive wheels: ((Vleft + Vright)/2). From that equation you can see that a positive
velocity makes the Roomba go forward and a negative velocity makes it go backward. But
since this is an average and Roomba, like all real machines, takes time to come up to a speed
and slow down from a speed, any command will result in positional error, and series of com-
mands with rapid starts and stops will accumulate position errors to an even greater degree.
This is the nature of using a single value to specify what is at least a three-value problem:
acceleration time, velocity, and deceleration time. In practice the error is minimized if the
speed is kept below 200 mm/s (as always, boring is safe). You can also programmatically
make Roomba speed up and slow down to and from cruising speed.
When moving straight, to make Roomba go a particular distance, move it at a particular velocity
for a particular amount of time. For example, going 200 mm/s for two seconds should result in
Roomba going 400 mm. In practice it’s not that exact, but you get the idea.
Although the minimum velocity is +/- 1 mm/s, in actuality it appears Roomba only responds to
values of at least +/- 10 mm/s.