LoDrive.h File Reference

Driving API for Robolocust iRobot Create Command Module control program. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define lo_stop_immediate()   lo_drive(0, LOBOT_OI_DRIVE_STRAIGHT, 0)
#define lo_suspend_ramping()   lo_suspend_timer10()
#define lo_resume_ramping()   lo_resume_timer10()

Functions

void lo_init_drive (void)
void lo_nop (int)
void lo_drive (int speed, int turn_radius, char smooth)
int lo_backup (int speed, int distance)
int lo_spin (int speed, int angle)
char lo_stopped (void)

void lo_forward (int)
void lo_reverse (int)
void lo_stop (int)

void lo_left (int turn_radius)
void lo_right (int turn_radius)
void lo_straight (int)
void lo_cmd_spin (int angle)

Detailed Description

Driving API for Robolocust iRobot Create Command Module control program.

This file defines an API for driving the iRobot Create using the Open Interface. These functions accept the high-level drive commands issued by the higher layers of the Robolocust controller and convert them to their equivalent Open Interface byte sequences.

Definition in file LoDrive.h.


Define Documentation

 
#define lo_resume_ramping (  )     lo_resume_timer10()

This function can be used to resume the drive module's temporarily suspended acceleration/deceleration functionality. It works by reenabling the 10ms generalized timer's interrupts. It is required because the 10ms timer is used to ramp the speed up or down as necessary and issue Open Interface drive commands.

However, if the low-level controller is currently talking to the high level via the Command Module's USB port, these drive commands will get routed to the wrong serial destination. Thus, when the low-level controller is busy interacting with the high level, it will need to ensure that the drive module doesn't issue any drive commands related to acceleration/deceleration. Once the low level is done talking to the high level, it will have to resume the speed ramping operations to ensure that the robot moves smoothly instead of jerking about as it starts and stops.

Definition at line 179 of file LoDrive.h.

 
#define lo_stop_immediate (  )     lo_drive(0, LOBOT_OI_DRIVE_STRAIGHT, 0)

This function executes an immediate stop.

The high-level drive commands go through an acceleration/deceleration function to achieve the stated drive speed. However, when the low-level controller senses a dangerous situation (e.g., wheel drops, cliffs or bumps), it responds by taking appropriate action and then informing the high level with a suitable ACK message. When responding to low-level events, the low-level controller cannot afford to effect smooth acceleration/decelaration because that might cause big problems. Consider, for example, the robot approaching the edge of a stairway. When the cliff sensors fire, the robot has to stop immediately, pronto, right now, this very instant! If it were to decelerate smoothly, it would just topple down the stairs...

This stop function allows low-level sensor reaction functions to bypass the acceleration/deceleration functions that are used by the high-level drive commands.

Definition at line 128 of file LoDrive.h.

Referenced by lo_bumps(), and lo_wheel_drops().

 
#define lo_suspend_ramping (  )     lo_suspend_timer10()

This function can be used to temporarily suspend the drive module's acceleration/deceleration functionality. It works by inhibiting the 10ms generalized timer's interrupts. It is required because the 10ms timer is used to ramp the speed up or down as necessary and issue Open Interface drive commands.

However, if the low-level controller is currently talking to the high level via the Command Module's USB port, these drive commands will get routed to the wrong serial destination. Thus, when the low-level controller is busy interacting with the high level, it will need to ensure that the drive module doesn't issue any drive commands related to acceleration/deceleration.

Definition at line 162 of file LoDrive.h.


Function Documentation

int lo_backup ( int  speed,
int  distance 
)

This function backs up the robot by the specified amount at the specified speed. It returns the actual amount backed up.

NOTE: Positive values for the backup speed and distance parameters will result in moving the robot forward instead of backing it up.

Definition at line 295 of file LoDrive.c.

References abs(), lo_drive(), lo_make_word(), lo_rx(), lo_tx(), lo_wait(), LOBOT_OI_CMD_QUERY_LIST, and LOBOT_OI_SENSOR_DISTANCE.

Referenced by lo_bumps(), and lo_cliffs().

void lo_drive ( int  speed,
int  turn_radius,
char  smooth 
)

This function implements a "general" drive command that takes a speed and turn radius and converts it to the right set of Open Interface byte sequences. Additionally, this function takes a flag indicating whether the drive should be smooth (i.e., make use of the acceleration/deceleration functionality implemented by this module) or immediate (i.e., just implement the drive command without any acceleration/deceleration).

Definition at line 269 of file LoDrive.c.

References lo_resume_timer10, and lo_suspend_timer10.

Referenced by lo_backup(), lo_forward(), lo_left(), and lo_spin().

void lo_forward ( int   ) 

lobot's high-level controller works in terms of driving forwards, backwards and stopping as distinct commands for the robot. These functions implement the high-level drive commands using the generic lo_drive function.

Definition at line 132 of file LoDrive.c.

References lo_clamp(), and lo_drive().

void lo_init_drive ( void   ) 

Initialize the drive system.

The main function must call lo_init_drive() during initialization to ensure that the drive module's acceleration/deceleration functionality is setup properly. Internally, acceleration and deceleration are implemented using the ATmega168's Timer2 via the low-level controller's 10ms "generalized timer" callback mechanism. This function basically registers the callback function that implements the acceleration/deceleration feature with the timer module.

Definition at line 116 of file LoDrive.c.

References lo_add_timer10_cb().

void lo_left ( int  turn_radius  ) 

lobot's high-level controller works in terms of steering the robot using distinct left, right and straight commands. lobot also supports in-place turns, i.e., spinning.

These functions implement the high-level steering commands using the generic lo_drive function.

Definition at line 155 of file LoDrive.c.

References lo_clamp(), and lo_drive().

void lo_nop ( int   ) 

This command can be used by the high-level controller to have the robot continue to do whatever it is currently doing. This is useful when the high level doesn't have any real drive commands queued and ready for the low level. Without this NOP, the low-level controller will halt the robot if it doesn't receive a valid command within its timeout window.

Definition at line 129 of file LoDrive.c.

int lo_spin ( int  speed,
int  angle 
)

This function spins the robot in-place by the specified angle at the specified speed. It returns the actual amount spun.

Positive values for the spin angle result in ccw turns; negative angles result in cw turns.

Definition at line 320 of file LoDrive.c.

References abs(), lo_drive(), lo_make_word(), lo_rx(), lo_tx(), lo_wait(), LOBOT_OI_CMD_QUERY_LIST, and LOBOT_OI_SENSOR_ANGLE.

Referenced by lo_bumps(), and lo_cliffs().

char lo_stopped ( void   ) 

Returns true if the robot is currently stopped; false if the robot is currently moving.

Definition at line 348 of file LoDrive.c.

Generated on Sun May 8 08:17:10 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3