LoDrive.c File Reference

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

#include "LoDrive.h"
#include "LoSensors.h"
#include "LoUtils.h"
#include "LoIO.h"
#include "LoTimer.h"
#include "LoOpenInterface.h"
#include <avr/interrupt.h>
#include <stdlib.h>
Include dependency graph for LoDrive.c:

Go to the source code of this file.

Functions

static void accelerate_decelerate (void)
void lo_init_drive (void)
void lo_nop (int param)
void lo_forward (int speed)
void lo_reverse (int speed)
void lo_stop (int speed)
void lo_left (int turn_radius)
void lo_right (int turn_radius)
void lo_straight (int turn_radius)
void lo_cmd_spin (int angle)
static void drive_oi (int speed, int turn)
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)

Variables

static volatile int g_speed
static volatile int g_radius = LOBOT_OI_DRIVE_STRAIGHT
static volatile char g_ramp_flag
static volatile int g_target_speed

Detailed Description

Driving API for Robolocust iRobot Create Command Module control program.

This file defines the functions that implement the driving API for a control program meant to be run on the iRobot Create's Command Module. 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.c.


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:42:49 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3