hpp-pinocchio 6.0.0
Wrapping of the kinematic/dynamic chain Pinocchio for HPP.
Loading...
Searching...
No Matches
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
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_CENTER_OF_MASS_COMPUTATION_HH
30#define HPP_PINOCCHIO_CENTER_OF_MASS_COMPUTATION_HH
31
33#include <hpp/pinocchio/fwd.hh>
34#include <hpp/util/serialization-fwd.hh>
35#include <list>
36#include <pinocchio/multibody/data.hpp> // ::pinocchio::Data
37
38namespace hpp {
39namespace pinocchio {
53 public:
54 typedef std::vector<std::size_t> JointRootIndexes_t;
56 // This fixes an alignment issue of ::pinocchio::Data::hg
57 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
59
60 public:
66
71 void add(const JointPtr_t& rootOfSubtree);
72
75 void compute(const Computation_t& flag = COMPUTE_ALL) {
76 compute(robot_->d(), flag);
77 }
78
81 void compute(DeviceData& data, const Computation_t& flag);
82
84 const vector3_t& com() const { return com(robot_->d()); }
86 const value_type& mass() const { return mass(robot_->d()); }
88 const ComJacobian_t& jacobian() const { return jacobian(robot_->d()); }
89
93 static const vector3_t& com(const DeviceData& d) { return d.data_->com[0]; }
97 static const value_type& mass(const DeviceData& d) {
98 return d.data_->mass[0];
99 }
103 static const ComJacobian_t& jacobian(const DeviceData& d) {
104 return d.data_->Jcom;
105 }
106
108 const JointRootIndexes_t& roots() const { return roots_; }
109
111
112 protected:
114
115 private:
116 DevicePtr_t robot_;
117 // Root of the subtrees
118 JointRootIndexes_t roots_;
119
121 HPP_SERIALIZABLE();
122}; // class CenterOfMassComputation
123} // namespace pinocchio
124} // namespace hpp
125#endif // HPP_PINOCCHIO_CENTER_OF_MASS_COMPUTATION_HH
Definition center-of-mass-computation.hh:52
void add(const JointPtr_t &rootOfSubtree)
const vector3_t & com() const
Get center of mass of the subtree.
Definition center-of-mass-computation.hh:84
void compute(const Computation_t &flag=COMPUTE_ALL)
Definition center-of-mass-computation.hh:75
const value_type & mass() const
Get mass of the sub-tree.
Definition center-of-mass-computation.hh:86
const JointRootIndexes_t & roots() const
Get const reference to the vector of sub-tree roots.
Definition center-of-mass-computation.hh:108
CenterOfMassComputation(const DevicePtr_t &device)
void compute(DeviceData &data, const Computation_t &flag)
const ComJacobian_t & jacobian() const
Get Jacobian of center of mass of the sub-tree.
Definition center-of-mass-computation.hh:88
static const value_type & mass(const DeviceData &d)
Get mass of the sub-tree.
Definition center-of-mass-computation.hh:97
std::vector< std::size_t > JointRootIndexes_t
Definition center-of-mass-computation.hh:54
static const ComJacobian_t & jacobian(const DeviceData &d)
Get Jacobian of center of mass of the sub-tree.
Definition center-of-mass-computation.hh:103
static CenterOfMassComputationPtr_t create(const DevicePtr_t &device)
static const vector3_t & com(const DeviceData &d)
Get center of mass of the subtree.
Definition center-of-mass-computation.hh:93
shared_ptr< Device > DevicePtr_t
Definition fwd.hh:118
shared_ptr< CenterOfMassComputation > CenterOfMassComputationPtr_t
Definition fwd.hh:122
Computation_t
Definition device-data.hh:40
@ COMPUTE_ALL
Definition device-data.hh:46
shared_ptr< Joint > JointPtr_t
Definition fwd.hh:123
Eigen::Matrix< value_type, 3, 1 > vector3_t
Definition fwd.hh:99
double value_type
Definition fwd.hh:51
Eigen::Matrix< value_type, 3, Eigen::Dynamic > ComJacobian_t
Definition fwd.hh:102
Utility functions.
Definition body.hh:39
Definition collision-object.hh:40
Definition device-data.hh:51
DataPtr_t data_
Definition device-data.hh:68