opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
opyn::Model Class Referencefinal

#include <model.h>

Public Member Functions

ModelState initial_state (ModelStateStage realized_to=ModelStateStage::instance) const
 
std::unordered_set< std::string > rotational_columns_in (const DataFrame &data_frame) const
 
std::unordered_map< std::string, Symbolcolumn_to_state_variable_mappings (const DataFrame &data_frame) const
 
DataFrame convert_data_frame_to_radians (const DataFrame &data_frame) const
 
ModelStates states_from_data_frame (const DataFrame &data_frame, ModelStateStage realized_to=ModelStateStage::instance) const
 
void realize (ModelState &model_state, ModelStateStage model_state_stage) const
 Realizes model_state to the given model_state_stage.
 
size_t num_coordinates () const
 Returns the number of coordinates in the model.
 
std::vector< Symbolcoordinates () const
 Returns all coordinates in the model.
 
double get_coordinate_value (const ModelState &model_state, const Symbol &coordinate) const
 Returns the value of coordinate in model_state.
 
void set_coordinate_value (ModelState &model_state, const Symbol &coordinate, double value) const
 Sets the value of coordinate in model_state to value.
 
double get_coordinate_speed (const ModelState &model_state, const Symbol &coordinate) const
 Returns the speed of coordinate in model_state.
 
void set_coordinate_speed (ModelState &model_state, const Symbol &coordinate, double speed) const
 Sets the speed of coordinate in model_state to speed.
 
bool is_coordinate_locked (const ModelState &model_state, const Symbol &coordinate) const
 Returns true if coordinate is locked in model_state.
 
void set_coordinate_locked (ModelState &model_state, const Symbol &coordinate, bool locked=true) const
 Sets the locked state of coordinate in model_state to locked.
 
bool is_coordinate_rotational (const Symbol &coordinate) const
 Returns true if coordinate has a rotational (i.e. not translational or coupled).
 
size_t num_outputs () const
 Returns the number of outputs in the model.
 
std::vector< Symboloutputs () const
 Returns all outputs in the model.
 
OutputValue get_output_value (const ModelState &model_state, const Symbol &output) const
 Returns the value of output in model_state.
 
std::vector< osc::SceneDecorationdecorations (osc::SceneCache &, const ModelState &model_state, const OpenSimDecorationOptions &={}) const
 Returns scene decorations that visually represent *this in model_state.
 
const OpenSim::Model & open_sim_model () const
 Returns the underlying OpenSim::Model (internal method: be careful with this).
 

Friends

class ModelSpecification
 

Detailed Description

Represents a readonly multibody physics system compiled from a ModelSpecification.

Member Function Documentation

◆ column_to_state_variable_mappings()

std::unordered_map< std::string, Symbol > opyn::Model::column_to_state_variable_mappings ( const DataFrame data_frame) const

Returns associative mappings between the names of columns in data_frame and state variables in this Model, where the correspondence can be found.

◆ convert_data_frame_to_radians()

DataFrame opyn::Model::convert_data_frame_to_radians ( const DataFrame data_frame) const

Returns a new DataFrame that's the result of converting rotational columns in data_frame to radians (if applicable).

Behavior:

  • If data_frame.attrs()["inDegrees"] != "yes", returns a copy of data_frame as-is.
  • Otherwise, copies data_frame and uses this->rotational_columns_in(copy) to figure out which columns in are rotational, followed by scaling the entire column to radians. The "inDegrees" key is cleared from the returned copy.

◆ coordinates()

std::vector< Symbol > opyn::Model::coordinates ( ) const

Returns all coordinates in the model.

◆ decorations()

std::vector< osc::SceneDecoration > opyn::Model::decorations ( osc::SceneCache ,
const ModelState model_state,
const OpenSimDecorationOptions = {} 
) const

Returns scene decorations that visually represent *this in model_state.

◆ get_coordinate_speed()

double opyn::Model::get_coordinate_speed ( const ModelState model_state,
const Symbol coordinate 
) const

Returns the speed of coordinate in model_state.

◆ get_coordinate_value()

double opyn::Model::get_coordinate_value ( const ModelState model_state,
const Symbol coordinate 
) const

Returns the value of coordinate in model_state.

◆ get_output_value()

OutputValue opyn::Model::get_output_value ( const ModelState model_state,
const Symbol output 
) const

Returns the value of output in model_state.

◆ initial_state()

ModelState opyn::Model::initial_state ( ModelStateStage  realized_to = ModelStateStage::instance) const

Returns the initial (default) state of this model, which is the state that was defined by the ModelSpecification used to build this model.

The realized_to argument ensures the returned ModelState is realized as-if by calling this->realize(returned_state, realized_to).

◆ is_coordinate_locked()

bool opyn::Model::is_coordinate_locked ( const ModelState model_state,
const Symbol coordinate 
) const

Returns true if coordinate is locked in model_state.

◆ is_coordinate_rotational()

bool opyn::Model::is_coordinate_rotational ( const Symbol coordinate) const

Returns true if coordinate has a rotational (i.e. not translational or coupled).

◆ num_coordinates()

size_t opyn::Model::num_coordinates ( ) const

Returns the number of coordinates in the model.

◆ num_outputs()

size_t opyn::Model::num_outputs ( ) const

Returns the number of outputs in the model.

◆ open_sim_model()

const OpenSim::Model & opyn::Model::open_sim_model ( ) const

Returns the underlying OpenSim::Model (internal method: be careful with this).

◆ outputs()

std::vector< Symbol > opyn::Model::outputs ( ) const

Returns all outputs in the model.

◆ realize()

void opyn::Model::realize ( ModelState model_state,
ModelStateStage  model_state_stage 
) const

Realizes model_state to the given model_state_stage.

◆ rotational_columns_in()

std::unordered_set< std::string > opyn::Model::rotational_columns_in ( const DataFrame data_frame) const

Returns a set of the names of the columns in data_frame that can be mapped to rotational state variables in this Model.

◆ set_coordinate_locked()

void opyn::Model::set_coordinate_locked ( ModelState model_state,
const Symbol coordinate,
bool  locked = true 
) const

Sets the locked state of coordinate in model_state to locked.

◆ set_coordinate_speed()

void opyn::Model::set_coordinate_speed ( ModelState model_state,
const Symbol coordinate,
double  speed 
) const

Sets the speed of coordinate in model_state to speed.

◆ set_coordinate_value()

void opyn::Model::set_coordinate_value ( ModelState model_state,
const Symbol coordinate,
double  value 
) const

Sets the value of coordinate in model_state to value.

◆ states_from_data_frame()

ModelStates opyn::Model::states_from_data_frame ( const DataFrame data_frame,
ModelStateStage  realized_to = ModelStateStage::instance 
) const

Returns ModelStates constructed from data_frame.

Columns in data_frame will be mapped to state variables in this Model (see: column_to_state_variable_mappings). Each row in data_frame constructs one state in the returned ModelStates, in row-order.

If data_frame.attrs()["inDegrees"] == "yes" then rotational columns in data_frame will be automatically converted into radians internally (see: rotational_columns_in). This is to support DataFrames loaded from legacy data sources.

The realized_to argument ensures each returned ModelStates is realized as-if by calling this->realize(returned_states[i], realized_to).

Friends And Related Symbol Documentation

◆ ModelSpecification

friend class ModelSpecification
friend

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