hpp-pinocchio  4.9.1
Wrapping of the kinematic/dynamic chain Pinocchio for HPP.
center-of-mass-computation.hh
Go to the documentation of this file.
1 // Copyright (c) 2016, LAAS-CNRS
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
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_CENTER_OF_MASS_COMPUTATION_HH
18 # define HPP_PINOCCHIO_CENTER_OF_MASS_COMPUTATION_HH
19 
20 # include <list>
21 
22 # include <pinocchio/multibody/data.hpp> // ::pinocchio::Data
23 
24 # include <hpp/pinocchio/fwd.hh>
25 # include <hpp/pinocchio/device.hh>
26 
27 namespace hpp {
28  namespace pinocchio {
42  {
43  public:
44  typedef std::vector <std::size_t> JointRootIndexes_t;
46  // This fixes an alignment issue of ::pinocchio::Data::hg
47  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
49 
50  public:
55  static CenterOfMassComputationPtr_t create (const DevicePtr_t& device);
56 
61  void add (const JointPtr_t& rootOfSubtree);
62 
65  void compute (const Computation_t& flag = COMPUTE_ALL)
66  {
67  compute (robot_->d(), flag);
68  }
69 
72  void compute (DeviceData& data, const Computation_t& flag);
73 
75  const vector3_t& com () const { return com (robot_->d()); }
77  const value_type& mass () const { return mass (robot_->d()); }
79  const ComJacobian_t& jacobian () const { return jacobian(robot_->d()); }
80 
84  static const vector3_t& com (const DeviceData& d) { return d.data_->com [0]; }
88  static const value_type& mass (const DeviceData& d) { return d.data_->mass[0]; }
92  static const ComJacobian_t& jacobian (const DeviceData& d) { return d.data_->Jcom ; }
93 
95  const JointRootIndexes_t & roots () const { return roots_; }
96 
98 
99  protected:
100  CenterOfMassComputation (const DevicePtr_t& device);
101 
102  private:
103  DevicePtr_t robot_;
104  // Root of the subtrees
105  JointRootIndexes_t roots_;
106  }; // class CenterOfMassComputation
107  } // namespace pinocchio
108 } // namespace hpp
109 #endif // HPP_PINOCCHIO_CENTER_OF_MASS_COMPUTATION_HH
static const ComJacobian_t & jacobian(const DeviceData &d)
Get Jacobian of center of mass of the sub-tree.
Definition: center-of-mass-computation.hh:92
std::vector< std::size_t > JointRootIndexes_t
Definition: center-of-mass-computation.hh:44
boost::shared_ptr< Device > DevicePtr_t
Definition: fwd.hh:104
static CenterOfMassComputationPtr_t create(const DevicePtr_t &device)
Utility functions.
void add(const JointPtr_t &rootOfSubtree)
static const vector3_t & com(const DeviceData &d)
Get center of mass of the subtree.
Definition: center-of-mass-computation.hh:84
Definition: device-data.hh:41
static const value_type & mass(const DeviceData &d)
Get mass of the sub-tree.
Definition: center-of-mass-computation.hh:88
const ComJacobian_t & jacobian() const
Get Jacobian of center of mass of the sub-tree.
Definition: center-of-mass-computation.hh:79
const value_type & mass() const
Get mass of the sub-tree.
Definition: center-of-mass-computation.hh:77
void compute(const Computation_t &flag=COMPUTE_ALL)
Definition: center-of-mass-computation.hh:65
Eigen::Matrix< value_type, 3, Eigen::Dynamic > ComJacobian_t
Definition: fwd.hh:89
DataPtr_t data_
Definition: device-data.hh:53
Computation_t
Definition: device-data.hh:30
Definition: center-of-mass-computation.hh:41
const JointRootIndexes_t & roots() const
Get const reference to the vector of sub-tree roots.
Definition: center-of-mass-computation.hh:95
FCL_REAL d
double value_type
Definition: fwd.hh:40
Definition: device-data.hh:36
boost::shared_ptr< CenterOfMassComputation > CenterOfMassComputationPtr_t
Definition: fwd.hh:108
CenterOfMassComputation(const DevicePtr_t &device)
const vector3_t & com() const
Get center of mass of the subtree.
Definition: center-of-mass-computation.hh:75
Eigen::Matrix< value_type, 3, 1 > vector3_t
Definition: fwd.hh:86
boost::shared_ptr< Joint > JointPtr_t
Definition: fwd.hh:109