aikido
SO2.hpp
1 #ifndef AIKIDO_STATESPACE_SO2STATESPACE_HPP_
2 #define AIKIDO_STATESPACE_SO2STATESPACE_HPP_
3 #include <Eigen/Core>
4 #include <Eigen/Geometry>
5 
6 #include "aikido/statespace/ScopedState.hpp"
7 #include "aikido/statespace/StateSpace.hpp"
8 
9 namespace aikido {
10 namespace statespace {
11 
12 // Defined in detail/SO2-impl.hpp
13 template <class>
14 class SO2StateHandle;
15 
18 class SO2 : virtual public StateSpace
19 {
20 public:
22  class State;
23 
26 
29 
30  using StateSpace::compose;
31 
33  SO2() = default;
34 
38  ScopedState createState() const;
39 
41  ScopedState cloneState(const StateSpace::State* stateIn) const;
42 
46  double toAngle(const State* state) const;
47 
52  void fromAngle(State* state, double angle) const;
53 
57  Eigen::Rotation2Dd toRotation(const State* state) const;
58 
63  void fromRotation(State* state, const Eigen::Rotation2Dd& rotation) const;
64 
65  // Documentation inherited.
66  std::size_t getStateSizeInBytes() const override;
67 
68  // Documentation inherited.
69  StateSpace::State* allocateStateInBuffer(void* buffer) const override;
70 
71  // Documentation inherited.
72  void freeStateInBuffer(StateSpace::State* state) const override;
73 
74  // Documentation inherited.
75  void compose(
76  const StateSpace::State* state1,
77  const StateSpace::State* state2,
78  StateSpace::State* out) const override;
79 
80  // Documentation inherited.
81  void getIdentity(StateSpace::State* out) const override;
82 
83  // Documentation inherited.
84  void getInverse(
85  const StateSpace::State* in, StateSpace::State* out) const override;
86 
87  // Documentation inherited.
88  std::size_t getDimension() const override;
89 
90  // Documentation inherited.
91  void copyState(
92  const StateSpace::State* source,
93  StateSpace::State* destination) const override;
94 
100  void expMap(
101  const Eigen::VectorXd& tangent, StateSpace::State* out) const override;
102 
108  void logMap(
109  const StateSpace::State* in, Eigen::VectorXd& tangent) const override;
110 
112  void print(const StateSpace::State* state, std::ostream& os) const override;
113 };
114 
115 class SO2::State final : public StateSpace::State
116 {
117 public:
121  explicit State(double angle = 0.0);
122 
123  ~State() = default;
124 
126  double toAngle() const;
127 
131  void fromAngle(double angle);
132 
134  Eigen::Rotation2Dd toRotation() const;
135 
139  void fromRotation(const Eigen::Rotation2Dd& rotation);
140 
141 private:
143  double mAngle;
144 
145  friend class SO2;
146 };
147 
148 } // namespace statespace
149 } // namespace aikido
150 
151 #include "detail/SO2-impl.hpp"
152 
153 #endif // ifndef AIKIDO_STATESPACE_SO2STATESPACE_HPP_
The two-dimensional special orthogonal group SO(2), i.e.
Definition: SO2.hpp:18
Definition: SO2.hpp:115
std::size_t getStateSizeInBytes() const override
Gets the size of a State, in bytes.
Definition: SO2.cpp:81
void copyState(const StateSpace::State *source, StateSpace::State *destination) const override
Copy a state.
Definition: SO2.cpp:140
StateSpace::State * allocateStateInBuffer(void *buffer) const override
Create a new state in a pre-allocated buffer.
Definition: SO2.cpp:87
CRTP RAII wrapper for a StateHandle.
Definition: ScopedState.hpp:15
virtual void compose(const State *_state1, const State *_state2, State *_out) const =0
Lie group operation for this StateSpace.
void expMap(const Eigen::VectorXd &tangent, StateSpace::State *out) const override
Exponential mapping of Lie algebra element to a Lie group element.
Definition: SO2.cpp:149
Format of serialized trajectory in YAML.
Definition: algorithm.hpp:4
void fromAngle(State *state, double angle) const
Sets state from a rotation angle in (-inf, inf).
Definition: SO2.cpp:63
A tuple of states where the i-th state is from the i-th subspace.
Definition: CartesianProduct.hpp:162
void print(const StateSpace::State *state, std::ostream &os) const override
Print the angle represented by the state.
Definition: SO2.cpp:176
void logMap(const StateSpace::State *in, Eigen::VectorXd &tangent) const override
Log mapping of Lie group element to a Lie algebra element.
Definition: SO2.cpp:166
ScopedState createState() const
Helper function to create a ScopedState.
Definition: SO2.cpp:42
double toAngle(const State *state) const
Returns state as a rotation angle in (-pi, pi].
Definition: SO2.cpp:57
std::size_t getDimension() const override
Get the dimension of this Lie group.
Definition: SO2.cpp:134
void fromRotation(State *state, const Eigen::Rotation2Dd &rotation) const
Sets state from an Eigen rotation.
Definition: SO2.cpp:75
Represents a Lie group and its associated Lie algebra, i.e.
Definition: StateSpace.hpp:33
ScopedState cloneState(const StateSpace::State *stateIn) const
Creates an identical clone of stateIn.
Definition: SO2.cpp:48
StateHandle for a SO2.
Definition: SO2-impl.hpp:9
Eigen::Rotation2Dd toRotation(const State *state) const
Returns state as an Eigen rotation.
Definition: SO2.cpp:69
SO2()=default
Constructs a state space representing SO(2).