hpp-pinocchio  4.9.1
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 // This file is part of hpp-pinocchio.
5 // hpp-pinocchio is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // hpp-pinocchio is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // hpp-pinocchio. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef HPP_PINOCCHIO_LIEGROUP_SPACE_HH
18 # define HPP_PINOCCHIO_LIEGROUP_SPACE_HH
19 
20 # include <vector>
21 # include <string>
22 # include <pinocchio/fwd.hpp>
23 # include <boost/variant.hpp>
24 # include <pinocchio/multibody/liegroup/special-euclidean.hpp>
25 # include <pinocchio/multibody/liegroup/special-orthogonal.hpp>
26 # include <pinocchio/multibody/liegroup/vector-space.hpp>
27 # include <hpp/pinocchio/liegroup.hh>
28 # include <hpp/pinocchio/fwd.hh>
29 
30 namespace hpp {
31  namespace pinocchio {
34 
35 #ifdef HPP_PINOCCHIO_PARSED_BY_DOXYGEN
36  typedef ABoostVariant LiegroupType;
47 #else
48  typedef boost::variant <liegroup::VectorSpaceOperation
49  <Eigen::Dynamic, false>,
50  liegroup::VectorSpaceOperation <1, true>,
51  liegroup::VectorSpaceOperation <1, false>,
52  liegroup::VectorSpaceOperation <2, false>,
53  liegroup::VectorSpaceOperation <3, false>,
54  liegroup::VectorSpaceOperation <3, true>,
55  liegroup::CartesianProductOperation<
56  liegroup::VectorSpaceOperation<3, false>,
57  liegroup::SpecialOrthogonalOperation<3> >,
58  liegroup::CartesianProductOperation<
59  liegroup::VectorSpaceOperation<2, false>,
60  liegroup::SpecialOrthogonalOperation<2> >,
61  liegroup::SpecialOrthogonalOperation <2>,
62  liegroup::SpecialOrthogonalOperation <3>,
63  liegroup::SpecialEuclideanOperation <2>,
64  liegroup::SpecialEuclideanOperation <3> >
66 #endif
67 
71  };
72 
93  {
94  public:
95  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
98 
101  static LiegroupSpacePtr_t Rn (const size_type& n);
103  static LiegroupSpacePtr_t R1 ();
105  static LiegroupSpacePtr_t R2 ();
107  static LiegroupSpacePtr_t R3 ();
109  static LiegroupSpacePtr_t SE2 ();
111  static LiegroupSpacePtr_t SE3 ();
113  static LiegroupSpacePtr_t SO2 ();
115  static LiegroupSpacePtr_t SO3 ();
117  static LiegroupSpacePtr_t R2xSO2 ();
119  static LiegroupSpacePtr_t R3xSO3 ();
121  static LiegroupSpacePtr_t empty ();
123 
126  {
127  LiegroupSpace* ptr (new LiegroupSpace (size));
128  LiegroupSpacePtr_t shPtr (ptr);
129  ptr->init (shPtr);
130  return shPtr;
131  }
132 
135  (const LiegroupSpaceConstPtr_t& other)
136  {
137  LiegroupSpace* ptr (new LiegroupSpace (*other));
138  LiegroupSpacePtr_t shPtr (ptr);
139  ptr->init (shPtr);
140  return shPtr;
141  }
142 
144  static LiegroupSpacePtr_t create (const LiegroupType& type)
145  {
146  LiegroupSpace* ptr (new LiegroupSpace (type));
147  LiegroupSpacePtr_t shPtr (ptr);
148  ptr->init (shPtr);
149  return shPtr;
150  }
151 
153  size_type nq () const
154  {
155  return nq_;
156  }
158  size_type nv () const
159  {
160  return nv_;
161  }
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  {
170  return liegroupTypes_;
171  }
172 
174  LiegroupElement neutral () const;
175 
178 
181 
184 
186  LiegroupElement exp (vectorIn_t v) const;
187 
208  template <DerivativeProduct side>
210 
230  template <DerivativeProduct side>
232 
234  template <bool ApplyOnTheLeft>
235  void Jdifference (vectorIn_t q0, vectorIn_t q1, matrixOut_t J0, matrixOut_t J1) const;
236 
246  template <DerivativeProduct side>
247  void dDifference_dq0 (vectorIn_t q0, vectorIn_t q1, matrixOut_t J0) const;
248 
258  template <DerivativeProduct side>
259  void dDifference_dq1 (vectorIn_t q0, vectorIn_t q1, matrixOut_t J1) const;
260 
270  vectorOut_t result) const;
271 
273  std::string name () const;
274 
275  void mergeVectorSpaces ();
276 
278 
279  bool isVectorSpace () const;
280 
281  bool operator== (const LiegroupSpace& other) const;
282  bool operator!= (const LiegroupSpace& other) const;
283 
285 
286  protected:
287 
289  LiegroupSpace (const size_type& size);
290  LiegroupSpace (const LiegroupSpace& other);
291  LiegroupSpace (const LiegroupType& type);
292 
293  private:
295  LiegroupSpace ();
297  void init (const LiegroupSpaceWkPtr_t weak);
299  void computeSize ();
301  void computeNeutral ();
302  typedef std::vector <LiegroupType> LiegroupTypes;
303  LiegroupTypes liegroupTypes_;
305  size_type nq_, nv_;
307  vector_t neutral_;
309  LiegroupSpaceWkPtr_t weak_;
310  }; // class LiegroupSpace
312  inline std::ostream& operator<< (std::ostream& os,
313  const LiegroupSpace& space)
314  {
315  os << space.name (); return os;
316  }
317 
319  } // namespace pinocchio
320 } // namespace hpp
321 
322 namespace boost {
325 
335 } // namespace boost
336 
337 #endif // HPP_PINOCCHIO_LIEGROUP_SPACE_HH
void Jdifference(vectorIn_t q0, vectorIn_t q1, matrixOut_t J0, matrixOut_t J1) const
static LiegroupSpacePtr_t SE3()
Return .
static LiegroupSpacePtr_t R2()
Return as a Lie group.
LiegroupSpacePtr_t vectorSpacesMerged() const
static LiegroupSpacePtr_t Rn(const size_type &n)
Vec3f n
Definition: liegroup-space.hh:322
static LiegroupSpacePtr_t SO3()
Return .
Utility functions.
static LiegroupSpacePtr_t R1()
Return as a Lie group.
static LiegroupSpacePtr_t R3()
Return as a Lie group.
Eigen::Ref< vector_t > vectorOut_t
Definition: fwd.hh:81
LiegroupElement neutral() const
Return the neutral element as a vector.
LiegroupElementConstRef elementConstRef(vectorIn_t q) const
Create a LiegroupElementRef from a configuration.
static LiegroupSpacePtr_t SE2()
Return .
ABoostVariant LiegroupType
Definition: liegroup-space.hh:46
bool operator!=(const LiegroupSpace &other) const
void dIntegrate_dv(LiegroupElementConstRef q, vectorIn_t v, matrixOut_t Jv) const
static LiegroupSpacePtr_t empty()
Return empty Lie group.
matrix_t::Index size_type
Definition: fwd.hh:84
size_type nv() const
Dimension of the Lie group tangent space.
Definition: liegroup-space.hh:158
Eigen::Ref< matrix_t > matrixOut_t
Definition: fwd.hh:83
Definition: liegroup-space.hh:92
size_type nq() const
Dimension of the vector representation.
Definition: liegroup-space.hh:153
Definition: liegroup-space.hh:70
bool operator==(const LiegroupSpace &other) const
std::ostream & operator<<(std::ostream &os, const hpp::pinocchio::Device &device)
Definition: device.hh:344
Eigen::Matrix< value_type, Eigen::Dynamic, 1 > vector_t
Definition: fwd.hh:75
static LiegroupSpacePtr_t createCopy(const LiegroupSpaceConstPtr_t &other)
Create copy.
Definition: liegroup-space.hh:135
DerivativeProduct
Definition: liegroup-space.hh:68
boost::shared_ptr< const LiegroupSpace > LiegroupSpaceConstPtr_t
Definition: fwd.hh:135
static LiegroupSpacePtr_t create(const LiegroupType &type)
Create instance with one Elementary Lie group.
Definition: liegroup-space.hh:144
LiegroupElement element(vectorIn_t q) const
Create a LiegroupElement from a configuration.
static LiegroupSpacePtr_t R2xSO2()
Return .
LiegroupElementRef elementRef(vectorOut_t q) const
Create a LiegroupElementRef from a configuration.
double value_type
Definition: fwd.hh:40
static LiegroupSpacePtr_t R3xSO3()
Return .
LiegroupSpacePtr_t operator*=(const LiegroupSpaceConstPtr_t &other)
Eigen::Ref< const vector_t > vectorIn_t
Definition: fwd.hh:80
LiegroupElement exp(vectorIn_t v) const
Return exponential of a tangent vector.
void dIntegrate_dq(LiegroupElementConstRef q, vectorIn_t v, matrixOut_t Jq) const
void dDifference_dq0(vectorIn_t q0, vectorIn_t q1, matrixOut_t J0) const
FCL_REAL size() const
static LiegroupSpacePtr_t SO2()
Return .
boost::shared_ptr< LiegroupSpace > LiegroupSpacePtr_t
Definition: fwd.hh:134
Definition: liegroup-space.hh:69
void dDifference_dq1(vectorIn_t q0, vectorIn_t q1, matrixOut_t J1) const
void interpolate(vectorIn_t q0, vectorIn_t q1, value_type u, vectorOut_t result) const
std::string name() const
Return name of Lie group.
hpp::pinocchio::LiegroupSpacePtr_t operator*(const hpp::pinocchio::LiegroupSpaceConstPtr_t &sp1, const hpp::pinocchio::LiegroupSpaceConstPtr_t &sp2)
Cartesian product between Lie groups.
static LiegroupSpacePtr_t create(const size_type &size)
Create instance of vector space of given size.
Definition: liegroup-space.hh:125
const std::vector< LiegroupType > & liegroupTypes() const
Get reference to vector of elementary types.
Definition: liegroup-space.hh:168