Go to the documentation of this file.
18 #include <boost/test/unit_test.hpp>
19 #include <boost/utility/binary.hpp>
21 template<
typename Jo
intModel>
25 const std::string & parent_name,
26 const std::string &
name,
28 bool setRandomLimits =
true)
31 typedef typename JointModel::ConfigVector_t CV;
32 typedef typename JointModel::TangentVector_t TV;
39 TV::Random() + TV::Constant(1), TV::Random() + TV::Constant(1),
40 CV::Random() - CV::Constant(1), CV::Random() + CV::Constant(1));
44 model.addJointFrame(idx);
50 BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
56 const std::string parent_name =
model.names.back();
57 const std::string
joint_name =
"ee_spherical_joint";
62 model.lowerPositionLimit.head<7>().
fill(-1.);
63 model.upperPositionLimit.head<7>().
fill(1.);
66 Eigen::VectorXd
v = Eigen::VectorXd::Random(
model.nv);
67 Eigen::VectorXd
a = Eigen::VectorXd::Random(
model.nv);
70 dhdot_da(6,
model.nv);
72 model,
data,
q,
v,
a, dh_dq, dhdot_dq, dhdot_dv, dhdot_da);
75 for (
size_t k = 0; k < (size_t)
model.njoints; ++k)
77 BOOST_CHECK(
data.oMi[k].isApprox(data_ref.oMi[k]));
78 BOOST_CHECK(
data.oYcrb[k].isApprox(data_ref.oYcrb[k]));
80 BOOST_CHECK(dhdot_da.isApprox(data_ref.
Ag));
83 for (
size_t k = 1; k < (size_t)
model.njoints; ++k)
85 BOOST_CHECK(
data.v[k].isApprox(data_ref.v[k]));
86 BOOST_CHECK(
data.ov[k].isApprox(
data.oMi[k].act(data_ref.v[k])));
87 BOOST_CHECK(
data.oa[k].isApprox(
data.oMi[k].act(data_ref.a[k])));
88 BOOST_CHECK(
data.oh[k].isApprox(
data.oMi[k].act(data_ref.h[k])));
91 BOOST_CHECK(
data.mass[0] == data_ref.
mass[0]);
92 BOOST_CHECK(
data.com[0].isApprox(data_ref.com[0]));
94 BOOST_CHECK(
data.oh[0].isApprox(data_ref.h[0]));
95 BOOST_CHECK(
data.of[0].isApprox(data_ref.f[0]));
97 BOOST_CHECK(
data.hg.isApprox(data_ref.
hg));
98 BOOST_CHECK(
data.dhg.isApprox(data_ref.
dhg));
99 BOOST_CHECK(
data.Ag.isApprox(data_ref.
Ag));
103 const double eps = 1e-8;
107 BOOST_CHECK(
data.hg.isApprox(data_ref.
hg));
110 Eigen::VectorXd q_plus(
model.nq, 1);
111 Eigen::VectorXd v_eps(
model.nv, 1);
116 for (Eigen::DenseIndex k = 0; k <
model.nv; ++k)
124 dhdot_dq_fd.col(k) = (dhg_plus - dhg).toVector() /
eps;
125 dh_dq_fd.col(k) = (hg_plus - hg).toVector() /
eps;
129 BOOST_CHECK(dhdot_dq.isApprox(dhdot_dq_fd, sqrt(
eps)));
130 BOOST_CHECK(dh_dq.isApprox(dh_dq_fd, sqrt(
eps)));
132 Eigen::VectorXd v_plus(
v);
135 for (Eigen::DenseIndex k = 0; k <
model.nv; ++k)
141 dhdot_dv_fd.col(k) = (dhg_plus - dhg).toVector() /
eps;
146 BOOST_CHECK(dhdot_dv.isApprox(dhdot_dv_fd, sqrt(
eps)));
149 Eigen::VectorXd a_plus(
a);
152 for (Eigen::DenseIndex k = 0; k <
model.nv; ++k)
158 dhdot_da_fd.col(k) = (dhg_plus - dhg).toVector() /
eps;
163 BOOST_CHECK(dhdot_da.isApprox(dhdot_da_fd, sqrt(
eps)));
166 BOOST_CHECK(
data.dAdv.isApprox(data_ref.
dAdv));
167 BOOST_CHECK(
data.dAdq.isApprox(data_ref.
dAdq));
168 BOOST_CHECK(
data.J.isApprox(data_ref.
J));
169 BOOST_CHECK(
data.dJ.isApprox(data_ref.
dJ));
170 BOOST_CHECK(
data.dVdq.isApprox(data_ref.
dVdq));
173 BOOST_CHECK(
data.Ag.isApprox(data_ref.
Ag));
182 model.lowerPositionLimit.head<7>().
fill(-1.);
183 model.upperPositionLimit.head<7>().
fill(1.);
186 Eigen::VectorXd
v = Eigen::VectorXd::Random(
model.nv);
187 Eigen::VectorXd
a = Eigen::VectorXd::Random(
model.nv);
190 dhdot_da(6,
model.nv);
192 dhdot_dv_ref(6,
model.nv), dhdot_da_ref(6,
model.nv);
195 model, data_ref,
q,
v,
a, dh_dq_ref, dhdot_dq_ref, dhdot_dv_ref, dhdot_da_ref);
200 BOOST_CHECK(
data.J.isApprox(data_ref.
J));
204 BOOST_CHECK(
data.oYcrb[k].isApprox(data_ref.oYcrb[k]));
208 BOOST_CHECK(force.isApprox(force_ref));
211 BOOST_CHECK(
data.com[0].isApprox(data_ref.com[0]));
213 BOOST_CHECK(
data.hg.isApprox(data_ref.
hg));
214 BOOST_CHECK(
data.dhg.isApprox(data_ref.
dhg));
216 BOOST_CHECK(
data.Fcrb[0].isApprox(data_ref.
dFdq));
217 BOOST_CHECK(
data.dFdv.isApprox(data_ref.
dFdv));
218 BOOST_CHECK(
data.dFda.isApprox(data_ref.
dFda));
219 BOOST_CHECK(dh_dq.isApprox(dh_dq_ref));
220 BOOST_CHECK(dhdot_dq.isApprox(dhdot_dq_ref));
221 BOOST_CHECK(dhdot_dv.isApprox(dhdot_dv_ref));
222 BOOST_CHECK(dhdot_da.isApprox(dhdot_da_ref));
231 model.lowerPositionLimit.head<7>().
fill(-1.);
232 model.upperPositionLimit.head<7>().
fill(1.);
235 Eigen::VectorXd
v = Eigen::VectorXd::Random(
model.nv);
236 Eigen::VectorXd
a = Eigen::VectorXd::Random(
model.nv);
239 dhdot_da(6,
model.nv);
241 dhdot_dv_ref(6,
model.nv), dhdot_da_ref(6,
model.nv);
244 model, data_ref,
q,
v,
a, dh_dq_ref, dhdot_dq_ref, dhdot_dv_ref, dhdot_da_ref);
251 BOOST_CHECK(
data.J.isApprox(data_ref.J));
252 BOOST_CHECK(
data.dVdq.isApprox(data_rnea.
dVdq));
253 BOOST_CHECK(
data.dAdq.isApprox(data_rnea.
dAdq));
254 BOOST_CHECK(
data.dAdv.isApprox(data_rnea.
dAdv));
255 BOOST_CHECK(
data.dFdq.isApprox(data_rnea.
dFdq));
256 BOOST_CHECK(
data.dFdv.isApprox(data_rnea.
dFdv));
257 BOOST_CHECK(
data.dFda.isApprox(data_rnea.
dFda));
261 BOOST_CHECK(
data.oYcrb[k].isApprox(data_ref.oYcrb[k]));
262 BOOST_CHECK(
data.oh[k].isApprox(data_ref.oh[k]));
266 BOOST_CHECK(force.isApprox(force_ref));
269 BOOST_CHECK(
data.com[0].isApprox(data_ref.com[0]));
271 BOOST_CHECK(
data.hg.isApprox(data_ref.hg));
272 BOOST_CHECK(
data.dhg.isApprox(data_ref.dhg));
274 BOOST_CHECK(
data.Fcrb[0].isApprox(data_ref.dFdq));
275 BOOST_CHECK(
data.dFdv.isApprox(data_ref.dFdv));
276 BOOST_CHECK(
data.dFda.isApprox(data_ref.dFda));
277 BOOST_CHECK(dh_dq.isApprox(dh_dq_ref));
278 BOOST_CHECK(dhdot_dq.isApprox(dhdot_dq_ref));
279 BOOST_CHECK(dhdot_dv.isApprox(dhdot_dv_ref));
280 BOOST_CHECK(dhdot_da.isApprox(dhdot_da_ref));
283 BOOST_AUTO_TEST_SUITE_END()
Matrix6x dFdq
Variation of the forceset with respect to the joint configuration.
void computeRNEADerivatives(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType1 > &v, const Eigen::MatrixBase< TangentVectorType2 > &a, const Eigen::MatrixBase< MatrixType1 > &rnea_partial_dq, const Eigen::MatrixBase< MatrixType2 > &rnea_partial_dv, const Eigen::MatrixBase< MatrixType3 > &rnea_partial_da)
Computes the partial derivatives of the Recursive Newton Euler Algorithms with respect to the joint c...
Matrix6x dAdv
Variation of the spatial acceleration set with respect to the joint velocity.
std::vector< Scalar > mass
Vector of subtree mass. In other words, mass[j] is the mass of the subtree supported by joint ....
Force dhg
Centroidal momentum time derivative.
static void addJointAndBody(pinocchio::Model &model, const pinocchio::JointModelBase< JointModel > &joint, const std::string &parent_name, const std::string &name, const pinocchio::SE3 placement=pinocchio::SE3::Random(), bool setRandomLimits=true)
Matrix6x dJ
Derivative of the Jacobian with respect to the time.
std::string name(const LieGroupGenericTpl< LieGroupCollection > &lg)
Visit a LieGroupVariant to get the name of it.
Matrix6x dFdv
Variation of the forceset with respect to the joint velocity.
void humanoidRandom(ModelTpl< Scalar, Options, JointCollectionTpl > &model, bool usingFF=true)
Create a humanoid kinematic tree with 6-DOF limbs and random joint placements.
Matrix6x dFda
Variation of the forceset with respect to the joint acceleration.
void randomConfiguration(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ConfigVectorIn1 > &lowerLimits, const Eigen::MatrixBase< ConfigVectorIn2 > &upperLimits, const Eigen::MatrixBase< ReturnType > &qout)
Generate a configuration vector uniformly sampled among provided limits.
BOOST_AUTO_TEST_CASE(test_centroidal_derivatives)
pinocchio::JointIndex JointIndex
const MotionDense< Motion2 > const SE3Tpl< SE3Scalar, SE3Options > & placement
const DataTpl< Scalar, Options, JointCollectionTpl >::Matrix6x & computeCentroidalMap(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q)
Computes the Centroidal Momentum Matrix.
void integrate(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType > &v, const Eigen::MatrixBase< ReturnType > &qout)
Integrate a configuration vector for the specified model for a tangent vector during one unit time.
const DataTpl< Scalar, Options, JointCollectionTpl >::Matrix6x & ccrba(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType > &v)
Computes the Centroidal Momentum Matrix, the Composite Ridig Body Inertia as well as the centroidal m...
static InertiaTpl Random()
const DataTpl< Scalar, Options, JointCollectionTpl >::Force & computeCentroidalMomentumTimeVariation(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data)
Computes the Centroidal momemtum and its time derivatives, a.k.a. the total momenta of the system and...
Matrix6x Ag
Centroidal Momentum Matrix.
Matrix6x J
Jacobian of joint placements.
void getCentroidalDynamicsDerivatives(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< Matrix6xLike1 > &dh_dq, const Eigen::MatrixBase< Matrix6xLike1 > &dhdot_dq, const Eigen::MatrixBase< Matrix6xLike2 > &dhdot_dv, const Eigen::MatrixBase< Matrix6xLike3 > &dhdot_da)
Retrive the analytical derivatives of the centroidal dynamics from the RNEA derivatives....
void computeABADerivatives(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType1 > &v, const Eigen::MatrixBase< TangentVectorType2 > &tau, const Eigen::MatrixBase< MatrixType1 > &aba_partial_dq, const Eigen::MatrixBase< MatrixType2 > &aba_partial_dv, const Eigen::MatrixBase< MatrixType3 > &aba_partial_dtau)
The derivatives of the Articulated-Body algorithm.
const DataTpl< Scalar, Options, JointCollectionTpl >::TangentVectorType & rnea(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType1 > &v, const Eigen::MatrixBase< TangentVectorType2 > &a)
The Recursive Newton-Euler algorithm. It computes the inverse dynamics, aka the joint torques accordi...
Force hg
Centroidal momentum quantity.
Eigen::Matrix< Scalar, 6, Eigen::Dynamic, Options > Matrix6x
The 6d jacobian type (temporary)
Matrix6x dVdq
Variation of the spatial velocity set with respect to the joint configuration.
void computeCentroidalDynamicsDerivatives(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType1 > &v, const Eigen::MatrixBase< TangentVectorType2 > &a, const Eigen::MatrixBase< Matrix6xLike0 > &dh_dq, const Eigen::MatrixBase< Matrix6xLike1 > &dhdot_dq, const Eigen::MatrixBase< Matrix6xLike2 > &dhdot_dv, const Eigen::MatrixBase< Matrix6xLike3 > &dhdot_da)
Computes the analytical derivatives of the centroidal dynamics with respect to the joint configuratio...
JointCollectionTpl & model
Main pinocchio namespace.
Matrix6x dAdq
Variation of the spatial acceleration set with respect to the joint configuration.
pinocchio
Author(s):
autogenerated on Fri Nov 1 2024 02:41:39