![]() |
Robotic Car Controller 1.0
Library to manage a two wheeled robotic vehicle (Stepper Motors)
|
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:
These actions can be defined in a list of actions to be performed and passed to the library for execution:
The action sequence is defined as an array of MD_SmartCar2::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_SmartCar2::actionId_t.
ActionId_t | Comment | Parameter 0 | Parameter 1 |
---|---|---|---|
MD_SmartCar2::DRIVE | executes drive() | Linear Velocity | Angular Velocity |
MD_SmartCar2::MOVE | executes move() | Left rotate | Right rotate |
MD_SmartCar2::SPIN | executes spin() | Spin percentage | Not used |
MD_SmartCar2::PAUSE | executes pause | Milliseconds | Not used |
MD_SmartCar2::STOP | executes stop() | Not used | Not used |
MD_SmartCar2::END | marks seq end | Not used | Not used |