#include <ControlLinear.h>
Public Member Functions | |
ControlLinear () | |
Default constructor. | |
ControlLinear (const ControlLinear &aControl) | |
Copy constructor. | |
virtual | ~ControlLinear () |
Destructor. | |
virtual Object * | copy () const |
Construct a copy of this control. | |
void | copyData (const ControlLinear &aControl) |
Copy the member variables of the specified control. | |
ControlLinear & | operator= (const ControlLinear &aControl) |
Assignment operator. | |
void | setUseSteps (bool aTrueFalse) |
Set whether or not step functions are used between control nodes or linear interpolation. | |
bool | getUseSteps () const |
Get whether or not step functions are used between control nodes or linear interpolation. | |
void | setKp (double aKp) |
Set position gain for PD follower filter. | |
double | getKp () const |
Get position gain for PD follower filter. | |
void | setKv (double aKv) |
Set velocity gain for PD follower filter. | |
double | getKv () const |
Get velocity gain for PD follower filter. | |
virtual int | getNumParameters () const |
Get the number of parameters that are used to specify the control curve. | |
virtual void | setParameterMin (int aI, double aMin) |
Set the minimum value of a control parameter. | |
virtual double | getParameterMin (int aI) const |
Get the minimum value of a control parameter. | |
virtual void | setParameterMax (int aI, double aMax) |
Set the maximum value of a control parameter. | |
virtual double | getParameterMax (int aI) const |
Get the maximum value of a control parameter. | |
virtual double | getParameterTime (int aI) const |
Get the time at which a parameter is specified. | |
virtual void | getParameterNeighborhood (int aI, double &rTLower, double &rTUpper) const |
Get the time neighborhood (i.e., the lower and upper bounds of time) in which a control parameter affects the value of the control curve. | |
virtual int | getParameterList (double aT, Array< int > &rList) |
Get the list of parameters that affect the control curve at a specified time. | |
virtual int | getParameterList (double aT1, double aT2, Array< int > &rList) |
Get the list of parameters that affect the control curve between two specified times and that do NOT affect the control curve below the lower of these two times. | |
virtual void | setParameterValue (int aI, double aP) |
Set the value of a control parameter. | |
virtual double | getParameterValue (int aI) const |
Get the value of a control parameter. | |
virtual void | setControlValue (double aT, double aX) |
Set the value of this control curve at time aT. | |
virtual double | getControlValue (double aT) |
Get the value of this control at time aT. | |
virtual double | getControlValueMin (double aT=0.0) |
Get the minimum allowed value of this control at time aT. | |
virtual void | setControlValueMin (double aT, double aX) |
Set the minimum value of this control curve at time aT. | |
virtual double | getControlValueMax (double aT=0.0) |
Get the maximum allowed value of this control at time aT. | |
virtual void | setControlValueMax (double aT, double aX) |
Set the maximum value of this control curve at time aT. | |
void | clearControlNodes () |
ArrayPtrs< ControlLinearNode > & | getControlValues () |
ArrayPtrs< ControlLinearNode > & | getControlMinValues () |
ArrayPtrs< ControlLinearNode > & | getControlMaxValues () |
void | insertNewValueNode (int index, const ControlLinearNode &newNode) |
void | insertNewMinNode (int index, const ControlLinearNode &newNode) |
void | insertNewMaxNode (int index, const ControlLinearNode &newNode) |
virtual const double | getFirstTime () const |
Get const ref to the time corresponding to first node. | |
virtual const double | getLastTime () const |
Get const ref to the time corresponding to Last node. | |
virtual void | simplify (const PropertySet &aProperties) |
Simplify the control curve. | |
bool | simplify (const double &cutoffFrequency, const double &distance) |
Another interface to simplify that:
| |
virtual void | filter (double aT) |
Filter the control curve at a particular time using a PD follower filter. | |
Static Public Member Functions | |
static double | Interpolate (double aX1, double aY1, double aX2, double aY2, double aX) |
Linearly interpolate or extrapolate given two points. | |
Protected Member Functions | |
virtual void | setupProperties () |
Connect properties to local pointers. | |
Protected Attributes | |
PropertyBool | _propUseSteps |
Flag that indicates whether or not to linearly interpolate between nodes or use step functions. | |
PropertyObjArray < ControlLinearNode > | _propXNodes |
Array of control nodes. | |
PropertyObjArray < ControlLinearNode > | _propMinNodes |
PropertyObjArray < ControlLinearNode > | _propMaxNodes |
PropertyDbl | _propKp |
Position gain for PD follower filter. | |
PropertyDbl | _propKv |
Velocity gain for PD follower filter. | |
bool & | _useSteps |
ArrayPtrs< ControlLinearNode > & | _xNodes |
ArrayPtrs< ControlLinearNode > & | _minNodes |
ArrayPtrs< ControlLinearNode > & | _maxNodes |
double & | _kp |
double & | _kv |
ControlLinearNode | _searchNode |
Utility node for speeding up searches for control values in getControlValue() and elsewhere. |
ControlLinear::ControlLinear | ( | ) |
Default constructor.
aX | Pointer to an array of control nodes. By default, the value of aX is NULL. If it is not NULL, the control nodes pointed to by aX are copied. This class keeps its own internal array of control nodes. The caller owns the array pointed to by aX, is free to use this array in any way, and, if necessary, is responsible for deleting the memory associated with aX. | |
aName | Name of the control. |
ControlLinear::ControlLinear | ( | const ControlLinear & | aControl | ) |
Copy constructor.
aControl | Control to copy. |
ControlLinear::~ControlLinear | ( | ) | [virtual] |
Destructor.
void ControlLinear::clearControlNodes | ( | ) |
Object * ControlLinear::copy | ( | ) | const [virtual] |
Construct a copy of this control.
Reimplemented from OpenSim::Object.
void ControlLinear::copyData | ( | const ControlLinear & | aControl | ) |
Copy the member variables of the specified control.
Reimplemented from OpenSim::Control.
void ControlLinear::filter | ( | double | aT | ) | [virtual] |
Filter the control curve at a particular time using a PD follower filter.
aT | Time at which to compute a new, filtered control value |
Reimplemented from OpenSim::Control.
ArrayPtrs<ControlLinearNode>& OpenSim::ControlLinear::getControlMaxValues | ( | ) | [inline] |
ArrayPtrs<ControlLinearNode>& OpenSim::ControlLinear::getControlMinValues | ( | ) | [inline] |
double ControlLinear::getControlValue | ( | double | aT | ) | [virtual] |
Get the value of this control at time aT.
aT | Time at which to get the control. |
Implements OpenSim::Control.
double ControlLinear::getControlValueMax | ( | double | aT = 0.0 |
) | [virtual] |
Get the maximum allowed value of this control at time aT.
aT | Time at which to get the control. |
Implements OpenSim::Control.
double ControlLinear::getControlValueMin | ( | double | aT = 0.0 |
) | [virtual] |
Get the minimum allowed value of this control at time aT.
aT | Time at which to get the control. |
Implements OpenSim::Control.
ArrayPtrs<ControlLinearNode>& OpenSim::ControlLinear::getControlValues | ( | ) | [inline] |
const double ControlLinear::getFirstTime | ( | ) | const [virtual] |
Get const ref to the time corresponding to first node.
Reimplemented from OpenSim::Control.
double ControlLinear::getKp | ( | ) | const |
Get position gain for PD follower filter.
This value is relevant only if the PD follower filter will be used.
double ControlLinear::getKv | ( | ) | const |
Get velocity gain for PD follower filter.
This value is relevant only if the PD follower filter will be used.
const double ControlLinear::getLastTime | ( | ) | const [virtual] |
Get const ref to the time corresponding to Last node.
Reimplemented from OpenSim::Control.
int ControlLinear::getNumParameters | ( | ) | const [virtual] |
Get the number of parameters that are used to specify the control curve.
Implements OpenSim::Control.
int ControlLinear::getParameterList | ( | double | aTLower, | |
double | aTUpper, | |||
Array< int > & | rList | |||
) | [virtual] |
Get the list of parameters that affect the control curve between two specified times and that do NOT affect the control curve below the lower of these two times.
This method is useful when solving for a set of controls for a dynamic simulation. When solving for a set of controls, one always wants to go forward in time. Therefore, one does not want to change control parameters that affect the control curve at past times.
A control parameter is included in the list only if it affects the control curve in the specified time interval AND does NOT affect the control curve below the lower bound of the specified time interval. So, it is possible that some of the parameters on the returned list could affect the control curve at times greater than the upper bound of the specified time interval.
aTLower | Lower time bound. The control curves are not affected below this time by any of the returned parameters. | |
aTUpper | Upper time bound. The control curves may be affected for times greater than this time. | |
rList | List of control parameters (their indices to be exact) that affect the curve between aTLower and aTUpper but not before aTLower. |
Implements OpenSim::Control.
int ControlLinear::getParameterList | ( | double | aT, | |
Array< int > & | rList | |||
) | [virtual] |
Get the list of parameters that affect the control curve at a specified time.
aT | Time in question. | |
rList | Array of control parameters that affect the curve at time aT. For ControlLinear, if aT lies between two nodes, the indices of these two nodes are returned; if aT equals the time at which a node occurs, the index of that node is returned; if aT is less than the time of the first node in the array, the index of the first node (i.e., 0) is returned; if aT is greater than the time of the last node, the index of the last node (i.e., size-1) is returned. |
Implements OpenSim::Control.
double ControlLinear::getParameterMax | ( | int | aI | ) | const [virtual] |
Get the maximum value of a control parameter.
aI | Index of the parameter. |
Exception | if aI is invalid. |
Implements OpenSim::Control.
double ControlLinear::getParameterMin | ( | int | aI | ) | const [virtual] |
Get the minimum value of a control parameter.
aI | Index of the parameter. |
Exception | if aI is invalid. |
Implements OpenSim::Control.
void ControlLinear::getParameterNeighborhood | ( | int | aI, | |
double & | rTLower, | |||
double & | rTUpper | |||
) | const [virtual] |
Get the time neighborhood (i.e., the lower and upper bounds of time) in which a control parameter affects the value of the control curve.
Changes in the specified parameter are guarranteed not to change the value of the control curve below the lower bound time or above the upper bound time. If a parameter influences the value of the control curve for all times, -SimTKInfinity and SimTK::Infinity are returned for the upper and lower bound times, respectively.
aI | Index of the parameter. | |
rTLower | Time below which the curve is not affected by the specified parameter. For ControlLinear, aTLower is the time of parameter aI-1 or of aI if there is no parameter aI-1. If there are no nodes at all or if aI is invalid, aTLower is given the value SimTK::NaN. | |
rTUpper | Time above which the curve is not affected by the specified parameter. For ControlLinear, aTUpper is the time of parameter aI+1 or of aI if there is no parameter aI+1. If there are no nodes at all or if aI is invalid, aTUpper is given the value SimTK::NaN. |
Exception | if aI is invalid. |
Implements OpenSim::Control.
double ControlLinear::getParameterTime | ( | int | aI | ) | const [virtual] |
Get the time at which a parameter is specified.
Parameters for some types of control curves do not have a time at which they are specified. For example, in a Fourier series the control parameters are the cooefficients in the expansion, and each term in the expansion corresponds not to a specific time but to a frequency. Another example is a constant that has the same value for all times. In these cases, this method returns SimTK::NaN.
aI | Index of the parameter. |
Exception | if aI is invalid. |
Implements OpenSim::Control.
double ControlLinear::getParameterValue | ( | int | aI | ) | const [virtual] |
Get the value of a control parameter.
aI | Index of the parameter. |
Implements OpenSim::Control.
bool ControlLinear::getUseSteps | ( | ) | const |
Get whether or not step functions are used between control nodes or linear interpolation.
When step functions are used, the value of the control curve between two nodes is the value of the node that occurs later in time.
void OpenSim::ControlLinear::insertNewMaxNode | ( | int | index, | |
const ControlLinearNode & | newNode | |||
) | [inline] |
void OpenSim::ControlLinear::insertNewMinNode | ( | int | index, | |
const ControlLinearNode & | newNode | |||
) | [inline] |
void OpenSim::ControlLinear::insertNewValueNode | ( | int | index, | |
const ControlLinearNode & | newNode | |||
) | [inline] |
double ControlLinear::Interpolate | ( | double | aX1, | |
double | aY1, | |||
double | aX2, | |||
double | aY2, | |||
double | aX | |||
) | [static] |
Linearly interpolate or extrapolate given two points.
aX1 | X coordinate of point 1. | |
aY1 | Y coordinate of point 1. | |
aX2 | X coordinate of point 2. | |
aY2 | Y coordinate of point 2. | |
aX | X coordinate whose corresponding Y coordinate is desired. |
ControlLinear & ControlLinear::operator= | ( | const ControlLinear & | aControl | ) |
void ControlLinear::setControlValue | ( | double | aT, | |
double | aX | |||
) | [virtual] |
Set the value of this control curve at time aT.
This method adds a set of control parameters at the specified time unless the specified time equals the time of an existing control node, in which case the parameters of that control node are changed.
aT | Time at which to set the control. | |
aX | Control value. |
Implements OpenSim::Control.
void ControlLinear::setControlValueMax | ( | double | aT, | |
double | aMax | |||
) | [virtual] |
Set the maximum value of this control curve at time aT.
This method adds a set of control parameters at the specified time unless the specified time equals the time of an existing control node, in which case the parameters of that control node are changed.
aT | Time at which to set the control. | |
aMax | Maximum allowed control value. |
Implements OpenSim::Control.
void ControlLinear::setControlValueMin | ( | double | aT, | |
double | aMin | |||
) | [virtual] |
Set the minimum value of this control curve at time aT.
This method adds a set of control parameters at the specified time unless the specified time equals the time of an existing control node, in which case the parameters of that control node are changed.
aT | Time at which to set the control. | |
aMin | Minimum allowed control value. |
Implements OpenSim::Control.
void ControlLinear::setKp | ( | double | aKp | ) |
Set position gain for PD follower filter.
This value is relevant only if the PD follower filter will be used.
aKp | Value of position gain for the PD follower filter. |
void ControlLinear::setKv | ( | double | aKv | ) |
Set velocity gain for PD follower filter.
This value is relevant only if the PD follower filter will be used.
aKv | Value of velocity gain for the PD follower filter. |
void ControlLinear::setParameterMax | ( | int | aI, | |
double | aMax | |||
) | [virtual] |
Set the maximum value of a control parameter.
aI | Index of the parameter. | |
aMax | Maximum value of the parameter. |
Exception | if aI is invalid. |
Implements OpenSim::Control.
void ControlLinear::setParameterMin | ( | int | aI, | |
double | aMin | |||
) | [virtual] |
Set the minimum value of a control parameter.
aI | Index of the parameter. | |
aMin | Minimum value of the parameter. |
Exception | if aI is invalid. |
Implements OpenSim::Control.
void ControlLinear::setParameterValue | ( | int | aI, | |
double | aX | |||
) | [virtual] |
Set the value of a control parameter.
aI | Index of the parameter. | |
aX | Value of the parameter. For ControlLinear, the parameter value is simply the value of the control node. |
Exception | if aI is invalid. |
Implements OpenSim::Control.
void ControlLinear::setupProperties | ( | void | ) | [protected, virtual] |
Connect properties to local pointers.
Reimplemented from OpenSim::Control.
void ControlLinear::setUseSteps | ( | bool | aTrueFalse | ) |
Set whether or not step functions are used between control nodes or linear interpolation.
When step functions are used, the value of the control curve between two nodes is the value of the node that occurs later in time.
aTrueFalse | If true, step functions will be used to determine the value between adjacent nodes. If false, linear interpolation will be used. |
bool ControlLinear::simplify | ( | const double & | cutoffFrequency, | |
const double & | distance | |||
) |
Another interface to simplify that:
void ControlLinear::simplify | ( | const PropertySet & | aProperties | ) | [virtual] |
Simplify the control curve.
The number of control nodes is reduced by first applying a lowpass filter to the sequence of control nodes using a specified cutoff frequency and then removing nodes that keep the curve within a specified distance to the low-pass filtered curve.
aProperties | Property set containing the needed properties for this method. The property set should contain: NAME cutoff_frequency distance |
Exception | if an error is encountered. |
Reimplemented from OpenSim::Control.
double& OpenSim::ControlLinear::_kp [protected] |
double& OpenSim::ControlLinear::_kv [protected] |
ArrayPtrs<ControlLinearNode>& OpenSim::ControlLinear::_maxNodes [protected] |
ArrayPtrs<ControlLinearNode>& OpenSim::ControlLinear::_minNodes [protected] |
PropertyDbl OpenSim::ControlLinear::_propKp [protected] |
Position gain for PD follower filter.
PropertyDbl OpenSim::ControlLinear::_propKv [protected] |
Velocity gain for PD follower filter.
PropertyBool OpenSim::ControlLinear::_propUseSteps [protected] |
Flag that indicates whether or not to linearly interpolate between nodes or use step functions.
Array of control nodes.
ControlLinearNode OpenSim::ControlLinear::_searchNode [protected] |
Utility node for speeding up searches for control values in getControlValue() and elsewhere.
Without this node, a control node would need to be contructed, but this is too expensive. It is better to contruct a node up front, and then just alter the time.
bool& OpenSim::ControlLinear::_useSteps [protected] |
ArrayPtrs<ControlLinearNode>& OpenSim::ControlLinear::_xNodes [protected] |