OpenSim  OpenSim 3.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
OpenSim::Controller Class Referenceabstract

Controller is an abstract ModelComponent that defines the interface for an OpenSim Controller. More...

#include <Controller.h>

Inheritance diagram for OpenSim::Controller:
OpenSim::ModelComponent OpenSim::Object OpenSim::ControlSetController OpenSim::PrescribedController OpenSim::ToyReflexController OpenSim::TrackingController OpenSim::CMC OpenSim::CorrectionController

Property declarations

These are the serializable properties associated with a Controller.

class ControllerSet
 
 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. More...
 
bool isDisabled () const
 Get whether or not this controller is disabled. More...
 
void setDisabled (bool disableFlag)
 Disable this controller. More...
 
void setActuators (const Set< Actuator > &actuators)
 replace the current set of actuators with the provided set More...
 
void addActuator (const Actuator &actuator)
 add to the current set of actuators More...
 
const Set< Actuator > & getActuatorSet () const
 get a const reference to the current set of actuators More...
 
Set< Actuator > & updActuators ()
 get a writable reference to the set of actuators for this controller More...
 
virtual void computeControls (const SimTK::State &s, SimTK::Vector &controls) const =0
 Compute the control for actuator This method defines the behavior for any concrete controller and therefore must be implemented by concrete subclasses. More...
 
int getNumControls () const
 
void connectToModel (Model &model) override
 Model component interface that permits the controller to be "wired" up to its actuators. More...
 
void addToSystem (SimTK::MultibodySystem &system) const override
 Model component interface that creates underlying computational components in the SimTK::MultibodySystem. More...
 
void setNumControls (int numControls)
 Only a Controller can set its number of controls based on its actuators. More...
 

Additional Inherited Members

- Public Member Functions inherited from OpenSim::ModelComponent
 ModelComponent ()
 Default constructor. More...
 
 ModelComponent (const std::string &aFileName, bool aUpdateFromXMLNode=true) SWIG_DECLARE_EXCEPTION
 Construct ModelComponent from an XML file. More...
 
 ModelComponent (SimTK::Xml::Element &aNode)
 Construct ModelComponent from a specific node in an XML document. More...
 
 ModelComponent (const ModelComponent &source)
 Construct ModelComponent with its contents copied from another ModelComponent; this is a deep copy so nothing is shared with the source after the copy. More...
 
virtual ~ModelComponent ()
 Destructor is virtual to allow concrete model component cleanup. More...
 
ModelComponentoperator= (const ModelComponent &aModelComponent)
 Assignment operator to copy contents of an existing component. More...
 
const ModelgetModel () const
 Get a const reference to the Model this component is part of. More...
 
ModelupdModel ()
 Get a modifiable reference to the Model this component is part of. More...
 
virtual void updateDisplayer (const SimTK::State &s) const
 In case the ModelComponent has a visual representation (VisualObject), override this method to update it. More...
 
virtual int getNumStateVariables () const
 Get the number of "Continuous" state variables maintained by the ModelComponent and its specified subcomponents. More...
 
virtual Array< std::string > getStateVariableNames () const
 Get the names of "continuous" state variables maintained by the ModelComponent and its subcomponents. More...
 
virtual SimTK::SystemYIndex getStateVariableSystemIndex (const std::string &stateVariableName) const
 Get the System Index of a state variable allocated by this ModelComponent. More...
 
int getModelingOption (const SimTK::State &state, const std::string &name) const
 Get a ModelingOption flag for this ModelComponent by name. More...
 
void setModelingOption (SimTK::State &state, const std::string &name, int flag) const
 Set the value of a ModelingOption flag for this ModelComponent. More...
 
double getStateVariable (const SimTK::State &state, const std::string &name) const
 Get the value of a state variable allocated by this ModelComponent. More...
 
void setStateVariable (SimTK::State &state, const std::string &name, double value) const
 Set the value of a state variable allocated by this ModelComponent by name. More...
 
double getDiscreteVariable (const SimTK::State &state, const std::string &name) const
 Get the value of a discrete variable allocated by this ModelComponent by name. More...
 
void setDiscreteVariable (SimTK::State &state, const std::string &name, double value) const
 Set the value of a discrete variable allocated by this ModelComponent by name. More...
 
template<typename T >
const T & getCacheVariable (const SimTK::State &state, const std::string &name) const
 Get the value of a cache variable allocated by this ModelComponent by name. More...
 
template<typename T >
T & updCacheVariable (const SimTK::State &state, const std::string &name) const
 Obtain a writable cache variable value allocated by this ModelComponent by name. More...
 
void markCacheVariableValid (const SimTK::State &state, const std::string &name) const
 After updating a cache variable value allocated by this ModelComponent, you can mark its value as valid, which will not change until the realization stage falls below the minimum set at the time the cache variable was created. More...
 
void markCacheVariableInvalid (const SimTK::State &state, const std::string &name) const
 Mark a cache variable value allocated by this ModelComponent as invalid. More...
 
bool isCacheVariableValid (const SimTK::State &state, const std::string &name) const
 Enables the to monitor the validity of the cache variable value using the returned flag. More...
 
template<typename T >
void setCacheVariable (const SimTK::State &state, const std::string &name, const T &value) const
 Set cache variable value allocated by this ModelComponent by name. More...
 
- 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. More...
 
static void renameType (const std::string &oldTypeName, const std::string &newTypeName)
 Support versioning by associating the current Object type with an old name. More...
 
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. More...
 
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*. More...
 
static ObjectnewInstanceOfType (const std::string &concreteClassName)
 Create a new instance of the concrete Object type whose class name is given as concreteClassName. More...
 
static void getRegisteredTypenames (Array< std::string > &typeNames)
 Retrieve all the typenames registered so far. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
static const std::string & getClassName ()
 Return the name of this class as a string; i.e., "Object". More...
 
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. More...
 
static bool getSerializeAllDefaults ()
 Report the value of the "serialize all defaults" flag. More...
 
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. More...
 
static void setDebugLevel (int newLevel)
 Set the debug level to get verbose output. More...
 
static int getDebugLevel ()
 Get current setting of debug level. More...
 
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. More...
 
static void RegisterType (const Object &defaultObject)
 OBSOLETE alternate name for registerType(). More...
 
static void RenameType (const std::string &oldName, const std::string &newName)
 OBSOLETE alternate name for renameType(). More...
 
- Static Public Attributes inherited from OpenSim::Object
static const std::string DEFAULT_NAME
 Name used for default objects when they are serialized. More...
 
- Protected Member Functions inherited from OpenSim::ModelComponent
virtual void initStateFromProperties (SimTK::State &state) const
 Transfer property values or other state-independent initial values into this component's state variables in the passed-in state argument. More...
 
virtual void setPropertiesFromState (const SimTK::State &state)
 Update this component's property values to match the specified State, if the component has created any state variable that is intended to correspond to a property. More...
 
virtual SimTK::Vector computeStateVariableDerivatives (const SimTK::State &s) const
 If a model component has allocated any continuous state variables using the addStateVariable() method, then computeStateVariableDerivatives() must be implemented to provide time derivatives for those states. More...
 
virtual void generateDecorations (bool fixed, const ModelDisplayHints &hints, const SimTK::State &state, SimTK::Array_< SimTK::DecorativeGeometry > &appendToThis) const
 Optional method for generating arbitrary display geometry that reflects this ModelComponent at the specified state. More...
 
virtual void realizeTopology (SimTK::State &state) const
 Obtain state resources that are needed unconditionally, and perform computations that depend only on the system topology. More...
 
virtual void realizeModel (SimTK::State &state) const
 Obtain state resources that may be needed, depending on modeling options, and perform computations that depend only on topology and selected modeling options. More...
 
virtual void realizeInstance (const SimTK::State &state) const
 Perform computations that depend only on instance variables, like lengths and masses. More...
 
virtual void realizeTime (const SimTK::State &state) const
 Perform computations that depend only on time and earlier stages. More...
 
virtual void realizePosition (const SimTK::State &state) const
 Perform computations that depend only on position-level state variables and computations performed in earlier stages (including time). More...
 
virtual void realizeVelocity (const SimTK::State &state) const
 Perform computations that depend only on velocity-level state variables and computations performed in earlier stages (including position, and time). More...
 
virtual void realizeDynamics (const SimTK::State &state) const
 Perform computations (typically forces) that may depend on dynamics-stage state variables, and on computations performed in earlier stages (including velocity, position, and time), but not on other forces, accelerations, constraint multipliers, or reaction forces. More...
 
virtual void realizeAcceleration (const SimTK::State &state) const
 Perform computations that may depend on applied forces. More...
 
virtual void realizeReport (const SimTK::State &state) const
 Perform computations that may depend on anything but are only used for reporting and cannot affect subsequent simulation behavior. More...
 
void includeAsSubComponent (ModelComponent *aComponent)
 Include another ModelComponent as a Subcomponent of this ModelComponent. More...
 
void addModelingOption (const std::string &optionName, int maxFlagValue) const
 Add a modeling option (integer flag stored in the State) for use by this ModelComponent. More...
 
void addStateVariable (const std::string &stateVariableName, SimTK::Stage invalidatesStage=SimTK::Stage::Dynamics) const
 Add a continuous system state variable belonging to this ModelComponent, and assign a name by which to refer to it. More...
 
void addDiscreteVariable (const std::string &discreteVariableName, SimTK::Stage invalidatesStage) const
 Add a system discrete variable belonging to this ModelComponent, give it a name by which it can be referenced, and declare the lowest Stage that should be invalidated if this variable's value is changed. More...
 
template<class T >
void addCacheVariable (const std::string &cacheVariableName, const T &variablePrototype, SimTK::Stage dependsOnStage) const
 Add a state cache entry belonging to this ModelComponent to hold calculated values that must be automatically invalidated when certain state values change. More...
 
const int getStateIndex (const std::string &name) const
 Get the index of a ModelComponent's continuous state variable in the Subsystem for allocations. More...
 
const SimTK::DiscreteVariableIndex getDiscreteVariableIndex (const std::string &name) const
 Get the index of a ModelComponent's discrete variable in the Subsystem for allocations. More...
 
const SimTK::CacheEntryIndex getCacheVariableIndex (const std::string &name) const
 Get the index of a ModelComponent's cache variable in the Subsystem for allocations. More...
 
- Protected Attributes inherited from OpenSim::ModelComponent
Model_model
 The model this component belongs to. More...
 

Detailed Description

Controller is an abstract ModelComponent that defines the interface for an OpenSim Controller.

A controller computes and sets the values of the controls for the actuators under its control. The defining method of a Controller is its computeControls() method.

See Also
computeControls()
Author
Ajay Seth

Constructor & Destructor Documentation

OpenSim::Controller::Controller ( )

Default constructor.

Member Function Documentation

void OpenSim::Controller::addActuator ( const Actuator actuator)

add to the current set of actuators

void OpenSim::Controller::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::ModelComponent.

Reimplemented in OpenSim::CMC, OpenSim::CorrectionController, and OpenSim::ControlSetController.

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

Compute the control for actuator This method defines the behavior for any concrete controller and therefore must be implemented by concrete subclasses.

Parameters
ssystem state
controlswritable model controls (all actuators)

Implemented in OpenSim::CMC, OpenSim::TrackingController, OpenSim::ControlSetController, OpenSim::CorrectionController, OpenSim::PrescribedController, and OpenSim::ToyReflexController.

void OpenSim::Controller::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::ModelComponent.

Reimplemented in OpenSim::CMC, OpenSim::CorrectionController, OpenSim::PrescribedController, and OpenSim::ControlSetController.

const Set<Actuator>& OpenSim::Controller::getActuatorSet ( ) const

get a const reference to the current set of actuators

int OpenSim::Controller::getNumControls ( ) const
inline
bool OpenSim::Controller::isDisabled ( ) const

Get whether or not this controller is disabled.

Returns
true when controller is disabled.
OpenSim::Controller::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"   
)
OpenSim::Controller::OpenSim_DECLARE_PROPERTY ( isDisabled  ,
bool  ,
"Flag (true or false) indicating whether or not the controller is disabled."   
)
void OpenSim::Controller::setActuators ( const Set< Actuator > &  actuators)

replace the current set of actuators with the provided set

void OpenSim::Controller::setDisabled ( bool  disableFlag)

Disable this controller.

Parameters
disableFlagDisable if true.
void OpenSim::Controller::setNumControls ( int  numControls)
inlineprotected

Only a Controller can set its number of controls based on its actuators.

Set<Actuator>& OpenSim::Controller::updActuators ( )

get a writable reference to the set of actuators for this controller

Friends And Related Function Documentation

friend class ControllerSet
friend

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