Page 46
There are three major byte code commands used in the script:
1.
Byte code 152
Specifies start of script definition, and must be immediately followed by a byte that gives
the remaining number of bytes in the script (0-98).
2.
Byte code 137
Byte codes 137 is a drive command for the iRobot Create, and must be immediately
followed by 4 bytes representing two 16-bit two's complement integers representing speed
and turn radius in mm, respectively. The high order byte (bits 8-15) of each number is sent
first. For a positive speed and positive turn radius, the iRobot Create arcs to the left while
driving forward. A turn radius of hex 8000 or 7FFF (32,767) is a special case to drive straight.
There are also special cases for turning in place CW and CCW.
3.
Byte code 156
Command to wait until the iRobot Create has traveled a specified distance, immediately
followed by 2 bytes representing a 16-bit two's complement integer for distance in mm.
Byte code 153 is the command sent by the program that directs the iRobot Create to run the current
user defined script.
The byte code 137 drive command does not provide for individual control of drive motors. Byte code
145 is a drive command for providing direct control, where the two 16-bit two's complement integers
that immediately follow it specify right and left motor speeds, respectively.
The wait command used in the example is for distance traveled. There are 4 wait commands that can be
used in scripts (but not otherwise):
1.
wait for elapsed time (155)
The byte code is followed by 1 byte giving time from 0-255 tenths of a second, resolution of
15ms.
2.
wait for distance traveled (156)
The byte code is followed by 2 bytes giving the distance (mm) as a 16-bit 2's complement
integer.
3.
wait for total angle rotated through (157)
The byte code is followed by 2 bytes giving the angle (mm) as a 16-bit 2's complement
integer.
4.
wait for event to occur (158)
The byte code is followed by a 1 byte event number (+ or minus, where + is for event
occurrence, and - is for event non-occurrence). For example, event -9 is "no wall detected"
(e.g., the event doesn't occur until a robot being sensed by the wall sensor has moved out of
the way). To obtain a complete listing of the 22 wait events recognized by this command,
consult the Create Open Interface.
The most typical use for scripts is to move a Create, so the above example can be used as a template for
script development.
Содержание KIPR Link
Страница 1: ...KIPR Link Manual Version BB2014 1 1...