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

#include <BoxSpace.h>

Public Member Functions

 BoxSpace (MatNd *min, MatNd *max, std::vector< std::string > names={})
 
 BoxSpace (double min, double max, unsigned int m, unsigned int n=1, std::vector< std::string > names={})
 
 BoxSpace (const BoxSpace &)
 
BoxSpaceoperator= (const BoxSpace &)
 
 BoxSpace (BoxSpace &&) noexcept
 
BoxSpaceoperator= (BoxSpace &&) noexcept
 
 ~BoxSpace ()
 
bool checkDimension (const MatNd *values, std::string *msg=NULL) const
 
bool contains (const MatNd *values, std::string *msg=NULL) const
 
MatNd * createValueMatrix () const
 
void sample (MatNd *out) const
 
const MatNd * getMin () const
 
const MatNd * getMax () const
 
const std::vector< std::string > & getNames () const
 

Private Attributes

MatNd * min
 
MatNd * max
 
std::vector< std::string > names
 

Detailed Description

A box in R^n.

Each coordinate is bounded by a minimum and maximum value.

This class doesn't define any advanced operations, it solely exists to clean up the C++ interface of the implementation.

Definition at line 49 of file BoxSpace.h.

Constructor & Destructor Documentation

◆ BoxSpace() [1/4]

Rcs::BoxSpace::BoxSpace ( MatNd *  min,
MatNd *  max,
std::vector< std::string >  names = {} 
)

Create a box space from min/max value matrices. The shape of the matrices must match.

The BoxSpace object will assume ownership of the MatNds.

Parameters
minminimum values for each element.
maxmaximum values for each element.
namesvariable names for each element.

Definition at line 54 of file BoxSpace.cpp.

◆ BoxSpace() [2/4]

Rcs::BoxSpace::BoxSpace ( double  min,
double  max,
unsigned int  m,
unsigned int  n = 1,
std::vector< std::string >  names = {} 
)

Create a box space with the same min/max value for all dimensions.

Parameters
minminimum value for any element
maxmaximum value for any element
mnumber of rows in space
nnumber of columns in space
namesvariable names for each element.

Definition at line 73 of file BoxSpace.cpp.

◆ BoxSpace() [3/4]

Rcs::BoxSpace::BoxSpace ( const BoxSpace other)

Definition at line 93 of file BoxSpace.cpp.

◆ BoxSpace() [4/4]

Rcs::BoxSpace::BoxSpace ( BoxSpace &&  other)
noexcept

Definition at line 113 of file BoxSpace.cpp.

◆ ~BoxSpace()

Rcs::BoxSpace::~BoxSpace ( )

Definition at line 141 of file BoxSpace.cpp.

Member Function Documentation

◆ checkDimension()

bool Rcs::BoxSpace::checkDimension ( const MatNd *  values,
std::string *  msg = NULL 
) const

Check if the given MatNd has the right shape for this space.

The optional parameter can take an error message to report back.

Parameters
[in]valuesvalue matrix to check
[out]msgstring variable to write a message to if the values do not fit.
Returns
true if the values fit

Definition at line 147 of file BoxSpace.cpp.

◆ contains()

bool Rcs::BoxSpace::contains ( const MatNd *  values,
std::string *  msg = NULL 
) const

Check if the given MatNd has the right shape and it's values are valid.

The optional parameter can take an error message to report back.

Parameters
[in]valuesvalue matrix to check
[out]msgstring variable to write a message to if the values do not fit.
Returns
true if the values fit

Definition at line 163 of file BoxSpace.cpp.

◆ createValueMatrix()

MatNd * Rcs::BoxSpace::createValueMatrix ( ) const

Create a matrix of the right shape to fit into the space.

Returns
a MatNd of the right shape

Definition at line 197 of file BoxSpace.cpp.

◆ getMax()

const MatNd* Rcs::BoxSpace::getMax ( ) const
inline

Upper bounds for each variable.

Definition at line 137 of file BoxSpace.h.

◆ getMin()

const MatNd* Rcs::BoxSpace::getMin ( ) const
inline

Lower bounds for each variable.

Definition at line 129 of file BoxSpace.h.

◆ getNames()

const std::vector<std::string>& Rcs::BoxSpace::getNames ( ) const
inline

Names for each variable.

These are intended for use in python, i.e., for pandas dataframe column names.

Definition at line 147 of file BoxSpace.h.

◆ operator=() [1/2]

BoxSpace & Rcs::BoxSpace::operator= ( const BoxSpace other)

Definition at line 100 of file BoxSpace.cpp.

◆ operator=() [2/2]

BoxSpace & Rcs::BoxSpace::operator= ( BoxSpace &&  other)
noexcept

Definition at line 124 of file BoxSpace.cpp.

◆ sample()

void Rcs::BoxSpace::sample ( MatNd *  out) const

Fill the given matrix out with random values fitting into the space bounds.

Parameters
[out]outMatNd to fill. The shape must match.

Definition at line 202 of file BoxSpace.cpp.

Member Data Documentation

◆ max

MatNd* Rcs::BoxSpace::max
private

Definition at line 155 of file BoxSpace.h.

◆ min

MatNd* Rcs::BoxSpace::min
private

Definition at line 154 of file BoxSpace.h.

◆ names

std::vector<std::string> Rcs::BoxSpace::names
private

Definition at line 159 of file BoxSpace.h.


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