14 #include <boost/test/unit_test.hpp>
31 model.appendBodyToJoint(idx,
Y);
34 BOOST_AUTO_TEST_SUITE(JointPrismatic)
44 const double displacement = 0.2;
47 TransformX Mx(displacement);
50 BOOST_CHECK(Mplain.
rotation().isIdentity());
51 BOOST_CHECK((Mrand * Mplain).
isApprox(Mrand * Mx));
53 TransformY My(displacement);
55 BOOST_CHECK(Mplain.translation().isApprox(
Vector3(0, displacement, 0)));
56 BOOST_CHECK(Mplain.rotation().isIdentity());
57 BOOST_CHECK((Mrand * Mplain).
isApprox(Mrand * My));
59 TransformZ Mz(displacement);
61 BOOST_CHECK(Mplain.translation().isApprox(
Vector3(0, 0, displacement)));
62 BOOST_CHECK(Mplain.rotation().isIdentity());
63 BOOST_CHECK((Mrand * Mplain).
isApprox(Mrand * Mz));
71 BOOST_CHECK(
M.act(mp_x).isApprox(
M.act(mp_dense_x)));
72 BOOST_CHECK(
M.actInv(mp_x).isApprox(
M.actInv(mp_dense_x)));
74 BOOST_CHECK(
v.cross(mp_x).isApprox(
v.cross(mp_dense_x)));
79 BOOST_CHECK(
M.act(mp_y).isApprox(
M.act(mp_dense_y)));
80 BOOST_CHECK(
M.actInv(mp_y).isApprox(
M.actInv(mp_dense_y)));
82 BOOST_CHECK(
v.cross(mp_y).isApprox(
v.cross(mp_dense_y)));
87 BOOST_CHECK(
M.act(mp_z).isApprox(
M.act(mp_dense_z)));
88 BOOST_CHECK(
M.actInv(mp_z).isApprox(
M.actInv(mp_dense_z)));
90 BOOST_CHECK(
v.cross(mp_z).isApprox(
v.cross(mp_dense_z)));
107 Eigen::VectorXd
q(Eigen::VectorXd::Zero(1));
108 Eigen::VectorXd
q_dot(Eigen::VectorXd::Zero(1));
116 BOOST_CHECK(expected_configuration.
rotation().isApprox(joint_data.
M.rotation(), 1e-12));
117 BOOST_CHECK(expected_configuration.
translation().isApprox(joint_data.
M.translation(), 1e-12));
118 BOOST_CHECK(expected_v_J.toVector().isApprox(((
Motion)joint_data.
v).toVector(), 1e-12));
119 BOOST_CHECK(expected_c_J.isApprox((
Motion)joint_data.
c, 1e-12));
129 expected_v_J.linear() << 1., 0., 0.;
131 BOOST_CHECK(expected_configuration.
rotation().isApprox(joint_data.
M.rotation(), 1e-12));
132 BOOST_CHECK(expected_configuration.
translation().isApprox(joint_data.
M.translation(), 1e-12));
133 BOOST_CHECK(expected_v_J.toVector().isApprox(((
Motion)joint_data.
v).toVector(), 1e-12));
134 BOOST_CHECK(expected_c_J.isApprox((
Motion)joint_data.
c, 1e-12));
151 Eigen::VectorXd
q(Eigen::VectorXd::Zero(
model.nq));
152 Eigen::VectorXd
v(Eigen::VectorXd::Zero(
model.nv));
153 Eigen::VectorXd
a(Eigen::VectorXd::Zero(
model.nv));
157 Eigen::VectorXd tau_expected(Eigen::VectorXd::Zero(
model.nq));
160 BOOST_CHECK(tau_expected.isApprox(
data.tau, 1e-14));
163 q = Eigen::VectorXd::Ones(
model.nq);
164 v = Eigen::VectorXd::Ones(
model.nv);
165 a = Eigen::VectorXd::Ones(
model.nv);
170 BOOST_CHECK(tau_expected.isApprox(
data.tau, 1e-12));
173 v = Eigen::VectorXd::Ones(
model.nv);
174 a = Eigen::VectorXd::Ones(
model.nv);
179 BOOST_CHECK(tau_expected.isApprox(
data.tau, 1e-12));
197 Eigen::VectorXd
q(Eigen::VectorXd::Zero(
model.nq));
198 Eigen::MatrixXd M_expected(
model.nv,
model.nv);
203 BOOST_CHECK(M_expected.isApprox(
data.M, 1e-14));
205 q = Eigen::VectorXd::Ones(
model.nq);
209 BOOST_CHECK(M_expected.isApprox(
data.M, 1e-12));
215 BOOST_CHECK(M_expected.isApprox(
data.M, 1e-10));
218 BOOST_AUTO_TEST_SUITE_END()
220 BOOST_AUTO_TEST_SUITE(JointPrismaticUnaligned)
230 BOOST_CHECK(
M.act(mp).isApprox(
M.act(mp_dense)));
231 BOOST_CHECK(
M.actInv(mp).isApprox(
M.actInv(mp_dense)));
233 BOOST_CHECK(
v.cross(mp).isApprox(
v.cross(mp_dense)));
242 Eigen::Vector3d
axis;
243 axis << 1.0, 0.0, 0.0;
245 Model modelPX, modelPrismaticUnaligned;
249 pos.translation() = SE3::LinearType(1., 0., 0.);
254 addJointAndBody(modelPrismaticUnaligned, joint_model_PU, 0,
pos,
"prismatic-unaligned", inertia);
256 Data dataPX(modelPX);
257 Data dataPrismaticUnaligned(modelPrismaticUnaligned);
259 Eigen::VectorXd
q = Eigen::VectorXd::Ones(modelPX.
nq);
260 Eigen::VectorXd
v = Eigen::VectorXd::Ones(modelPX.
nv);
261 Eigen::VectorXd tauPX = Eigen::VectorXd::Ones(modelPX.
nv);
262 Eigen::VectorXd tauPrismaticUnaligned = Eigen::VectorXd::Ones(modelPrismaticUnaligned.
nv);
263 Eigen::VectorXd aPX = Eigen::VectorXd::Ones(modelPX.
nv);
264 Eigen::VectorXd aPrismaticUnaligned(aPX);
272 BOOST_CHECK(dataPrismaticUnaligned.oMi[1].isApprox(dataPX.oMi[1]));
273 BOOST_CHECK(dataPrismaticUnaligned.liMi[1].isApprox(dataPX.liMi[1]));
274 BOOST_CHECK(dataPrismaticUnaligned.Ycrb[1].matrix().isApprox(dataPX.Ycrb[1].matrix()));
275 BOOST_CHECK(dataPrismaticUnaligned.f[1].toVector().isApprox(dataPX.f[1].toVector()));
277 BOOST_CHECK(dataPrismaticUnaligned.
nle.isApprox(dataPX.
nle));
278 BOOST_CHECK(dataPrismaticUnaligned.com[0].isApprox(dataPX.com[0]));
281 tauPX =
rnea(modelPX, dataPX,
q,
v, aPX);
282 tauPrismaticUnaligned =
283 rnea(modelPrismaticUnaligned, dataPrismaticUnaligned,
q,
v, aPrismaticUnaligned);
285 BOOST_CHECK(tauPX.isApprox(tauPrismaticUnaligned));
289 Eigen::VectorXd aAbaPrismaticUnaligned =
aba(
290 modelPrismaticUnaligned, dataPrismaticUnaligned,
q,
v, tauPrismaticUnaligned,
293 BOOST_CHECK(aAbaPX.isApprox(aAbaPrismaticUnaligned));
299 BOOST_CHECK(dataPX.
M.isApprox(dataPrismaticUnaligned.
M));
302 Eigen::Matrix<double, 6, Eigen::Dynamic> jacobianPX;
303 jacobianPX.resize(6, 1);
304 jacobianPX.setZero();
305 Eigen::Matrix<double, 6, Eigen::Dynamic> jacobianPrismaticUnaligned;
306 jacobianPrismaticUnaligned.resize(6, 1);
307 jacobianPrismaticUnaligned.setZero();
312 modelPrismaticUnaligned, dataPrismaticUnaligned, 1,
LOCAL, jacobianPrismaticUnaligned);
314 BOOST_CHECK(jacobianPX.isApprox(jacobianPrismaticUnaligned));
317 BOOST_AUTO_TEST_SUITE_END()