iLab Neuromorphic Robotics Toolkit
0.1
|
#include <nrt/Probabilistic/Types/StateDef.H>
A Simple class to represent possibly complex and nested state information with dual access.
The goal of this class is not to store data but rather to provide easy, intuitive, hierarchical named access to data stored in an Eigen vector. The StateDef class thus does not provide storage but only convenience access. This class assumes that you have defined some datatypes whose internal data members are reference to double, such as:
The constructor from double[] and the size static data member are required. Once you have this, you can use StateDef to build hierarchical structures of these datatypes and to access their leaf data elements naturally:
And of course the data remains accessible as an Eigen vector for vector/matrix operations on it. You can compose State elements, for example:
Definition at line 117 of file StateDef.H.
Inherits nrt::StateAccessor< Elements >.
Public Types | |
typedef Eigen::Matrix< double, StateAccessor< Elements...> ::size, 1 > | datatype |
The datatype this particular StateDef instance should be attached to. | |
Public Member Functions | |
StateDef (datatype &data) | |
Construct by attaching to an already allocated Eigen vector. | |
StateDef (double data[]) | |
Construct by attaching to an already allocated raw C vector. More... | |
size_t const | indexof (double &addr) |
Get the index of a particular leaf element. More... | |
double & | operator[] (size_t const idx) |
Get an element by index, non-const version. | |
double const & | operator[] (size_t const idx) const |
Get an element by index, const version. | |
|
inline |
Construct by attaching to an already allocated raw C vector.
Users should normally not use this constructor but it is used by nested StateDef elements.
Definition at line 91 of file StateDefImpl.H.
|
inline |
Get the index of a particular leaf element.
Leaf elements are of type double &, and can be retrieved using the get() functions of StateAccessor.
Definition at line 96 of file StateDefImpl.H.