Aikido
CartesianProduct.hpp
Go to the documentation of this file.
1 #ifndef AIKIDO_STATESPACE_COMPOUNDSTATESPACE_HPP_
2 #define AIKIDO_STATESPACE_COMPOUNDSTATESPACE_HPP_
3 #include <vector>
4 
7 
8 namespace aikido {
9 namespace statespace {
10 
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 
176 
177 #endif // AIKIDO_STATESPACE_COMPOUNDSTATESPACE_HPP_
CartesianProduct-impl.hpp
aikido::statespace::CartesianProduct::copyState
void copyState(const StateSpace::State *_source, StateSpace::State *_destination) const override
Copy a state.
aikido
Format of serialized trajectory in YAML.
Definition: algorithm.hpp:4
aikido::statespace::CartesianProduct::logMap
void logMap(const StateSpace::State *_in, Eigen::VectorXd &_tangent) const override
Log mapping of Lie group element to a Lie algebra element.
aikido::statespace::CartesianProduct::getSubStateHandle
Space::StateHandle getSubStateHandle(State *_state, std::size_t _index) const
Gets substate of type Space::State from a CompoundState by index and wraps it in a Space::StateHandle...
Definition: CartesianProduct-impl.hpp:140
StateSpace.hpp
aikido::statespace::CartesianProduct::mSizeInBytes
std::size_t mSizeInBytes
Definition: CartesianProduct.hpp:158
aikido::statespace::CartesianProduct::allocateStateInBuffer
StateSpace::State * allocateStateInBuffer(void *_buffer) const override
Create a new state in a pre-allocated buffer.
aikido::statespace::CartesianProduct::freeStateInBuffer
void freeStateInBuffer(StateSpace::State *_state) const override
Free a state previously created by allocateStateInBuffer.
aikido::statespace::CartesianProduct::cloneState
ScopedState cloneState(const StateSpace::State *stateIn) const
Creates an identical clone of stateIn.
aikido::statespace::CartesianProduct::mSubspaces
std::vector< ConstStateSpacePtr > mSubspaces
Definition: CartesianProduct.hpp:156
aikido::statespace::CartesianProduct::CartesianProduct
CartesianProduct(std::vector< ConstStateSpacePtr > _subspaces)
Construct the Cartesian product of a vector of subspaces.
aikido::statespace::CartesianProduct::compose
void compose(const StateSpace::State *_state1, const StateSpace::State *_state2, StateSpace::State *_out) const override
Lie group operation for this StateSpace.
aikido::statespace::CartesianProduct::getSubspace
std::shared_ptr< const Space > getSubspace(std::size_t _index) const
Gets subspace of type Space by at _index.
Definition: CartesianProduct-impl.hpp:93
aikido::statespace::CartesianProduct::getNumSubspaces
std::size_t getNumSubspaces() const
Gets number of subspaces.
aikido::statespace::CartesianProduct::State::State
State()=default
aikido::statespace::CompoundStateHandle
StateHandle for a CartesianProduct.
Definition: CartesianProduct.hpp:15
aikido::statespace::CartesianProduct::getSubState
Space::State * getSubState(State *_state, std::size_t _index) const
Gets substate of type Space::State from a CompoundState by index.
Definition: CartesianProduct-impl.hpp:116
aikido::statespace::StateSpace
Represents a Lie group and its associated Lie algebra, i.e.
Definition: StateSpace.hpp:33
aikido::statespace::CartesianProduct::getInverse
void getInverse(const StateSpace::State *_in, StateSpace::State *_out) const override
Gets the inverse of _in in this Lie group, such that:
aikido::statespace::CartesianProduct::createState
ScopedState createState() const
Helper function to create a ScopedState.
aikido::statespace::CartesianProduct::State::~State
~State()=default
aikido::statespace::ScopedState< StateHandle >
aikido::statespace::CartesianProduct::State
A tuple of states where the i-th state is from the i-th subspace.
Definition: CartesianProduct.hpp:162
aikido::statespace::CartesianProduct::print
void print(const StateSpace::State *_state, std::ostream &_os) const override
Print the contents of each substate contained in the state as a list with each substate enclosed in b...
aikido::statespace::StateSpace::compose
virtual void compose(const State *_state1, const State *_state2, State *_out) const =0
Lie group operation for this StateSpace.
aikido::statespace::CartesianProduct::mOffsets
std::vector< std::size_t > mOffsets
Definition: CartesianProduct.hpp:157
aikido::statespace::CartesianProduct::getDimension
std::size_t getDimension() const override
Get the dimension of this Lie group.
aikido::statespace::CartesianProduct::expMap
void expMap(const Eigen::VectorXd &_tangent, StateSpace::State *_out) const override
Exponential mapping of Lie algebra element to a Lie group element.
aikido::statespace::StateSpace::State
Definition: StateSpace.hpp:167
aikido::statespace::CartesianProduct::getIdentity
void getIdentity(StateSpace::State *_state) const override
Gets the identity element for this Lie group, such that:
AIKIDO_DECLARE_POINTERS
#define AIKIDO_DECLARE_POINTERS(X)
Definition: pointers.hpp:21
aikido::statespace::CartesianProduct
Represents the Cartesian product of other StateSpaces.
Definition: CartesianProduct.hpp:18
ScopedState.hpp
aikido::statespace::CartesianProduct::getStateSizeInBytes
std::size_t getStateSizeInBytes() const override
Gets the size of a State, in bytes.