14 #include <boost/test/unit_test.hpp>
31 model.appendBodyToJoint(idx,
Y);
34 BOOST_AUTO_TEST_SUITE(JointTranslation)
41 const Vector3 displacement(Vector3::Random());
44 TransformTranslation Mtrans(displacement);
46 BOOST_CHECK(Mplain.
translation().isApprox(displacement));
47 BOOST_CHECK(Mplain.
rotation().isIdentity());
48 BOOST_CHECK((Mrand * Mplain).
isApprox(Mrand * Mtrans));
56 BOOST_CHECK(
M.act(mp).isApprox(
M.act(mp_dense)));
57 BOOST_CHECK(
M.actInv(mp).isApprox(
M.actInv(mp_dense)));
59 BOOST_CHECK(
v.cross(mp).isApprox(
v.cross(mp_dense)));
66 typedef Eigen::Matrix<double, 6, 1> Vector6;
67 typedef Eigen::Matrix<double, 7, 1> VectorFF;
70 Model modelTranslation, modelFreeflyer;
74 pos.translation() = SE3::LinearType(1., 0., 0.);
80 Data dataTranslation(modelTranslation);
81 Data dataFreeFlyer(modelFreeflyer);
83 Eigen::VectorXd
q = Eigen::VectorXd::Ones(modelTranslation.
nq);
85 qff << 1, 1, 1, 0, 0, 0, 1;
86 Eigen::VectorXd
v = Eigen::VectorXd::Ones(modelTranslation.
nv);
88 vff << 1, 1, 1, 0, 0, 0;
89 Eigen::VectorXd tauTranslation = Eigen::VectorXd::Ones(modelTranslation.
nv);
90 Eigen::VectorXd tauff(6);
91 tauff << 1, 1, 1, 0, 0, 0;
92 Eigen::VectorXd aTranslation = Eigen::VectorXd::Ones(modelTranslation.
nv);
93 Eigen::VectorXd aff(vff);
101 BOOST_CHECK(dataFreeFlyer.oMi[1].isApprox(dataTranslation.oMi[1]));
102 BOOST_CHECK(dataFreeFlyer.liMi[1].isApprox(dataTranslation.liMi[1]));
103 BOOST_CHECK(dataFreeFlyer.Ycrb[1].matrix().isApprox(dataTranslation.Ycrb[1].matrix()));
104 BOOST_CHECK(dataFreeFlyer.f[1].toVector().isApprox(dataTranslation.f[1].toVector()));
106 Eigen::VectorXd nle_expected_ff(3);
107 nle_expected_ff << dataFreeFlyer.
nle[0], dataFreeFlyer.
nle[1], dataFreeFlyer.
nle[2];
108 BOOST_CHECK(nle_expected_ff.isApprox(dataTranslation.
nle));
109 BOOST_CHECK(dataFreeFlyer.com[0].isApprox(dataTranslation.com[0]));
112 tauTranslation =
rnea(modelTranslation, dataTranslation,
q,
v, aTranslation);
113 tauff =
rnea(modelFreeflyer, dataFreeFlyer, qff, vff, aff);
116 tau_expected << tauff(0), tauff(1), tauff(2);
117 BOOST_CHECK(tauTranslation.isApprox(tau_expected));
120 Eigen::VectorXd aAbaTranslation =
122 Eigen::VectorXd aAbaFreeFlyer =
125 a_expected << aAbaFreeFlyer[0], aAbaFreeFlyer[1], aAbaFreeFlyer[2];
126 BOOST_CHECK(aAbaTranslation.isApprox(a_expected));
132 Eigen::Matrix<double, 3, 3> M_expected(dataFreeFlyer.
M.topLeftCorner<3, 3>());
134 BOOST_CHECK(dataTranslation.
M.isApprox(M_expected));
137 Eigen::Matrix<double, 6, Eigen::Dynamic> jacobian_translation;
138 jacobian_translation.resize(6, 3);
139 jacobian_translation.setZero();
140 Eigen::Matrix<double, 6, Eigen::Dynamic> jacobian_ff;
141 jacobian_ff.resize(6, 6);
142 jacobian_ff.setZero();
148 Eigen::Matrix<double, 6, 3> jacobian_expected;
149 jacobian_expected << jacobian_ff.col(0), jacobian_ff.col(1), jacobian_ff.col(2);
150 BOOST_CHECK(jacobian_translation.isApprox(jacobian_expected));
153 BOOST_AUTO_TEST_SUITE_END()