Module: extendedStateVector
Typedefs
-
using ExtendedStateId = std::pair<size_t, std::string>
Because two different DynamicObjects can have states with the same name, ExtendedStateId is used to give a unique identifier to every state. The first item is the index of the DynamicObject in the integrator’s dynPtrs vector. The second item in the pair is the name of the state.
-
struct ExtendedStateIdHash
- #include <extendedStateVector.h>
ExtendedStateIdHash is required to make ExtendedStateId hashable (usable as a key in a map)
Public Functions
-
inline std::size_t operator()(const ExtendedStateId &p) const
Generates a hash value (integer) from an ExtendedStateId object
-
inline std::size_t operator()(const ExtendedStateId &p) const
-
class ExtendedStateVector : public std::unordered_map<ExtendedStateId, Eigen::MatrixXd, ExtendedStateIdHash>
- #include <extendedStateVector.h>
Conceptually similar to StateVector, this class allows us to handle the states of multiple DynamicObject with a single object.
It also supports several utility functions.
Public Functions
-
ExtendedStateVector map(std::function<Eigen::MatrixXd(const size_t&, const std::string&, const Eigen::MatrixXd&)> functor) const
This method will call the given std::function for every state in the ExtendedStateVector. The arguments to the functor are the index of the DynamicObject corresponding to the state, the name of the state, and the value of the state stored in ExtendedStateVector. A new ExtendedStateVector is built from the results of each call of the functor.
-
void apply(std::function<void(const size_t&, const std::string&, const Eigen::MatrixXd&)> functor) const
Similar to the map method, except that no ExtendedStateVector is returned because the given functor does not produce any values.
-
void modify(std::function<void(const size_t&, const std::string&, Eigen::MatrixXd&)> functor)
Modifies each Eigen::MatrixXd stored in this object according to the given functor
-
ExtendedStateVector operator+=(const ExtendedStateVector &rhs)
Adds the values of
rhs
to thisThis functions as a state-wise addition operation.
-
ExtendedStateVector operator*(const double rhs) const
Returns a new ExtendedStateVector that is the result of multiplying each state by a constant
-
void setStates(std::vector<DynamicObject*> &dynPtrs) const
Calls StateData::setState for every entry in in this
Public Static Functions
-
static ExtendedStateVector fromStates(const std::vector<DynamicObject*> &dynPtrs)
Builds a ExtendedStateVector from all states in the given dynamic objects
-
static ExtendedStateVector fromStateDerivs(const std::vector<DynamicObject*> &dynPtrs)
Builds a ExtendedStateVector from the derivatives of all states in the given dynamic objects
Private Static Functions
-
static ExtendedStateVector fromStateData(const std::vector<DynamicObject*> &dynPtrs, std::function<Eigen::MatrixXd(const StateData&)>)
-
ExtendedStateVector map(std::function<Eigen::MatrixXd(const size_t&, const std::string&, const Eigen::MatrixXd&)> functor) const