14 #include <boost/test/unit_test.hpp>
31 model.appendBodyToJoint(idx,
Y);
34 BOOST_AUTO_TEST_SUITE(JointPlanar)
44 BOOST_CHECK(
M.act(mp).isApprox(
M.act(mp_dense)));
45 BOOST_CHECK(
M.actInv(mp).isApprox(
M.actInv(mp_dense)));
47 BOOST_CHECK(
v.cross(mp).isApprox(
v.cross(mp_dense)));
54 typedef Eigen::Matrix<double, 6, 1> Vector6;
55 typedef Eigen::Matrix<double, 4, 1> VectorPl;
56 typedef Eigen::Matrix<double, 7, 1> VectorFF;
59 Model modelPlanar, modelFreeflyer;
63 pos.translation() = SE3::LinearType(1., 0., 0.);
68 Data dataPlanar(modelPlanar);
69 Data dataFreeFlyer(modelFreeflyer);
74 qff << 1, 1, 0, 0, 0, sqrt(2) / 2, sqrt(2) / 2;
75 Eigen::VectorXd
v = Eigen::VectorXd::Ones(modelPlanar.
nv);
77 vff << 1, 1, 0, 0, 0, 1;
78 Eigen::VectorXd tauPlanar = Eigen::VectorXd::Ones(modelPlanar.
nv);
79 Eigen::VectorXd tauff = Eigen::VectorXd::Ones(modelFreeflyer.
nv);
80 Eigen::VectorXd aPlanar = Eigen::VectorXd::Ones(modelPlanar.
nv);
81 Eigen::VectorXd aff(vff);
89 BOOST_CHECK(dataFreeFlyer.oMi[1].isApprox(dataPlanar.oMi[1]));
90 BOOST_CHECK(dataFreeFlyer.liMi[1].isApprox(dataPlanar.liMi[1]));
91 BOOST_CHECK(dataFreeFlyer.Ycrb[1].matrix().isApprox(dataPlanar.Ycrb[1].matrix()));
92 BOOST_CHECK(dataFreeFlyer.f[1].toVector().isApprox(dataPlanar.f[1].toVector()));
94 Eigen::VectorXd nle_expected_ff(3);
95 nle_expected_ff << dataFreeFlyer.
nle[0], dataFreeFlyer.
nle[1], dataFreeFlyer.
nle[5];
96 BOOST_CHECK(nle_expected_ff.isApprox(dataPlanar.
nle));
97 BOOST_CHECK(dataFreeFlyer.com[0].isApprox(dataPlanar.com[0]));
100 tauPlanar =
rnea(modelPlanar, dataPlanar,
q,
v, aPlanar);
101 tauff =
rnea(modelFreeflyer, dataFreeFlyer, qff, vff, aff);
104 tau_expected << tauff(0), tauff(1), tauff(5);
105 BOOST_CHECK(tauPlanar.isApprox(tau_expected));
109 Eigen::VectorXd aAbaFreeFlyer =
112 a_expected << aAbaFreeFlyer[0], aAbaFreeFlyer[1], aAbaFreeFlyer[5];
113 BOOST_CHECK(aAbaPlanar.isApprox(a_expected));
119 Eigen::Matrix<double, 3, 3> M_expected;
120 M_expected.block<2, 2>(0, 0) = dataFreeFlyer.
M.block<2, 2>(0, 0);
121 M_expected.block<1, 2>(2, 0) = dataFreeFlyer.
M.block<1, 2>(5, 0);
122 M_expected.block<2, 1>(0, 2) = dataFreeFlyer.
M.col(5).head<2>();
123 M_expected.block<1, 1>(2, 2) = dataFreeFlyer.
M.col(5).tail<1>();
125 BOOST_CHECK(dataPlanar.
M.isApprox(M_expected));
128 Eigen::Matrix<double, 6, Eigen::Dynamic> jacobian_planar;
129 jacobian_planar.resize(6, 3);
130 jacobian_planar.setZero();
131 Eigen::Matrix<double, 6, Eigen::Dynamic> jacobian_ff;
132 jacobian_ff.resize(6, 6);
133 jacobian_ff.setZero();
139 Eigen::Matrix<double, 6, 3> jacobian_expected;
140 jacobian_expected << jacobian_ff.col(0), jacobian_ff.col(1), jacobian_ff.col(5);
142 BOOST_CHECK(jacobian_planar.isApprox(jacobian_expected));
145 BOOST_AUTO_TEST_SUITE_END()