RcsPySim
A robot control and simulation library
Rcs::ObservationModel Class Referenceabstract

#include <ObservationModel.h>

Inheritance diagram for Rcs::ObservationModel:
Collaboration diagram for Rcs::ObservationModel:

Classes

struct  Offsets
 

Public Member Functions

virtual ~ObservationModel ()
 
MatNd * computeObservation (const MatNd *currentAction, double dt) const
 
void computeObservation (MatNd *observation, const MatNd *currentAction, double dt) const
 
virtual unsigned int getStateDim () const =0
 
virtual unsigned int getVelocityDim () const
 
virtual void computeObservation (double *state, double *velocity, const MatNd *currentAction, double dt) const =0
 
virtual void getLimits (double *minState, double *maxState, double *maxVelocity) const
 
virtual void reset ()
 
virtual std::vector< std::string > getStateNames () const
 
virtual std::vector< std::string > getVelocityNames () const
 
virtual void getMinMax (double *min, double *max) const final
 
virtual unsigned int getDim () const final
 
virtual std::vector< std::string > getNames () const final
 
template<typename OM >
OM * findModel ()
 
template<typename OM >
Offsets findOffsets ()
 
virtual std::vector< ObservationModel * > getNested () const
 
- Public Member Functions inherited from Rcs::BoxSpaceProvider
 BoxSpaceProvider ()
 
virtual ~BoxSpaceProvider ()
 
 BoxSpaceProvider (const BoxSpaceProvider &)=delete
 
BoxSpaceProvideroperator= (const BoxSpaceProvider &)=delete
 
 BoxSpaceProvider (BoxSpaceProvider &&)=delete
 
BoxSpaceProvideroperator= (BoxSpaceProvider &&)=delete
 
const BoxSpacegetSpace () const
 

Detailed Description

The ObservationModel encapsulates the computation of the state vector from the current graph state.

Definition at line 45 of file ObservationModel.h.

Constructor & Destructor Documentation

◆ ~ObservationModel()

Rcs::ObservationModel::~ObservationModel ( )
virtualdefault

Member Function Documentation

◆ computeObservation() [1/3]

MatNd * Rcs::ObservationModel::computeObservation ( const MatNd *  currentAction,
double  dt 
) const

Create a MatNd for the observation vector, fill it using computeObservation and return it. The caller must take ownership of the returned matrix.

Parameters
[in]currentActionaction in current step. May be NULL if not available.
[in]dttime step since the last observation has been taken
Returns
a new observation vector

Definition at line 45 of file ObservationModel.cpp.

◆ computeObservation() [2/3]

void Rcs::ObservationModel::computeObservation ( MatNd *  observation,
const MatNd *  currentAction,
double  dt 
) const

Fill the given matrix with observation data.

Parameters
[out]observationobservation output vector
[in]currentActionaction in current step. May be NULL if not available.
[in]dttime step since the last observation has been taken

Definition at line 52 of file ObservationModel.cpp.

◆ computeObservation() [3/3]

virtual void Rcs::ObservationModel::computeObservation ( double *  state,
double *  velocity,
const MatNd *  currentAction,
double  dt 
) const
pure virtual

Implement to fill the observation vector with the observed values.

Parameters
[out]statestate observation vector to fill, has getStateDim() elements.
[out]velocityvelocity observation vector to fill, has getVelocityDim() elements.
[in]currentActionaction in current step. May be NULL if not available.
[in]dttime step since the last observation has been taken

Implemented in Rcs::OMPartial, Rcs::OMJointState, Rcs::OMNormalized, Rcs::OMTaskSpaceDiscrepancy, Rcs::OMForceTorque, Rcs::OMManipulabilityIndex, Rcs::OMDynamicalSystemGoalDistance, Rcs::OMCombined, Rcs::OMDynamicalSystemDiscrepancy, Rcs::OMTaskPositions, Rcs::OMTask, Rcs::OMBallPos, Rcs::OMCollisionCostPrediction, Rcs::OMComputedVelocity, and Rcs::OMCollisionCost.

◆ findModel()

template<typename OM >
OM* Rcs::ObservationModel::findModel ( )
inline

Find a nested observation model of a specified type. If multiple observation models match, the first found in depth-first search order is returned.

Template Parameters
OMobservation model type to find
Returns
nested observation model or NULL if not found.

Definition at line 145 of file ObservationModel.h.

◆ findOffsets()

template<typename OM >
Offsets Rcs::ObservationModel::findOffsets ( )
inline

Find a nested observation model of a specified type. If multiple observation models match, the first found in depth-first search order is returned. NOTE: the positions and velovities are done separately. In order to correct for masked state observations use observationModel->getStateDim() + thisOM.vel + i to get the index.

Template Parameters
OMobservation model type to find
Returns
nested observation model or NULL if not found.

Definition at line 181 of file ObservationModel.h.

◆ getDim()

unsigned int Rcs::ObservationModel::getDim ( ) const
finalvirtual

The number of observed variables is twice the number of state variables. Delegates to getStateDim.

Implements Rcs::BoxSpaceProvider.

Definition at line 110 of file ObservationModel.cpp.

◆ getLimits()

void Rcs::ObservationModel::getLimits ( double *  minState,
double *  maxState,
double *  maxVelocity 
) const
virtual

Provides the minimum and maximum observable values. Since the velocity is symmetric, only the maximum needs to be provided. The default implementation uses -inf and inf.

Parameters
[out]minStateminimum state vector to fill, has getStateDim() elements.
[out]maxStatemaximum state vector to fill, has getStateDim() elements.
[out]maxVelocitymaximum velocity vector to fill, has getVelocityDim() elements.

Reimplemented in Rcs::OMPartial, Rcs::OMJointState, Rcs::OMNormalized, Rcs::OMForceTorque, Rcs::OMTaskSpaceDiscrepancy, Rcs::OMDynamicalSystemGoalDistance, Rcs::OMCombined, Rcs::OMTaskPositions, Rcs::OMTask, Rcs::OMCollisionCostPrediction, and Rcs::OMCollisionCost.

Definition at line 70 of file ObservationModel.cpp.

◆ getMinMax()

void Rcs::ObservationModel::getMinMax ( double *  min,
double *  max 
) const
finalvirtual

Provides the minimum and maximum observable values. Delegates to getLimits.

Implements Rcs::BoxSpaceProvider.

Definition at line 116 of file ObservationModel.cpp.

◆ getNames()

std::vector< std::string > Rcs::ObservationModel::getNames ( ) const
finalvirtual

The velocity names are the state names postfixed with 'd'. Delegates to getStateNames.

Reimplemented from Rcs::BoxSpaceProvider.

Definition at line 129 of file ObservationModel.cpp.

◆ getNested()

std::vector< ObservationModel * > Rcs::ObservationModel::getNested ( ) const
virtual

List directly nested observation models. The default implementation returns an empty list, since there are no nested models.

Reimplemented in Rcs::OMPartial, Rcs::OMNormalized, and Rcs::OMCombined.

Definition at line 138 of file ObservationModel.cpp.

◆ getStateDim()

◆ getStateNames()

std::vector< std::string > Rcs::ObservationModel::getStateNames ( ) const
virtual

◆ getVelocityDim()

unsigned int Rcs::ObservationModel::getVelocityDim ( ) const
virtual

◆ getVelocityNames()

std::vector< std::string > Rcs::ObservationModel::getVelocityNames ( ) const
virtual

Provides names for each velocity entry. The default implementation derives the names from getStateNames(), appending a 'd' to each name.

Returns
a vector of name strings. Must be of length getVelocityDim() or empty for a nameless space.

Reimplemented in Rcs::OMPartial, Rcs::OMNormalized, and Rcs::OMCombined.

Definition at line 92 of file ObservationModel.cpp.

◆ reset()

void Rcs::ObservationModel::reset ( )
virtual

Reset any internal state. This is called to begin a new episode. It should also reset values depending on modifiable physics parameters. This is an optional operation, so the default implementation does nothing.

Reimplemented in Rcs::OMPartial, Rcs::OMNormalized, Rcs::OMTaskSpaceDiscrepancy, Rcs::OMCombined, Rcs::OMDynamicalSystemDiscrepancy, Rcs::OMBallPos, and Rcs::OMComputedVelocity.

Definition at line 58 of file ObservationModel.cpp.


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