RobotLib  1
A set of software wrappers for Rovio, Roomba and NXT robots written in C#.
 All Classes Namespaces Functions Variables Enumerations Properties Pages
Public Member Functions | Public Attributes | List of all members
Roomba.SCI.SCI Class Reference

Implementation of all SCI commands. More...

Inheritance diagram for Roomba.SCI.SCI:
Roomba.Component

Public Member Functions

 SCI (Robot _robot)
 The constructor.
 
void Start ()
 Starts the SCI. The Start command must be sent before any other SCI commands. This command puts the SCI in passive mode.
 
void Baud (BaudRate baud_rate)
 Sets the baud rate in bits per second (bps) at which SCI commands and data are sent according to the baud code sent in the data byte. The default baud rate at power up is 57600 bps. (See Serial Port Settings, above.) Once the baud rate is changed, it will persist until Roomba is power cycled by removing the battery (or until the battery voltage falls below the minimum required for processor operation). You must wait 100ms after sending this command before sending additional commands at the new baud rate. The SCI must be in passive, safe, or full mode to accept this command. This command puts the SCI in passive mode.
 
void Control ()
 Enables user control of Roomba. This command must be sent after the start command and before any control commands are sent to the SCI. The SCI must be in passive mode to accept this command. This command puts the SCI in safe mode.
 
void Safe ()
 This command puts the SCI in safe mode. The SCI must be in full mode to accept this command. Note: In order to go from passive mode to safe mode, use the Control command.
 
void Full ()
 Enables unrestricted control of Roomba through the SCI and turns off the safety features. The SCI must be in safe mode to accept this command. This command puts the SCI in full mode.
 
void Sleep ()
 Puts Roomba to sleep, the same as a normal “power” button press. The Device Detect line must be held low for 500 ms to wake up Roomba from sleep. The SCI must be in safe or full mode to accept this command. This command puts the SCI in passive mode.
 
void Spot ()
 Starts a spot cleaning cycle, the same as a normal “spot” button press. The SCI must be in safe or full mode to accept this command. This command puts the SCI in passive mode.
 
void Clean ()
 Starts a normal cleaning cycle, the same as a normal “clean” button press. The SCI must be in safe or full mode to accept this command. This command puts the SCI in passive mode.
 
void Max ()
 Starts a maximum time cleaning cycle, the same as a normal “max” button press. The SCI must be in safe or full mode to accept this command. This command puts the SCI in passive mode.
 
void Drive (short velocity, short radius)
 Controls Roomba’s drive wheels. The command takes four data bytes, which are interpreted as two 16 bit signed values using twos-complement. The first two bytes specify the average velocity of the drive wheels in millimeters per second (mm/s), with the high byte sent first. The next two bytes specify the radius, in millimeters, at which Roomba should turn. The longer radii make Roomba drive straighter; shorter radii make it turn more. A Drive command with a positive velocity and a positive radius will make Roomba drive forward while turning toward the left. A negative radius will make it turn toward the right. Special cases for the radius make Roomba turn in place or drive straight, as specified below. The SCI must be in safe or full mode to accept this command. This command does change the mode.
 
void Motors (bool main_brush, bool vacuum, bool side_brush)
 Controls Roomba’s cleaning motors. The state of each motor is specified by one bit in the data byte. The SCI must be in safe or full mode to accept this command. This command does not change the mode.
 
void Leds (int led_bits, int power_color, int power_intensity)
 Controls Roomba’s LEDs. The state of each of the spot, clean, max, and dirt detect LEDs is specified by one bit in the first data byte. The color of the status LED is specified by two bits in the first data byte. The power LED is specified by two data bytes, one for the color and one for the intensity. The SCI must be in safe or full mode to accept this command. This command does not change the mode.
 
void Song (int song_number, byte[] song)
 Specifies a song to the SCI to be played later. Each song is associated with a song number which the Play command uses to select the song to play. Users can specify up to 16 songs with up to 16 notes per song. Each note is specified by a note number using MIDI note definitions and a duration specified in fractions of a second. The number of data bytes varies depending on the length of the song specified. A one note song is specified by four data bytes. For each additional note, two data bytes must be added. The SCI must be in passive, safe, or full mode to accept this command. This command does not change the mode.
 
void Play (byte song_number)
 Plays one of 16 songs, as specified by an earlier Song command. If the requested song has not been specified yet, the Play command does nothing. The SCI must be in safe or full mode to accept this command. This command does not change the mode.
 
void Sensors (SensorPacket packet)
 Requests the SCI to send a packet of sensor data bytes. The user can select one of four different sensor packets. The sensor data packets are explained in more detail in the next section. The SCI must be in passive, safe, or full mode to accept this command. This command does not change the mode.
 
void ForceSeekingDock ()
 Turns on force-seeking-dock mode, which causes the robot to immediately attempt to dock during its cleaning cycle if it encounters the docking beams from the Home Base. (Note, however, that if the robot was not active in a clean, spot or max cycle it will not attempt to execute the docking.) Normally the robot attempts to dock only if the cleaning cycle has completed or the battery is nearing depletion. This command can be sent anytime, but the mode will be cancelled if the robot turns off, begins charging, or is commanded into SCI safe or full modes.
 
void UpdateSensorState (SensorPacket packet)
 Update the sensor state. The robot will send back one of four different sensor data packets in response to a Sensor command, depending on the value of the packet code data byte. The data bytes are specified below in the order in which they will be sent. A packet code value of 0 sends all of the data bytes. A value of 1 through 3 sends a subset of the sensor data. Some of the sensor data values are 16 bit values. These values are sent as two bytes, high byte first.
 
- Public Member Functions inherited from Roomba.Component
 Component (Robot _robot)
 The constructor.
 

Public Attributes

byte[] sensor_state
 The raw sensor data.
 
- Public Attributes inherited from Roomba.Component
bool AutoUpdate = true
 Automatic update option for methods requesting more than one piece of information.
 

Additional Inherited Members

- Protected Attributes inherited from Roomba.Component
Robot robot
 The robot class, accessible by all dervied classes.
 

Detailed Description

Implementation of all SCI commands.

Constructor & Destructor Documentation

Roomba.SCI.SCI.SCI ( Robot  _robot)

The constructor.

Member Function Documentation

void Roomba.SCI.SCI.Baud ( BaudRate  baud_rate)

Sets the baud rate in bits per second (bps) at which SCI commands and data are sent according to the baud code sent in the data byte. The default baud rate at power up is 57600 bps. (See Serial Port Settings, above.) Once the baud rate is changed, it will persist until Roomba is power cycled by removing the battery (or until the battery voltage falls below the minimum required for processor operation). You must wait 100ms after sending this command before sending additional commands at the new baud rate. The SCI must be in passive, safe, or full mode to accept this command. This command puts the SCI in passive mode.

Parameters
baud_ratebaud rate
void Roomba.SCI.SCI.Clean ( )

Starts a normal cleaning cycle, the same as a normal “clean” button press. The SCI must be in safe or full mode to accept this command. This command puts the SCI in passive mode.

void Roomba.SCI.SCI.Control ( )

Enables user control of Roomba. This command must be sent after the start command and before any control commands are sent to the SCI. The SCI must be in passive mode to accept this command. This command puts the SCI in safe mode.

void Roomba.SCI.SCI.Drive ( short  velocity,
short  radius 
)

Controls Roomba’s drive wheels. The command takes four data bytes, which are interpreted as two 16 bit signed values using twos-complement. The first two bytes specify the average velocity of the drive wheels in millimeters per second (mm/s), with the high byte sent first. The next two bytes specify the radius, in millimeters, at which Roomba should turn. The longer radii make Roomba drive straighter; shorter radii make it turn more. A Drive command with a positive velocity and a positive radius will make Roomba drive forward while turning toward the left. A negative radius will make it turn toward the right. Special cases for the radius make Roomba turn in place or drive straight, as specified below. The SCI must be in safe or full mode to accept this command. This command does change the mode.

void Roomba.SCI.SCI.ForceSeekingDock ( )

Turns on force-seeking-dock mode, which causes the robot to immediately attempt to dock during its cleaning cycle if it encounters the docking beams from the Home Base. (Note, however, that if the robot was not active in a clean, spot or max cycle it will not attempt to execute the docking.) Normally the robot attempts to dock only if the cleaning cycle has completed or the battery is nearing depletion. This command can be sent anytime, but the mode will be cancelled if the robot turns off, begins charging, or is commanded into SCI safe or full modes.

void Roomba.SCI.SCI.Full ( )

Enables unrestricted control of Roomba through the SCI and turns off the safety features. The SCI must be in safe mode to accept this command. This command puts the SCI in full mode.

void Roomba.SCI.SCI.Leds ( int  led_bits,
int  power_color,
int  power_intensity 
)

Controls Roomba’s LEDs. The state of each of the spot, clean, max, and dirt detect LEDs is specified by one bit in the first data byte. The color of the status LED is specified by two bits in the first data byte. The power LED is specified by two data bytes, one for the color and one for the intensity. The SCI must be in safe or full mode to accept this command. This command does not change the mode.

Parameters
led_bits
power_color
power_intensity
void Roomba.SCI.SCI.Max ( )

Starts a maximum time cleaning cycle, the same as a normal “max” button press. The SCI must be in safe or full mode to accept this command. This command puts the SCI in passive mode.

void Roomba.SCI.SCI.Motors ( bool  main_brush,
bool  vacuum,
bool  side_brush 
)

Controls Roomba’s cleaning motors. The state of each motor is specified by one bit in the data byte. The SCI must be in safe or full mode to accept this command. This command does not change the mode.

Parameters
main_brushMain brush on/off (true/false)
vacuumVacuum on/off (true/false)
side_brushSide brush on/off (true/false)
void Roomba.SCI.SCI.Play ( byte  song_number)

Plays one of 16 songs, as specified by an earlier Song command. If the requested song has not been specified yet, the Play command does nothing. The SCI must be in safe or full mode to accept this command. This command does not change the mode.

void Roomba.SCI.SCI.Safe ( )

This command puts the SCI in safe mode. The SCI must be in full mode to accept this command. Note: In order to go from passive mode to safe mode, use the Control command.

void Roomba.SCI.SCI.Sensors ( SensorPacket  packet)

Requests the SCI to send a packet of sensor data bytes. The user can select one of four different sensor packets. The sensor data packets are explained in more detail in the next section. The SCI must be in passive, safe, or full mode to accept this command. This command does not change the mode.

Parameters
packet
void Roomba.SCI.SCI.Sleep ( )

Puts Roomba to sleep, the same as a normal “power” button press. The Device Detect line must be held low for 500 ms to wake up Roomba from sleep. The SCI must be in safe or full mode to accept this command. This command puts the SCI in passive mode.

void Roomba.SCI.SCI.Song ( int  song_number,
byte[]  song 
)

Specifies a song to the SCI to be played later. Each song is associated with a song number which the Play command uses to select the song to play. Users can specify up to 16 songs with up to 16 notes per song. Each note is specified by a note number using MIDI note definitions and a duration specified in fractions of a second. The number of data bytes varies depending on the length of the song specified. A one note song is specified by four data bytes. For each additional note, two data bytes must be added. The SCI must be in passive, safe, or full mode to accept this command. This command does not change the mode.

Parameters
song_number
song
void Roomba.SCI.SCI.Spot ( )

Starts a spot cleaning cycle, the same as a normal “spot” button press. The SCI must be in safe or full mode to accept this command. This command puts the SCI in passive mode.

void Roomba.SCI.SCI.Start ( )

Starts the SCI. The Start command must be sent before any other SCI commands. This command puts the SCI in passive mode.

void Roomba.SCI.SCI.UpdateSensorState ( SensorPacket  packet)

Update the sensor state. The robot will send back one of four different sensor data packets in response to a Sensor command, depending on the value of the packet code data byte. The data bytes are specified below in the order in which they will be sent. A packet code value of 0 sends all of the data bytes. A value of 1 through 3 sends a subset of the sensor data. Some of the sensor data values are 16 bit values. These values are sent as two bytes, high byte first.

Parameters
packet

Member Data Documentation

byte [] Roomba.SCI.SCI.sensor_state

The raw sensor data.


The documentation for this class was generated from the following file: