hpp-pinocchio  6.0.0
Wrapping of the kinematic/dynamic chain Pinocchio for HPP.
liegroup-space.hh
Go to the documentation of this file.
1 // Copyright (c) 2017, CNRS
2 // Authors: Florent Lamiraux
3 //
4 
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // 1. Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // 2. Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
27 // DAMAGE.
28 
29 #ifndef HPP_PINOCCHIO_LIEGROUP_SPACE_HH
30 #define HPP_PINOCCHIO_LIEGROUP_SPACE_HH
31 
32 #include <boost/variant.hpp>
33 #include <hpp/pinocchio/fwd.hh>
35 #include <hpp/util/serialization-fwd.hh>
36 #include <pinocchio/fwd.hpp>
37 #include <pinocchio/multibody/liegroup/special-euclidean.hpp>
38 #include <pinocchio/multibody/liegroup/special-orthogonal.hpp>
39 #include <pinocchio/multibody/liegroup/vector-space.hpp>
40 #include <string>
41 #include <vector>
42 
43 namespace hpp {
44 namespace pinocchio {
47 
48 #ifdef HPP_PINOCCHIO_PARSED_BY_DOXYGEN
59 typedef ABoostVariant LiegroupType;
60 #else
61 typedef boost::variant<liegroup::VectorSpaceOperation<Eigen::Dynamic, false>,
78 #endif
79 
81 
102  public:
103  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
106 
109  static LiegroupSpacePtr_t Rn(const size_type& n);
113  static LiegroupSpacePtr_t R1(bool rotation = false);
133 
135  static LiegroupSpacePtr_t create(const size_type& size) {
136  LiegroupSpace* ptr(new LiegroupSpace(size));
137  LiegroupSpacePtr_t shPtr(ptr);
138  ptr->init(shPtr);
139  return shPtr;
140  }
141 
144  LiegroupSpace* ptr(new LiegroupSpace(*other));
145  LiegroupSpacePtr_t shPtr(ptr);
146  ptr->init(shPtr);
147  return shPtr;
148  }
149 
151  static LiegroupSpacePtr_t create(const LiegroupType& type) {
152  LiegroupSpace* ptr(new LiegroupSpace(type));
153  LiegroupSpacePtr_t shPtr(ptr);
154  ptr->init(shPtr);
155  return shPtr;
156  }
157 
159  size_type nq() const { return nq_; }
161  size_type nv() const { return nv_; }
163  size_type nq(const std::size_t& rank) const;
165  size_type nv(const std::size_t& rank) const;
166 
168  const std::vector<LiegroupType>& liegroupTypes() const {
169  return liegroupTypes_;
170  }
171 
174 
177 
180 
183 
186 
209  template <DerivativeProduct side>
211  matrixOut_t J) const;
212 
235  template <DerivativeProduct side>
237  matrixOut_t Jv) const;
238 
240  template <bool ApplyOnTheLeft>
242  matrixOut_t J1) const;
243 
253  template <DerivativeProduct side>
255 
265  template <DerivativeProduct side>
267 
277  vectorOut_t result) const;
278 
280  std::string name() const;
281 
283 
285 
286  bool isVectorSpace() const;
287 
288  bool operator==(const LiegroupSpace& other) const;
289  bool operator!=(const LiegroupSpace& other) const;
290 
292 
293  protected:
295  LiegroupSpace(const size_type& size);
298 
299  private:
301  LiegroupSpace();
303  void init(const LiegroupSpaceWkPtr_t weak);
305  void computeSize();
307  void computeNeutral();
308  typedef std::vector<LiegroupType> LiegroupTypes;
309  LiegroupTypes liegroupTypes_;
311  size_type nq_, nv_;
313  vector_t neutral_;
315  LiegroupSpaceWkPtr_t weak_;
316 
317  HPP_SERIALIZABLE();
318 }; // class LiegroupSpace
320 inline std::ostream& operator<<(std::ostream& os, const LiegroupSpace& space) {
321  os << space.name();
322  return os;
323 }
324 
326 } // namespace pinocchio
327 } // namespace hpp
328 
329 namespace std {
332 
342 } // namespace std
343 
344 #endif // HPP_PINOCCHIO_LIEGROUP_SPACE_HH
Definition: liegroup-element.hh:117
Definition: liegroup-element.hh:45
Definition: liegroup-space.hh:101
LiegroupElementRef elementRef(vectorOut_t q) const
Create a LiegroupElementRef from a configuration.
LiegroupElement element(vectorIn_t q) const
Create a LiegroupElement from a configuration.
void dDifference_dq0(vectorIn_t q0, vectorIn_t q1, matrixOut_t J0) const
static LiegroupSpacePtr_t R2()
Return as a Lie group.
LiegroupElement exp(vectorIn_t v) const
Return exponential of a tangent vector.
void dIntegrate_dq(LiegroupElementConstRef q, vectorIn_t v, matrixOut_t J) const
LiegroupSpace(const LiegroupType &type)
size_type nq(const std::size_t &rank) const
Dimension of elementary Liegroup at given rank.
static LiegroupSpacePtr_t create(const LiegroupType &type)
Create instance with one Elementary Lie group.
Definition: liegroup-space.hh:151
bool operator==(const LiegroupSpace &other) const
size_type nq() const
Dimension of the vector representation.
Definition: liegroup-space.hh:159
void interpolate(vectorIn_t q0, vectorIn_t q1, value_type u, vectorOut_t result) const
static LiegroupSpacePtr_t R2xSO2()
Return .
size_type nv(const std::size_t &rank) const
Dimension of elementary Liegroup tangent space at given rank.
LiegroupElement neutral() const
Return the neutral element as a vector.
static LiegroupSpacePtr_t empty()
Return empty Lie group.
static LiegroupSpacePtr_t createCopy(const LiegroupSpaceConstPtr_t &other)
Create copy.
Definition: liegroup-space.hh:143
static LiegroupSpacePtr_t R3()
Return as a Lie group.
std::string name() const
Return name of Lie group.
static LiegroupSpacePtr_t Rn(const size_type &n)
static LiegroupSpacePtr_t SE2()
Return .
static LiegroupSpacePtr_t create(const size_type &size)
Create instance of vector space of given size.
Definition: liegroup-space.hh:135
void Jdifference(vectorIn_t q0, vectorIn_t q1, matrixOut_t J0, matrixOut_t J1) const
void dIntegrate_dv(LiegroupElementConstRef q, vectorIn_t v, matrixOut_t Jv) const
LiegroupSpacePtr_t operator*=(const LiegroupSpaceConstPtr_t &other)
static LiegroupSpacePtr_t R1(bool rotation=false)
static LiegroupSpacePtr_t SE3()
Return .
static LiegroupSpacePtr_t SO2()
Return .
void dDifference_dq1(vectorIn_t q0, vectorIn_t q1, matrixOut_t J1) const
static LiegroupSpacePtr_t R3xSO3()
Return .
const std::vector< LiegroupType > & liegroupTypes() const
Get reference to vector of elementary types.
Definition: liegroup-space.hh:168
size_type nv() const
Dimension of the Lie group tangent space.
Definition: liegroup-space.hh:161
LiegroupElementConstRef elementConstRef(vectorIn_t q) const
Create a LiegroupElementRef from a configuration.
static LiegroupSpacePtr_t SO3()
Return .
LiegroupSpace(const size_type &size)
Constructor of vector space of given size.
bool operator!=(const LiegroupSpace &other) const
LiegroupSpacePtr_t vectorSpacesMerged() const
LiegroupSpace(const LiegroupSpace &other)
hpp::pinocchio::LiegroupSpacePtr_t operator^(const hpp::pinocchio::LiegroupSpaceConstPtr_t &sp, hpp::pinocchio::size_type n)
Cartesian power by an integer.
hpp::pinocchio::LiegroupSpacePtr_t operator*(const hpp::pinocchio::LiegroupSpaceConstPtr_t &sp1, const hpp::pinocchio::LiegroupSpaceConstPtr_t &sp2)
Cartesian product between Lie groups.
DerivativeProduct
Definition: liegroup-space.hh:80
ABoostVariant LiegroupType
Definition: liegroup-space.hh:59
@ InputTimesDerivative
Definition: liegroup-space.hh:80
@ DerivativeTimesInput
Definition: liegroup-space.hh:80
Eigen::Ref< matrix_t > matrixOut_t
Definition: fwd.hh:96
Eigen::Matrix< value_type, Eigen::Dynamic, 1 > vector_t
Definition: fwd.hh:88
Eigen::Ref< vector_t > vectorOut_t
Definition: fwd.hh:94
std::ostream & operator<<(std::ostream &os, const hpp::pinocchio::Device &device)
Definition: device.hh:366
shared_ptr< const LiegroupSpace > LiegroupSpaceConstPtr_t
Definition: fwd.hh:151
shared_ptr< LiegroupSpace > LiegroupSpacePtr_t
Definition: fwd.hh:150
matrix_t::Index size_type
Definition: fwd.hh:97
double value_type
Definition: fwd.hh:51
Eigen::Ref< const vector_t > vectorIn_t
Definition: fwd.hh:93
Utility functions.
Definition: body.hh:39
Definition: collision-object.hh:40
Definition: liegroup-space.hh:329
Definition: cartesian-product.hh:40
Definition: special-euclidean.hh:39
Definition: special-orthogonal.hh:39