OpenSim::ControlLinear Class Reference

#include <ControlLinear.h>

Inheritance diagram for OpenSim::ControlLinear:
OpenSim::Control OpenSim::Object

List of all members.

Public Member Functions

 ControlLinear ()
 Default constructor.
 ControlLinear (const ControlLinear &aControl)
 Copy constructor.
virtual ~ControlLinear ()
 Destructor.
virtual Objectcopy () const
 Construct a copy of this control.
void copyData (const ControlLinear &aControl)
 Copy the member variables of the specified control.
ControlLinearoperator= (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:

  • Does not require properties
  • returns bool on failure for a more graceful batch simplification.

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.

Constructor & Destructor Documentation

ControlLinear::ControlLinear (  ) 

Default constructor.

Parameters:
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.

Parameters:
aControl Control to copy.
ControlLinear::~ControlLinear (  )  [virtual]

Destructor.


Member Function Documentation

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.

Parameters:
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.

Parameters:
aT Time at which to get the control.
Returns:
Control value. If the value of the curve is not defined, SimTK::NaN is returned. If the control is set to extrapolate, getExtraplate, and the time is before the first node or after the last node, then an extrapolation is performed to determin the value of the control curve. Otherwise, the value of either the first control node or last control node is returned.

Implements OpenSim::Control.

double ControlLinear::getControlValueMax ( double  aT = 0.0  )  [virtual]

Get the maximum allowed value of this control at time aT.

Parameters:
aT Time at which to get the control.
Returns:
Maximum allowed control value. If the value of the curve is not defined, _defaultMax is returned. If the control is set to extrapolate, getExtraplate, and the time is before the first node or after the last node, then an extrapolation is performed to determin the value of the control curve. Otherwise, the value of either the first control node or last control node is returned.

Implements OpenSim::Control.

double ControlLinear::getControlValueMin ( double  aT = 0.0  )  [virtual]

Get the minimum allowed value of this control at time aT.

Parameters:
aT Time at which to get the control.
Returns:
Minimum allowed control value. If the value of the curve is not defined, _defaultMin is returned. If the control is set to extrapolate, getExtraplate, and the time is before the first node or after the last node, then an extrapolation is performed to determin the value of the control curve. Otherwise, the value of either the first control node or last control node is returned.

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.

Returns:
const ref to 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.

Returns:
Value of position gain for the PD follower filter.
double ControlLinear::getKv (  )  const

Get velocity gain for PD follower filter.

This value is relevant only if the PD follower filter will be used.

Returns:
Value of velocity gain for the PD follower filter.
const double ControlLinear::getLastTime (  )  const [virtual]

Get const ref to the time corresponding to Last node.

Returns:
const ref to 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.

Returns:
Number of parameters.

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.

Parameters:
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.
Returns:
Number of parameters indices in the list.

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.

Parameters:
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.
Returns:
Number of parameters in the list.

Implements OpenSim::Control.

double ControlLinear::getParameterMax ( int  aI  )  const [virtual]

Get the maximum value of a control parameter.

Parameters:
aI Index of the parameter.
Returns:
Maximum value of the parameter.
Exceptions:
Exception if aI is invalid.

Implements OpenSim::Control.

double ControlLinear::getParameterMin ( int  aI  )  const [virtual]

Get the minimum value of a control parameter.

Parameters:
aI Index of the parameter.
Returns:
Minimum value of the parameter.
Exceptions:
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.

Parameters:
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.
Exceptions:
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.

Parameters:
aI Index of the parameter.
Returns:
Time at which the control parameter occurs. For ControlLinear this value is not defined, and so SimTK::NaN is always returned.
Exceptions:
Exception if aI is invalid.

Implements OpenSim::Control.

double ControlLinear::getParameterValue ( int  aI  )  const [virtual]

Get the value of a control parameter.

Parameters:
aI Index of the parameter.
Returns:
Value of the parameter. For ControlLinear, the parameter value is simply the value of the control node.

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.

Returns:
True if steps functions are used. False if linear interpolation is used.
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.

Parameters:
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.
Returns:
Y value corresponding to aX.
ControlLinear & ControlLinear::operator= ( const ControlLinear aControl  ) 

Assignment operator.

Returns:
Reference to the altered object.

Reimplemented from OpenSim::Control.

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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
aI Index of the parameter.
aMax Maximum value of the parameter.
Exceptions:
Exception if aI is invalid.

Implements OpenSim::Control.

void ControlLinear::setParameterMin ( int  aI,
double  aMin 
) [virtual]

Set the minimum value of a control parameter.

Parameters:
aI Index of the parameter.
aMin Minimum value of the parameter.
Exceptions:
Exception if aI is invalid.

Implements OpenSim::Control.

void ControlLinear::setParameterValue ( int  aI,
double  aX 
) [virtual]

Set the value of a control parameter.

Parameters:
aI Index of the parameter.
aX Value of the parameter. For ControlLinear, the parameter value is simply the value of the control node.
See also:
getNumParameters()
Exceptions:
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.

Parameters:
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:

  • Does not require properties
  • returns bool on failure for a more graceful batch simplification.

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.

Parameters:
aProperties Property set containing the needed properties for this method. The property set should contain:
NAME cutoff_frequency
distance

Exceptions:
Exception if an error is encountered.

Reimplemented from OpenSim::Control.


Member Data Documentation

double& OpenSim::ControlLinear::_kp [protected]
double& OpenSim::ControlLinear::_kv [protected]

Position gain for PD follower filter.

Velocity gain for PD follower filter.

Flag that indicates whether or not to linearly interpolate between nodes or use step functions.

Array of control nodes.

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.


The documentation for this class was generated from the following files:

Generated on Sun Sep 25 00:19:54 2011 for OpenSim by  doxygen 1.6.1