aikido
CartesianProduct.hpp
1 #ifndef AIKIDO_STATESPACE_COMPOUNDSTATESPACE_HPP_
2 #define AIKIDO_STATESPACE_COMPOUNDSTATESPACE_HPP_
3 #include <vector>
4 
5 #include "aikido/statespace/ScopedState.hpp"
6 #include "aikido/statespace/StateSpace.hpp"
7 
8 namespace aikido {
9 namespace statespace {
10 
11 AIKIDO_DECLARE_POINTERS(CartesianProduct)
12 
13 // Defined in detail/CartesianProduct.hpp
14 template <class>
16 
19  : public std::enable_shared_from_this<CartesianProduct>
20  , public virtual StateSpace
21 {
22 public:
23  class State;
24 
27 
30 
31  using StateSpace::compose;
32 
35  explicit CartesianProduct(std::vector<ConstStateSpacePtr> _subspaces);
36 
40  ScopedState createState() const;
41 
43  ScopedState cloneState(const StateSpace::State* stateIn) const;
44 
48  std::size_t getNumSubspaces() const;
49 
55  template <class Space = StateSpace>
56  std::shared_ptr<const Space> getSubspace(std::size_t _index) const;
57 
64  template <class Space = StateSpace>
65  typename Space::State* getSubState(State* _state, std::size_t _index) const;
66 
74  template <class Space = StateSpace>
75  const typename Space::State* getSubState(
76  const State* _state, std::size_t _index) const;
77 
85  template <class Space = StateSpace>
86  typename Space::StateHandle getSubStateHandle(
87  State* _state, std::size_t _index) const;
88 
97  template <class Space = StateSpace>
98  typename Space::StateHandleConst getSubStateHandle(
99  const State* _state, std::size_t _index) const;
100 
101  // Documentation inherited.
102  std::size_t getStateSizeInBytes() const override;
103 
104  // Documentation inherited.
105  StateSpace::State* allocateStateInBuffer(void* _buffer) const override;
106 
107  // Documentation inherited.
108  void freeStateInBuffer(StateSpace::State* _state) const override;
109 
110  // Documentation inherited.
111  void compose(
112  const StateSpace::State* _state1,
113  const StateSpace::State* _state2,
114  StateSpace::State* _out) const override;
115 
116  // Documentation inherited
117  void getIdentity(StateSpace::State* _state) const override;
118 
119  // Documentation inherited
120  void getInverse(
121  const StateSpace::State* _in, StateSpace::State* _out) const override;
122 
123  // Documentation inherited
124  std::size_t getDimension() const override;
125 
126  // Documentation inherited
127  void copyState(
128  const StateSpace::State* _source,
129  StateSpace::State* _destination) const override;
130 
137  void expMap(
138  const Eigen::VectorXd& _tangent, StateSpace::State* _out) const override;
139 
146  void logMap(
147  const StateSpace::State* _in, Eigen::VectorXd& _tangent) const override;
148 
153  void print(const StateSpace::State* _state, std::ostream& _os) const override;
154 
155 private:
156  std::vector<ConstStateSpacePtr> mSubspaces;
157  std::vector<std::size_t> mOffsets;
158  std::size_t mSizeInBytes;
159 };
160 
163 {
164 protected:
165  friend class CartesianProduct;
166 
167  State() = default;
168 
169  ~State() = default;
170 };
171 
172 } // namespace statespace
173 } // namespace aikido
174 
175 #include "detail/CartesianProduct-impl.hpp"
176 
177 #endif // AIKIDO_STATESPACE_COMPOUNDSTATESPACE_HPP_
CRTP RAII wrapper for a StateHandle.
Definition: ScopedState.hpp:15
Represents the Cartesian product of other StateSpaces.
Definition: CartesianProduct.hpp:18
Definition: gtest-tuple.h:113
virtual void compose(const State *_state1, const State *_state2, State *_out) const =0
Lie group operation for this StateSpace.
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
StateHandle for a CartesianProduct.
Definition: CartesianProduct.hpp:15
Represents a Lie group and its associated Lie algebra, i.e.
Definition: StateSpace.hpp:33