Smart Car Controller  1.0
Library to manage a two wheeled robotic vehicle (DC Motors)
Action Sequences

Action sequences are a way of defining a sequential actions that the library will execute to move the vehicle (ie, a 'recipe' for movement). They save time in not having to program common combinations of actions and monitoring each completion in the application sketch. The library executes the action sequence in the background freeing the application to run other higher priority tasks.

An simple example is when a front bump switch detects a collision, triggering the evasive action defined by:

  • stop the vehicle
  • pause a short while
  • reverse away from the obstacle
  • pause a short while
  • spin to another direction
  • resume normal vehicle motion

These actions can be defined in a list of actions to be performed and passed to the library for execution:

static const PROGMEM MD_SmartCar::actionItem_t seq[] =
{
{ MD_SmartCar::MOVE, -PI, -PI },
};
@ MOVE
executes a move(); param 0 left rotate, param 1 right rotate
Definition: MD_SmartCar.h:175
@ END
marks the end of the action list; should always be last item.
Definition: MD_SmartCar.h:179
@ STOP
executes a stop()
Definition: MD_SmartCar.h:178
@ SPIN
executes a spin(); param 0 spin percentage
Definition: MD_SmartCar.h:176
@ PAUSE
executes a pause; param 0 milliseconds pause
Definition: MD_SmartCar.h:177
Definition: MD_SmartCar.h:188

The action sequence is defined as an array of MD_SmartCar::actionItem_t records. Each record contains the action to be performed and the parameters relevant to that action (summarized in the table below). The last record in the array must always be the END action or the library will continue reading random memory beyond the end of the sequence.

Sequences may be completely predefined, allowing them to be stored in static (PROGMEM) memory to preserve dynamic RAM, or they may be built and/or modified 'on the fly' in RAM.

The list of actions that can be defined an actionItem_t are listed given by the enumerated type MD_SmartCar::actionId_t.

ActionId_t Comment Parameter 0 Parameter 1
MD_SmartCar::DRIVE executes drive() Linear Velocity Angular Velocity
MD_SmartCar::MOVE executes move() Left rotate Right rotate
MD_SmartCar::SPIN executes spin() Spin percentage Not used
MD_SmartCar::PAUSE executes pause Milliseconds Not used
MD_SmartCar::STOP executes stop() Not used Not used
MD_SmartCar::END marks seq end Not used Not used