RcsPySim
A robot control and simulation library
Rcs::OMPartial Class Reference

#include <OMPartial.h>

Inheritance diagram for Rcs::OMPartial:
Collaboration diagram for Rcs::OMPartial:

Public Types

typedef std::vector< unsigned int > IndexList
 

Public Member Functions

 OMPartial (ObservationModel *wrapped, IndexList indices, bool exclude=false)
 
 OMPartial (ObservationModel *wrapped, IndexList stateIndices, IndexList velocityIndices, bool exclude=false)
 
virtual ~OMPartial ()
 
 OMPartial (const OMPartial &)=delete
 
OMPartialoperator= (const OMPartial &)=delete
 
 OMPartial (OMPartial &&)=delete
 
OMPartialoperator= (OMPartial &&)=delete
 
virtual unsigned int getStateDim () const
 
virtual unsigned int getVelocityDim () const
 
virtual void computeObservation (double *state, double *velocity, const MatNd *currentAction, double dt) const
 
virtual void getLimits (double *minState, double *maxState, double *maxVelocity) const
 
virtual std::vector< std::string > getStateNames () const
 
virtual std::vector< std::string > getVelocityNames () const
 
virtual void reset ()
 
virtual std::vector< ObservationModel * > getNested () const
 
- Public Member Functions inherited from Rcs::ObservationModel
virtual ~ObservationModel ()
 
MatNd * computeObservation (const MatNd *currentAction, double dt) const
 
void computeObservation (MatNd *observation, const MatNd *currentAction, double dt) 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 ()
 
- 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
 

Static Public Member Functions

static OMPartialfromMask (ObservationModel *wrapped, const std::vector< bool > &mask, bool exclude=false)
 
static OMPartialfromMask (ObservationModel *wrapped, const std::vector< bool > &stateMask, const std::vector< bool > &velocityMask, bool exclude=false)
 
static OMPartialfromNames (ObservationModel *wrapped, const std::vector< std::string > &names, bool exclude=false, bool autoSelectVelocity=false)
 

Private Attributes

ObservationModelwrapped
 
IndexList keptStateIndices
 
IndexList keptVelocityIndices
 

Detailed Description

Applies partial observability by masking out certain state variables.

Definition at line 42 of file OMPartial.h.

Member Typedef Documentation

◆ IndexList

typedef std::vector<unsigned int> Rcs::OMPartial::IndexList

Definition at line 45 of file OMPartial.h.

Constructor & Destructor Documentation

◆ OMPartial() [1/4]

Rcs::OMPartial::OMPartial ( ObservationModel wrapped,
IndexList  indices,
bool  exclude = false 
)

Create a partial observation model using only the specified indices.

Parameters
wrappedwrapped observation model. takes ownership.
indicesselected indices. Applied to both state and velocity, assuming their dimensions are equal.
excludeset to true to invert the mask and keep only observations not in indices.

Definition at line 92 of file OMPartial.cpp.

◆ OMPartial() [2/4]

Rcs::OMPartial::OMPartial ( ObservationModel wrapped,
IndexList  stateIndices,
IndexList  velocityIndices,
bool  exclude = false 
)

Create a partial observation model using only the specified indices.

Parameters
wrappedwrapped observation model. takes ownership.
stateIndicesselected indices for state.
velocityIndicesselected indices for velocity.
excludeset to true to invert the mask and keep only observations not in indices.

Definition at line 109 of file OMPartial.cpp.

◆ ~OMPartial()

Rcs::OMPartial::~OMPartial ( )
virtual

Definition at line 174 of file OMPartial.cpp.

◆ OMPartial() [3/4]

Rcs::OMPartial::OMPartial ( const OMPartial )
delete

◆ OMPartial() [4/4]

Rcs::OMPartial::OMPartial ( OMPartial &&  )
delete

Member Function Documentation

◆ computeObservation()

void Rcs::OMPartial::computeObservation ( double *  state,
double *  velocity,
const MatNd *  currentAction,
double  dt 
) const
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

Implements Rcs::ObservationModel.

Definition at line 199 of file OMPartial.cpp.

◆ fromMask() [1/2]

OMPartial * Rcs::OMPartial::fromMask ( ObservationModel wrapped,
const std::vector< bool > &  mask,
bool  exclude = false 
)
static

Create a partial observation model using a boolean mask. The mask is applied to both state and velocity, assuming their dimensions are equal.

Parameters
wrappedwrapped observation model. takes ownership.
masktrue entries will be kept.
excludeset to true to invert the mask

Definition at line 116 of file OMPartial.cpp.

◆ fromMask() [2/2]

OMPartial * Rcs::OMPartial::fromMask ( ObservationModel wrapped,
const std::vector< bool > &  stateMask,
const std::vector< bool > &  velocityMask,
bool  exclude = false 
)
static

Create a partial observation model using a boolean mask.

Parameters
wrappedwrapped observation model. takes ownership.
stateMaskmask for state. Length must match wrapped->getStateDim().
velocityMaskmask for velocity. Length must match wrapped->getVelocityDim().
excludeset to true to invert the mask

Definition at line 124 of file OMPartial.cpp.

◆ fromNames()

OMPartial * Rcs::OMPartial::fromNames ( ObservationModel wrapped,
const std::vector< std::string > &  names,
bool  exclude = false,
bool  autoSelectVelocity = false 
)
static

Create a partial observation model using a boolean mask.

Parameters
wrappedwrapped observation model. takes ownership.
namesselected entry names
excludeset to true to invert the mask
autoSelectVelocityset to true to automatically exclude the velocity corresponding to a state name

Definition at line 133 of file OMPartial.cpp.

◆ getLimits()

void Rcs::OMPartial::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 from Rcs::ObservationModel.

Definition at line 220 of file OMPartial.cpp.

◆ getNested()

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

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

Reimplemented from Rcs::ObservationModel.

Definition at line 267 of file OMPartial.cpp.

◆ getStateDim()

unsigned int Rcs::OMPartial::getStateDim ( ) const
virtual

The number of state variables.

Implements Rcs::ObservationModel.

Definition at line 189 of file OMPartial.cpp.

◆ getStateNames()

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

Provides names for each state entry.

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

Reimplemented from Rcs::ObservationModel.

Definition at line 246 of file OMPartial.cpp.

◆ getVelocityDim()

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

The number of velocity variables. The default implementation assumes that for each state there is a velocity.

Reimplemented from Rcs::ObservationModel.

Definition at line 194 of file OMPartial.cpp.

◆ getVelocityNames()

std::vector< std::string > Rcs::OMPartial::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 from Rcs::ObservationModel.

Definition at line 254 of file OMPartial.cpp.

◆ operator=() [1/2]

OMPartial& Rcs::OMPartial::operator= ( OMPartial &&  )
delete

◆ operator=() [2/2]

OMPartial& Rcs::OMPartial::operator= ( const OMPartial )
delete

◆ reset()

void Rcs::OMPartial::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 from Rcs::ObservationModel.

Definition at line 262 of file OMPartial.cpp.

Member Data Documentation

◆ keptStateIndices

IndexList Rcs::OMPartial::keptStateIndices
private

Definition at line 126 of file OMPartial.h.

◆ keptVelocityIndices

IndexList Rcs::OMPartial::keptVelocityIndices
private

Definition at line 127 of file OMPartial.h.

◆ wrapped

ObservationModel* Rcs::OMPartial::wrapped
private

Definition at line 123 of file OMPartial.h.


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