Aria
2.8.0
|
Action that requests motion based on abstract ratios provided by diferent input sources. More...
#include <ArActionRatioInput.h>
Inherits ArAction.
Public Member Functions | |
virtual void | activate (void) |
void | addActivateCallback (ArFunctor *functor, ArListPos::Pos position=ArListPos::LAST) |
Adds a callback that is called when this action is activated. | |
void | addDeactivateCallback (ArFunctor *functor, ArListPos::Pos position=ArListPos::LAST) |
Adds a callback that is called when this action is deactivated. | |
void | addFireCallback (int priority, ArFunctor *functor) |
Adds a callback that is called from this actions fire call. More... | |
void | addToConfig (ArConfig *config, const char *section) |
Adds to a section in a config. | |
ArActionRatioInput (const char *name="RatioInput") | |
Constructor. More... | |
virtual void | deactivate (void) |
virtual ArActionDesired * | fire (ArActionDesired currentDesired) |
virtual ArActionDesired * | getDesired (void) |
virtual const ArActionDesired * | getDesired (void) const |
double | getRotRatio (void) |
Gets the rot ratio (from -100 (full right) to 100 (full left) | |
double | getThrottleRatio (void) |
Gets the throttle ratio (from 0 (stopped) to 100 (full throttle) | |
double | getTransRatio (void) |
Gets the trans ratio (from -100 (full backwards) to 100 (full forwards) | |
void | remActivateCallback (ArFunctor *functor) |
Removes a callback that was called when this action is activated. | |
void | remDeactivateCallback (ArFunctor *functor) |
Removes a callback that was called when this action is deactivated. | |
void | remFireCallback (ArFunctor *functor) |
Removes a callback that was called from this actions fire callback. | |
void | setLatRatio (double latRatio) |
Sets the lat ratio (from -100 (one way) to 100 (the other)) More... | |
void | setParameters (double fullThrottleForwards, double fullThrottleBackwards, double rotAtFullForwards, double rotAtFullBackwards, double rotAtStopped, double latAtFullForwards=0, double latAtFullBackwards=0, double latAtStopped=0) |
Sets the parameters. More... | |
void | setRatios (double transRatio, double rotRatio, double throttleRatio, double latRatio=0) |
Set ratios. More... | |
void | setRotRatio (double rotRatio) |
Sets the rot ratio (from -100 (full right) to 100 (full left) More... | |
void | setThrottleRatio (double throttleRatio) |
Sets the throttle ratio (from 0 (stopped) to 100 (full throttle) More... | |
void | setTransRatio (double transRatio) |
Sets the trans ratio (from -100 (full backwards) to 100 (full forwards) More... | |
virtual | ~ArActionRatioInput () |
Destructor. | |
Public Member Functions inherited from ArAction | |
ArAction (const char *name, const char *description="") | |
Constructor. | |
virtual const ArArg * | getArg (int number) const |
Gets the numbered argument. More... | |
virtual ArArg * | getArg (int number) |
Gets the numbered argument. | |
virtual const char * | getDescription (void) const |
Gets the long description of the action. | |
virtual const char * | getName (void) const |
Gets the name of the action. | |
virtual int | getNumArgs (void) const |
Find the number of arguments this action takes. | |
ArRobot * | getRobot () const |
Get the robot we are controlling, which was set by setRobot() | |
virtual bool | isActive (void) const |
Returns whether the action is active or not. | |
virtual void | log (bool verbose=true) const |
Log information about this action using ArLog. | |
virtual void | setRobot (ArRobot *robot) |
Sets the robot this action is driving. More... | |
virtual | ~ArAction () |
Desructor. | |
Protected Attributes | |
std::list< ArFunctor * > | myActivateCallbacks |
std::list< ArFunctor * > | myDeactivateCallbacks |
ArActionDesired | myDesired |
std::multimap< int, ArFunctor * > | myFireCallbacks |
double | myFullThrottleBackwards |
double | myFullThrottleForwards |
double | myLatAtFullBackwards |
double | myLatAtFullForwards |
double | myLatAtStopped |
double | myLatDeadZone |
double | myLatRatio |
bool | myPrinting |
double | myRotAtFullBackwards |
double | myRotAtFullForwards |
double | myRotAtStopped |
double | myRotDeadZone |
double | myRotRatio |
double | myThrottleRatio |
double | myTransDeadZone |
double | myTransRatio |
Protected Attributes inherited from ArAction | |
std::map< int, ArArg > | myArgumentMap |
std::string | myDescription |
bool | myIsActive |
std::string | myName |
int | myNumArgs |
ArRobot * | myRobot |
The robot we are controlling, set by the action resolver using setRobot() | |
Additional Inherited Members | |
Static Public Member Functions inherited from ArAction | |
static bool | getDefaultActivationState (void) |
Gets the default activation state for all ArActions. | |
static void | setDefaultActivationState (bool defaultActivationState) |
Sets the default activation state for all ArActions. | |
Protected Member Functions inherited from ArAction | |
void | setNextArgument (ArArg const &arg) |
Sets the argument type for the next argument (must only be used in a constructor!) | |
Static Protected Attributes inherited from ArAction | |
static bool | ourDefaultActivationState = true |
Action that requests motion based on abstract ratios provided by diferent input sources.
This action interprets input drive commands as three abstract ratios, translation, rotation, and throttle. (In this way it mimics many joysticks.) The translation speed input ranges from -100 to 100, where -100 requests maximum backwards speed, and 100 requests maximum forward speed, 0 requests no translational speed, and values in between request a linear percentage of the maximum. Similarly, rotation speed input ranges from -100 to 100, where -100 indicates maximum rightwards or clockwise rotation, 100 indicates maximum leftwards or counter-clockwise rotation, 0 requests no rotation, and values in between request a linear percentage of the maximum. The throttle input scales the other speed, and ranges from 0 (no motion) to 100 (maximum motion).
Seperate objects (e.g. ArRatioInputKeydrive, ArRatioInputJoydrive, ArRAtionInputRobotJoydrive) are used to provide input.
When this action is activated it resets all its input ratios to 0 (including throttle).
Configuration parameters are used to map the maximum ratios to actual robot speeds. These are set be default to the robot's maximum configured velocities at startup but you can override them with ArConfig parameters (and call addToConfig()) or setParameters().
ArActionRatioInput::ArActionRatioInput | ( | const char * | name = "RatioInput" | ) |
Constructor.
name | name of the action |
void ArActionRatioInput::addFireCallback | ( | int | priority, |
ArFunctor * | functor | ||
) |
Adds a callback that is called from this actions fire call.
These callbacks are actually called in the order of lowest number to highest number, but this still means higher numbers are more important since throttle set by those will override the lower.
void ArActionRatioInput::setLatRatio | ( | double | latRatio | ) |
Sets the lat ratio (from -100 (one way) to 100 (the other))
This checks the input for greather than 100 and less than -100 and pulls it to within that range.
void ArActionRatioInput::setParameters | ( | double | fullThrottleForwards, |
double | fullThrottleBackwards, | ||
double | rotAtFullForwards, | ||
double | rotAtFullBackwards, | ||
double | rotAtStopped, | ||
double | latAtFullForwards = 0 , |
||
double | latAtFullBackwards = 0 , |
||
double | latAtStopped = 0 |
||
) |
Sets the parameters.
fullThrottleForwards | the speed we go forwards at at full throttle (mm/sec) |
fullThrottleBackwards | the speed we go backwards at at full throttle (mm/sec) |
rotAtFullForwards | the speed we turn at at full throttle forwards |
rotAtFullBackwards | the speed we turn at at full throttle backwards |
rotAtStopped | the speed we turn at if there is no forward/backward motion |
rotAtFullForwards | the speed we turn at at full throttle forwards |
latAtFullForwards | the lateral speed we go at at full throttle (mm/sec) (if robot supports lateral motion) |
latAtFullBackwards | the lateral speed we go at at full throttle (mm/sec) (if robot supports lateral motion) |
latAtStopped | the lateral speed we go at if stopped. |
void ArActionRatioInput::setRatios | ( | double | transRatio, |
double | rotRatio, | ||
double | throttleRatio, | ||
double | latRatio = 0 |
||
) |
Set ratios.
This checks the inputs and pulls them into the valid range.
void ArActionRatioInput::setRotRatio | ( | double | rotRatio | ) |
Sets the rot ratio (from -100 (full right) to 100 (full left)
This checks the input for greather than 100 and less than -100 and pulls it to within that range.
void ArActionRatioInput::setThrottleRatio | ( | double | throttleRatio | ) |
Sets the throttle ratio (from 0 (stopped) to 100 (full throttle)
This checks the input for greather than 100 and less than 0 and pulls it to within that range.
void ArActionRatioInput::setTransRatio | ( | double | transRatio | ) |
Sets the trans ratio (from -100 (full backwards) to 100 (full forwards)
This checks the input for greather than 100 and less than -100 and pulls it to within that range.