Loading...
Searching...
No Matches
CoM.h
Go to the documentation of this file.
1/*
2 * Copyright 2012-2019 CNRS-UM LIRMM, CNRS-AIST JRL
3 */
4
5#pragma once
6
7// std
8#include <vector>
9
10// Eigen
11#include <Eigen/Core>
12
13// RBDyn
14#include <rbdyn/config.hh>
15
16#include "Jacobian.h"
17
18namespace rbd
19{
20class MultiBody;
21struct MultiBodyConfig;
22
29RBDYN_DLLAPI Eigen::Vector3d computeCoM(const MultiBody & mb, const MultiBodyConfig & mbc);
30
37RBDYN_DLLAPI Eigen::Vector3d computeCoMVelocity(const MultiBody & mb, const MultiBodyConfig & mbc);
38
45RBDYN_DLLAPI Eigen::Vector3d computeCoMAcceleration(const MultiBody & mb, const MultiBodyConfig & mbc);
46
50class RBDYN_DLLAPI CoMJacobianDummy
51{
52public:
54
61 CoMJacobianDummy(const MultiBody & mb, std::vector<double> weight);
62
64
71 const Eigen::MatrixXd & jacobian(const MultiBody & mb, const MultiBodyConfig & mbc);
72
77 inline const Eigen::MatrixXd & jacobian() const noexcept
78 {
79 return jac_;
80 }
81
88 const Eigen::MatrixXd & jacobianDot(const MultiBody & mb, const MultiBodyConfig & mbc);
89
94 inline const Eigen::MatrixXd & jacobianDot() const noexcept
95 {
96 return jacDot_;
97 }
98
99 // safe version for python binding
100
104 const Eigen::MatrixXd & sJacobian(const MultiBody & mb, const MultiBodyConfig & mbc);
105
109 const Eigen::MatrixXd & sJacobianDot(const MultiBody & mb, const MultiBodyConfig & mbc);
110
111private:
112 void init(const rbd::MultiBody & mb);
113
114private:
115 Eigen::MatrixXd jac_;
116 Eigen::MatrixXd jacDot_;
117 Eigen::MatrixXd jacFull_;
118
119 std::vector<Jacobian> jacVec_;
120 double totalMass_;
121 std::vector<double> bodiesWeight_;
122};
123
127class RBDYN_DLLAPI CoMJacobian
128{
129public:
131
138 CoMJacobian(const MultiBody & mb, std::vector<double> weight);
139
147
149 const std::vector<double> & weight() const;
150
152 void weight(const MultiBody & mb, std::vector<double> w);
153
160 const Eigen::MatrixXd & jacobian(const MultiBody & mb, const MultiBodyConfig & mbc);
161
166 inline const Eigen::MatrixXd & jacobian() const noexcept
167 {
168 return jac_;
169 }
170
177 const Eigen::MatrixXd & jacobianDot(const MultiBody & mb, const MultiBodyConfig & mbc);
178
183 inline const Eigen::MatrixXd & jacobianDot() const noexcept
184 {
185 return jacDot_;
186 }
187
194 Eigen::Vector3d velocity(const MultiBody & mb, const MultiBodyConfig & mbc) const;
195
202 Eigen::Vector3d normalAcceleration(const MultiBody & mb, const MultiBodyConfig & mbc);
203
211 Eigen::Vector3d normalAcceleration(const MultiBody & mb,
212 const MultiBodyConfig & mbc,
213 const std::vector<sva::MotionVecd> & normalAccB) const;
214
215 // safe version for python binding
216
221
226 void sWeight(const MultiBody & mb, std::vector<double> w);
227
231 const Eigen::MatrixXd & sJacobian(const MultiBody & mb, const MultiBodyConfig & mbc);
232
236 const Eigen::MatrixXd & sJacobianDot(const MultiBody & mb, const MultiBodyConfig & mbc);
237
241 Eigen::Vector3d sVelocity(const MultiBody & mb, const MultiBodyConfig & mbc) const;
242
246 Eigen::Vector3d sNormalAcceleration(const MultiBody & mb, const MultiBodyConfig & mbc);
247
251 Eigen::Vector3d sNormalAcceleration(const MultiBody & mb,
252 const MultiBodyConfig & mbc,
253 const std::vector<sva::MotionVecd> & normalAccB) const;
254
255private:
256 void init(const rbd::MultiBody & mb);
257
258private:
259 Eigen::MatrixXd jac_;
260 Eigen::MatrixXd jacDot_;
261
262 std::vector<double> bodiesCoeff_;
263
265 std::vector<sva::PTransformd> bodiesCoM_;
266 std::vector<std::vector<int>> jointsSubBodies_;
267
268 // jacobian, jacobianDot computation buffer
269 std::vector<sva::PTransformd> bodiesCoMWorld_;
270 std::vector<sva::MotionVecd> bodiesCoMVelB_;
271 // store normal acceleration of each bodies when calling normal acceleration
272 std::vector<sva::MotionVecd> normalAcc_;
273
274 std::vector<double> weight_;
275};
276
277// safe version for python binding
278
284RBDYN_DLLAPI Eigen::Vector3d sComputeCoM(const MultiBody & mb, const MultiBodyConfig & mbc);
285
291RBDYN_DLLAPI Eigen::Vector3d sComputeCoMVelocity(const MultiBody & mb, const MultiBodyConfig & mbc);
292
298RBDYN_DLLAPI Eigen::Vector3d sComputeCoMAcceleration(const MultiBody & mb, const MultiBodyConfig & mbc);
299
300} // namespace rbd
Definition CoM.h:51
const Eigen::MatrixXd & sJacobian(const MultiBody &mb, const MultiBodyConfig &mbc)
const Eigen::MatrixXd & jacobian() const noexcept
Definition CoM.h:77
const Eigen::MatrixXd & jacobian(const MultiBody &mb, const MultiBodyConfig &mbc)
CoMJacobianDummy(const MultiBody &mb)
const Eigen::MatrixXd & sJacobianDot(const MultiBody &mb, const MultiBodyConfig &mbc)
const Eigen::MatrixXd & jacobianDot() const noexcept
Definition CoM.h:94
CoMJacobianDummy(const MultiBody &mb, std::vector< double > weight)
const Eigen::MatrixXd & jacobianDot(const MultiBody &mb, const MultiBodyConfig &mbc)
Definition CoM.h:128
void sWeight(const MultiBody &mb, std::vector< double > w)
const Eigen::MatrixXd & sJacobian(const MultiBody &mb, const MultiBodyConfig &mbc)
const Eigen::MatrixXd & jacobian(const MultiBody &mb, const MultiBodyConfig &mbc)
CoMJacobian(const MultiBody &mb, std::vector< double > weight)
void weight(const MultiBody &mb, std::vector< double > w)
Per bodies weight setter.
void updateInertialParameters(const MultiBody &mb)
const Eigen::MatrixXd & jacobianDot(const MultiBody &mb, const MultiBodyConfig &mbc)
Eigen::Vector3d sNormalAcceleration(const MultiBody &mb, const MultiBodyConfig &mbc)
CoMJacobian(const MultiBody &mb)
Eigen::Vector3d sVelocity(const MultiBody &mb, const MultiBodyConfig &mbc) const
Eigen::Vector3d velocity(const MultiBody &mb, const MultiBodyConfig &mbc) const
void sUpdateInertialParameters(const MultiBody &mb)
const Eigen::MatrixXd & jacobianDot() const noexcept
Definition CoM.h:183
Eigen::Vector3d normalAcceleration(const MultiBody &mb, const MultiBodyConfig &mbc)
Eigen::Vector3d normalAcceleration(const MultiBody &mb, const MultiBodyConfig &mbc, const std::vector< sva::MotionVecd > &normalAccB) const
const Eigen::MatrixXd & sJacobianDot(const MultiBody &mb, const MultiBodyConfig &mbc)
const Eigen::MatrixXd & jacobian() const noexcept
Definition CoM.h:166
Eigen::Vector3d sNormalAcceleration(const MultiBody &mb, const MultiBodyConfig &mbc, const std::vector< sva::MotionVecd > &normalAccB) const
const std::vector< double > & weight() const
Definition MultiBody.h:30
Definition common.h:21
RBDYN_DLLAPI Eigen::Vector3d sComputeCoM(const MultiBody &mb, const MultiBodyConfig &mbc)
RBDYN_DLLAPI Eigen::Vector3d sComputeCoMAcceleration(const MultiBody &mb, const MultiBodyConfig &mbc)
RBDYN_DLLAPI Eigen::Vector3d sComputeCoMVelocity(const MultiBody &mb, const MultiBodyConfig &mbc)
RBDYN_DLLAPI Eigen::Vector3d computeCoMAcceleration(const MultiBody &mb, const MultiBodyConfig &mbc)
RBDYN_DLLAPI Eigen::Vector3d computeCoM(const MultiBody &mb, const MultiBodyConfig &mbc)
RBDYN_DLLAPI Eigen::Vector3d computeCoMVelocity(const MultiBody &mb, const MultiBodyConfig &mbc)
Definition MultiBodyConfig.h:24