aikido
Rn.hpp
1 #ifndef AIKIDO_STATESPACE_REALVECTORSTATESPACE_HPP_
2 #define AIKIDO_STATESPACE_REALVECTORSTATESPACE_HPP_
3 #include <Eigen/Core>
4 
5 #include "aikido/statespace/ScopedState.hpp"
6 #include "aikido/statespace/StateSpace.hpp"
7 
8 namespace aikido {
9 namespace statespace {
10 
11 // Defined in detail/Rn-impl.hpp
12 template <class>
13 class RStateHandle;
14 
17 template <int N>
18 class R : public virtual StateSpace
19 {
20 public:
22  class State : public StateSpace::State
23  {
24  public:
25  static constexpr int DimensionAtCompileTime = N;
26 
27  protected:
28  State() = default;
29  ~State() = default;
30 
31  friend class R<N>;
32  };
33 
35  static constexpr int DimensionAtCompileTime = N;
36 
37  using VectorNd = Eigen::Matrix<double, N, 1>;
38 
41 
44 
45  using StateSpace::compose;
46 
59  R();
60 
71  explicit R(int dimension);
72 
76  ScopedState createState() const;
77 
79  ScopedState cloneState(const StateSpace::State* stateIn) const;
80 
85  Eigen::Map<const VectorNd> getValue(const State* _state) const;
86 
91  void setValue(State* _state, const VectorNd& _value) const;
92 
93  // Documentation inherited.
94  std::size_t getStateSizeInBytes() const override;
95 
96  // Documentation inherited.
97  StateSpace::State* allocateStateInBuffer(void* _buffer) const override;
98 
99  // Documentation inherited.
100  void freeStateInBuffer(StateSpace::State* _state) const override;
101 
102  // Documentation inherited.
103  void compose(
104  const StateSpace::State* _state1,
105  const StateSpace::State* _state2,
106  StateSpace::State* _out) const override;
107 
108  // Documentation inherited
109  void getIdentity(StateSpace::State* _out) const override;
110 
111  // Documentation inherited
112  void getInverse(
113  const StateSpace::State* _in, StateSpace::State* _out) const override;
114 
115  // Documentation inherited
116  std::size_t getDimension() const override;
117 
118  // Documentation inherited
119  void copyState(
120  const StateSpace::State* _source,
121  StateSpace::State* _destination) const override;
122 
128  void expMap(
129  const Eigen::VectorXd& _tangent, StateSpace::State* _out) const override;
130 
136  void logMap(
137  const StateSpace::State* _in, Eigen::VectorXd& _tangent) const override;
138 
141  void print(const StateSpace::State* _state, std::ostream& _os) const override;
142 
143 private:
149  Eigen::Map<VectorNd> getMutableValue(State* _state) const;
150 
156  int mDimension;
157 };
158 
159 using R0 = R<0>;
160 using R1 = R<1>;
161 using R2 = R<2>;
162 using R3 = R<3>;
163 using R6 = R<6>;
164 using Rn = R<Eigen::Dynamic>;
165 
166 } // namespace statespace
167 } // namespace aikido
168 
169 #include "detail/Rn-impl.hpp"
170 
171 #endif // ifndef AIKIDO_STATESPACE_REALVECTORSTATESPACE_HPP_
std::size_t getDimension() const override
Get the dimension of this Lie group.
Definition: Rn-impl.hpp:214
CRTP RAII wrapper for a StateHandle.
Definition: ScopedState.hpp:15
ScopedState cloneState(const StateSpace::State *stateIn) const
Creates an identical clone of stateIn.
Definition: Rn-impl.hpp:127
void copyState(const StateSpace::State *_source, StateSpace::State *_destination) const override
Copy a state.
Definition: Rn-impl.hpp:248
virtual void compose(const State *_state1, const State *_state2, State *_out) const =0
Lie group operation for this StateSpace.
void print(const StateSpace::State *_state, std::ostream &_os) const override
Print the n-dimensional vector represented by the state Format: [x_1, x_2, ..., x_n].
Definition: Rn-impl.hpp:287
Format of serialized trajectory in YAML.
Definition: algorithm.hpp:4
A tuple of states where the i-th state is from the i-th subspace.
Definition: CartesianProduct.hpp:162
Eigen::Map< const VectorNd > getValue(const State *_state) const
Gets the real vector stored in a State.
Definition: Rn-impl.hpp:147
std::size_t getStateSizeInBytes() const override
Gets the size of a State, in bytes.
Definition: Rn-impl.hpp:173
ScopedState createState() const
Helper function to create a ScopedState.
Definition: Rn-impl.hpp:120
void setValue(State *_state, const VectorNd &_value) const
Sets the real vector stored in a State.
Definition: Rn-impl.hpp:157
Represents a N-dimensional real vector space with vector addition as the group operation.
Definition: Rn.hpp:18
StateHandle for a Rn.
Definition: Rn-impl.hpp:27
Represents a Lie group and its associated Lie algebra, i.e.
Definition: StateSpace.hpp:33
void logMap(const StateSpace::State *_in, Eigen::VectorXd &_tangent) const override
Log mapping of Lie group element to a Lie algebra element.
Definition: Rn-impl.hpp:276
StateSpace::State * allocateStateInBuffer(void *_buffer) const override
Create a new state in a pre-allocated buffer.
Definition: Rn-impl.hpp:180
R()
Constructs a N dimensional real vector space only when the dimension is can be known in compile time...
Definition: Rn-impl.hpp:84
void expMap(const Eigen::VectorXd &_tangent, StateSpace::State *_out) const override
Exponential mapping of Lie algebra element to a Lie group element.
Definition: Rn-impl.hpp:258
Point in a R<N>.
Definition: Rn.hpp:22