Helper base class for BeoSub motor actions. More...
#include <BeoSub/BeoSubAction.H>
Public Member Functions | |
BeoSubAction (BeoSub *bs, const bool pulseWidthControl=false) | |
Constructor. | |
virtual | ~BeoSubAction () |
Destructor. | |
virtual bool | execute (const float target, const bool stabil, const int itsMaxIter=100) |
Execute the action. | |
virtual bool | pulseWidthExecute (const float target, const bool stabil, const int itsMaxIter=100) |
Protected Member Functions | |
virtual bool | activate (const bool incr)=0 |
Activate the action for one step. | |
virtual bool | turnOnMotor (const bool incr)=0 |
virtual bool | turnOffMotor (const bool incr)=0 |
virtual float | getPosition () const =0 |
Get a reading of the current position. | |
virtual bool | stabilize (const bool pulseWidthControl=false)=0 |
Stabilize whatever is not being modified by the action. | |
virtual float | difference (float pos, float target)=0 |
Calculate current and target value differences. | |
Protected Attributes | |
BeoSub * | itsBeoSub |
float | itsDeadBand |
our BeoSub, which holds our actuators & instruments | |
bool | pulseWidthControl |
deadband | |
float | itsGainP |
true when using pulse width control, number of pusle control when false | |
float | itsGainD |
Gain for Propositional Control. | |
float | itsGainI |
Gain for Derivative Control. | |
int | turnOnTime |
Gain for Integral Control. | |
float | itsErrorHistory [20] |
Number of time steps (iterations) for the motor to turn on when going pule interval control. | |
int | itsErrIndex |
storing pass 20 iterations value | |
float | u |
index top iterate the history |
Helper base class for BeoSub motor actions.
The base class defines an interface that will then be used in various derived forms in order to perfom a variety of actions
Definition at line 47 of file BeoSubAction.H.
BeoSubAction::BeoSubAction | ( | BeoSub * | bs, | |
const bool | pulseWidthControl = false | |||
) |
Constructor.
Definition at line 45 of file BeoSubAction.C.
BeoSubAction::~BeoSubAction | ( | ) | [virtual] |
Destructor.
Definition at line 50 of file BeoSubAction.C.
virtual bool BeoSubAction::activate | ( | const bool | incr | ) | [protected, pure virtual] |
Activate the action for one step.
incr | if true, the one step of activation should tend to increase the value returned by getPosition(), otherwise it should tend to decrease it |
Implemented in BeoSubActionDive, and BeoSubActionTurn.
Referenced by execute().
virtual float BeoSubAction::difference | ( | float | pos, | |
float | target | |||
) | [protected, pure virtual] |
Calculate current and target value differences.
Implemented in BeoSubActionDive, and BeoSubActionTurn.
Referenced by execute().
bool BeoSubAction::execute | ( | const float | target, | |
const bool | stabil, | |||
const int | itsMaxIter = 100 | |||
) | [virtual] |
Execute the action.
This will attempt to reach the target reading by iteratively outputing motor commands and monitoring the instruments. If stabil is true, we will attempt to maintain the sub stable while executing the action. Returns true on success.
Definition at line 54 of file BeoSubAction.C.
References activate(), difference(), getPosition(), itsDeadBand, itsErrIndex, itsErrorHistory, itsGainD, itsGainI, itsGainP, pulseWidthControl, stabilize(), and u.
Referenced by BeoSubActionTurn::stabilize(), and BeoSubActionDive::stabilize().
virtual float BeoSubAction::getPosition | ( | ) | const [protected, pure virtual] |
Get a reading of the current position.
Implemented in BeoSubActionDive, and BeoSubActionTurn.
Referenced by execute().
virtual bool BeoSubAction::stabilize | ( | const bool | pulseWidthControl = false |
) | [protected, pure virtual] |
Stabilize whatever is not being modified by the action.
Implemented in BeoSubActionDive, and BeoSubActionTurn.
Referenced by execute().
float BeoSubAction::itsDeadBand [protected] |
our BeoSub, which holds our actuators & instruments
Definition at line 90 of file BeoSubAction.H.
Referenced by BeoSubActionDive::BeoSubActionDive(), BeoSubActionTurn::BeoSubActionTurn(), and execute().
int BeoSubAction::itsErrIndex [protected] |
storing pass 20 iterations value
Definition at line 100 of file BeoSubAction.H.
Referenced by execute().
float BeoSubAction::itsErrorHistory[20] [protected] |
Number of time steps (iterations) for the motor to turn on when going pule interval control.
Definition at line 99 of file BeoSubAction.H.
Referenced by execute().
float BeoSubAction::itsGainD [protected] |
Gain for Propositional Control.
Definition at line 94 of file BeoSubAction.H.
Referenced by BeoSubActionDive::BeoSubActionDive(), BeoSubActionTurn::BeoSubActionTurn(), and execute().
float BeoSubAction::itsGainI [protected] |
Gain for Derivative Control.
Definition at line 95 of file BeoSubAction.H.
Referenced by BeoSubActionDive::BeoSubActionDive(), BeoSubActionTurn::BeoSubActionTurn(), and execute().
float BeoSubAction::itsGainP [protected] |
true when using pulse width control, number of pusle control when false
Definition at line 93 of file BeoSubAction.H.
Referenced by BeoSubActionDive::BeoSubActionDive(), BeoSubActionTurn::BeoSubActionTurn(), and execute().
bool BeoSubAction::pulseWidthControl [protected] |
int BeoSubAction::turnOnTime [protected] |
Gain for Integral Control.
Definition at line 97 of file BeoSubAction.H.
float BeoSubAction::u [protected] |
index top iterate the history
Definition at line 101 of file BeoSubAction.H.
Referenced by execute().