OpenSim  OpenSim 3.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
OpenSim::CorrectionController Class Reference

This is a simple feedback controller to be used in generating a forward dynamic simulation. More...

#include <CorrectionController.h>

Inheritance diagram for OpenSim::CorrectionController:
OpenSim::TrackingController OpenSim::Controller OpenSim::ModelComponent OpenSim::Object

Public Member Functions

 CorrectionController ()
 CorrectionController (const std::string &aFileName, bool aUpdateFromXMLNode=true)
 CorrectionController (const CorrectionController &aController)
virtual ~CorrectionController ()
CorrectionControlleroperator= (const CorrectionController &aController)
 Assignment operator.
double getKp () const
void setKp (double aKp)
double getKv () const
void setKv (double aKv)
virtual void computeControls (const SimTK::State &s, SimTK::Vector &controls) const
 Controller interface.
- Public Member Functions inherited from OpenSim::TrackingController
 TrackingController ()
 Default constructor.
 TrackingController (const TrackingController &TrackingController)
 Copy constructor.
virtual ~TrackingController ()
 Destructor.
TrackingControlleroperator= (const TrackingController &TrackingController)
 Assignment operator.
virtual void setDesiredStatesStorage (const Storage *aYDesStore)
 Set this class's pointer to the storage object containing desired model states to point to the storage object passed into this method.
virtual const StoragegetDesiredStatesStorage () const
- Public Member Functions inherited from OpenSim::Controller
 OpenSim_DECLARE_PROPERTY (isDisabled, bool,"Flag (true or false) indicating whether or not the controller is disabled.")
 OpenSim_DECLARE_LIST_PROPERTY (actuator_list, std::string,"The list of model actuators that this controller will control.""The keyword ALL indicates the controller will controll all the acuators in the model")
 Controller ()
 Default constructor.
bool isDisabled () const
 Get whether or not this controller is disabled.
void setDisabled (bool disableFlag)
 Disable this controller.
void setActuators (const Set< Actuator > &actuators)
 replace the current set of actuators with the provided set
void addActuator (const Actuator &actuator)
 add to the current set of actuators
const Set< Actuator > & getActuatorSet () const
 get a const reference to the current set of actuators
Set< Actuator > & updActuators ()
 get a writable reference to the set of actuators for this controller
int getNumControls () const

Protected Member Functions

void setupProperties ()
 Connect properties to local pointers.
void copyData (const CorrectionController &aController)
void connectToModel (Model &model) override
 Model component interface that permits the controller to be "wired" up to its actuators.
void addToSystem (SimTK::MultibodySystem &system) const override
 Model component interface that creates underlying computational components in the SimTK::MultibodySystem.
void initStateFromProperties (SimTK::State &s) const override
 Transfer property values or other state-independent initial values into this component's state variables in the passed-in state argument.
- Protected Member Functions inherited from OpenSim::TrackingController
void copyData (const TrackingController &aController)
 Copy the member variables of the specified controller.
- Protected Member Functions inherited from OpenSim::Controller
void setNumControls (int numControls)
 Only a Controller can set its number of controls based on its actuators.

Protected Attributes

PropertyDbl _kpProp
 Gain for position errors.
double & _kp
PropertyDbl _kvProp
 Gain for velocity errors.
double & _kv
Storage_yDesStore
 States for the simulation.
- Protected Attributes inherited from OpenSim::TrackingController
const Storage_desiredStatesStorage
 storage object containing the desired trajectory
Array< double > * _trackingTasks

Additional Inherited Members

- Static Public Member Functions inherited from OpenSim::Object
static void registerType (const Object &defaultObject)
 Register an instance of a class; if the class is already registered it will be replaced.
static void renameType (const std::string &oldTypeName, const std::string &newTypeName)
 Support versioning by associating the current Object type with an old name.
static const ObjectgetDefaultInstanceOfType (const std::string &concreteClassName)
 Return a pointer to the default instance of the registered (concrete) Object whose class name is given, or NULL if the type is not registered.
template<class T >
static bool isObjectTypeDerivedFrom (const std::string &concreteClassName)
 Return true if the given concrete object type represents a subclass of the template object type T, and thus could be referenced with a T*.
static ObjectnewInstanceOfType (const std::string &concreteClassName)
 Create a new instance of the concrete Object type whose class name is given as concreteClassName.
static void getRegisteredTypenames (Array< std::string > &typeNames)
 Retrieve all the typenames registered so far.
template<class T >
static void getRegisteredObjectsOfGivenType (ArrayPtrs< T > &rArray)
 Return an array of pointers to the default instances of all registered (concrete) Object types that derive from a given Object-derived type that does not have to be concrete.
static void PrintPropertyInfo (std::ostream &os, const std::string &classNameDotPropertyName)
 Dump formatted property information to a given output stream, useful for creating a "help" facility for registered objects.
static void PrintPropertyInfo (std::ostream &os, const std::string &className, const std::string &propertyName)
 Same as the other signature but the class name and property name are provided as two separate strings.
static ObjectmakeObjectFromFile (const std::string &fileName)
 Create an OpenSim object whose type is based on the tag at the root node of the XML file passed in.
static const std::string & getClassName ()
 Return the name of this class as a string; i.e., "Object".
static void setSerializeAllDefaults (bool shouldSerializeDefaults)
 Static function to control whether all registered objects and their properties are written to the defaults section of output files rather than only those values for which the default was explicitly overwritten when read in from an input file or set programmatically.
static bool getSerializeAllDefaults ()
 Report the value of the "serialize all defaults" flag.
static bool isKindOf (const char *type)
 Returns true if the passed-in string is "Object"; each Object-derived class defines a method of this name for its own class name.
static void setDebugLevel (int newLevel)
 Set the debug level to get verbose output.
static int getDebugLevel ()
 Get current setting of debug level.
static ObjectSafeCopy (const Object *aObject)
 Use the clone() method to duplicate the given object unless the pointer is null in which case null is returned.
static void RegisterType (const Object &defaultObject)
 OBSOLETE alternate name for registerType().
static void RenameType (const std::string &oldName, const std::string &newName)
 OBSOLETE alternate name for renameType().
- Static Public Attributes inherited from OpenSim::Object
static const std::string DEFAULT_NAME
 Name used for default objects when they are serialized.
- Friends inherited from OpenSim::Controller

Detailed Description

This is a simple feedback controller to be used in generating a forward dynamic simulation.

Author
Chand T. John, Samuel R. Hamner, Ajay Seth
Version
1.0

Constructor & Destructor Documentation

OpenSim::CorrectionController::CorrectionController ( )
OpenSim::CorrectionController::CorrectionController ( const std::string &  aFileName,
bool  aUpdateFromXMLNode = true 
)
OpenSim::CorrectionController::CorrectionController ( const CorrectionController aController)
virtual OpenSim::CorrectionController::~CorrectionController ( )
virtual

Member Function Documentation

void OpenSim::CorrectionController::addToSystem ( SimTK::MultibodySystem &  system) const
overrideprotectedvirtual

Model component interface that creates underlying computational components in the SimTK::MultibodySystem.

This includes adding states, creating measures, etc... required by the controller.

Reimplemented from OpenSim::Controller.

virtual void OpenSim::CorrectionController::computeControls ( const SimTK::State &  s,
SimTK::Vector &  controls 
) const
virtual

Controller interface.

Implements OpenSim::TrackingController.

void OpenSim::CorrectionController::connectToModel ( Model model)
overrideprotectedvirtual

Model component interface that permits the controller to be "wired" up to its actuators.

Subclasses can override to perform additional setup.

Reimplemented from OpenSim::Controller.

void OpenSim::CorrectionController::copyData ( const CorrectionController aController)
protected
double OpenSim::CorrectionController::getKp ( ) const
double OpenSim::CorrectionController::getKv ( ) const
void OpenSim::CorrectionController::initStateFromProperties ( SimTK::State &  state) const
overrideprotectedvirtual

Transfer property values or other state-independent initial values into this component's state variables in the passed-in state argument.

This is called after a SimTK::System and State have been created for the Model (that is, after addToSystem() has been called on all components). You should override this method if your component has properties (serializable values) that can affect initial values for your state variables. You can also perform any other state-independent calculations here that result in state initial conditions.

If you override this method, be sure to invoke the base class method first, using code like this:

void MyComponent::initStateFromProperties(SimTK::State& state) const {
Super::initStateFromProperties(state); // invoke parent class method
// ... your code goes here
}
Parameters
stateThe state that will receive the new initial conditions.
See Also
setPropertiesFromState()

Reimplemented from OpenSim::ModelComponent.

CorrectionController& OpenSim::CorrectionController::operator= ( const CorrectionController aController)

Assignment operator.

This method is called automatically whenever a command of the form "controller1 = controller2;" is made, where both controller1 and controller2 are both of type Controller. Although Controller cannot be instantiated directly, a subclass of Controller could implement its own operator= method that calls Controller's operator= method. If the subclass does not implement its own operator= method, then when a command of the form "controller1 = controller2" is made, where both controller1 and controller2 are instants of the subclass, the Controller class's operator= method will be called automatically.

Parameters
aControllerThe controller to be copied.
Returns
Reference to the altered object.
void OpenSim::CorrectionController::setKp ( double  aKp)
void OpenSim::CorrectionController::setKv ( double  aKv)
void OpenSim::CorrectionController::setupProperties ( )
protectedvirtual

Connect properties to local pointers.

Reimplemented from OpenSim::TrackingController.

Member Data Documentation

double& OpenSim::CorrectionController::_kp
protected
PropertyDbl OpenSim::CorrectionController::_kpProp
protected

Gain for position errors.

This property can be specified in a setup file.

double& OpenSim::CorrectionController::_kv
protected
PropertyDbl OpenSim::CorrectionController::_kvProp
protected

Gain for velocity errors.

This property can be specified in a setup file.

Storage* OpenSim::CorrectionController::_yDesStore
protected

States for the simulation.


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