- Start command
- Mode command
- Drive command
"Drive" command is used to drive iRobot Create's wheels, which is the main command for this demo. Let's try it with a serial connection + Realterm as previous.
Drive command syntax (in serial sequence) is
[137] [Velocity high byte] [Velocity low byte] [Radius high byte] [Radius low byte]
The range of velocity is -500 to 500 mm/s and that of radius is -2000 to 2000 mm. There are 3 special cases for this radius value as follows:
- 0x8000 or 0x7FFF: Straight (+ Velocity moves forward and - Velocity moves backward)
- 0xFFFF: Turn in place clockwise
- 0x0001: Turn in place counter-clockwise
you need to send the following commands:
- 128 131 (Start OI and puts the OI into Safe mode)
- 137 0 100 128 0 (move forward at 100 mm/s)
- 156 1 44 (until traveling 300 mm (3 s))
- 137 0 0 128 0 (stop)
- 155 20 (wait for 20 * 1/10 = 2 s)
- 137 255 156 128 0 (move backward at -100 mm/s)
- 156 254 212 (until traveling -300 mm (3 s))
- 137 0 0 128 0 (stop)
- 155 20 (wait for 20 * 1/10 = 2 s)
- 137 0 100 0 1 (move counter-clockwise at 100 mm/s)
- 157 1 105 (until rotating 360 degrees)
- 137 0 0 128 0 (stop)
- 155 20 (wait for 20 * 1/10 = 2 s)
- 137 0 100 255 255 (move clockwise at 100 mm/s)
- 157 254 152 (until rotating -360 degrees)
- 137 0 0 128 0 (stop)
Apart from that, you may as well have a tool converting a decimal integer to a hex. In Ruby, you can use the following script to investigate the value -100, -300 and -360 we used above.
$ cat conv.rb
#!/usr/bin/env ruby
ARGV.each {|n|
s = sprintf("%.4x", n)
puts "#{n} => #{s} (#{s[0,2].hex} #{s[2,4].hex})"
}
$ ./conv.rb -100 -300 -360
-100 => ff9c (255 156)
-300 => fed4 (254 212)
-360 => fe98 (254 152)
To execute the above command with Realterm, power on iRobot Create, send "128 131" first and the rest command at once:
137 0 100 128 0 156 1 44 137 0 0 128 0 155 20 137 255 156 128 0 156 254 212 137 0 0 128 0 155 20 137 0 100 0 1 157 1 105 137 0 0 128 0 155 20 137 0 100 255 255 157 254 152 137 0 0 128 0
Until now, we use serial connection with Realterm to test and understand iRobot Create behavior, but it's much interesting to program iRobot Create? OK, let's delve into it from next time.