11 #include "utils/macros.hpp"
15 #include <boost/test/unit_test.hpp>
16 #include <boost/utility/binary.hpp>
20 BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
31 ForceSet F2(Eigen::Matrix<double, 3, 2>::Zero(), Eigen::Matrix<double, 3, 2>::Zero());
33 BOOST_CHECK_EQUAL(F.
matrix().col(10).norm(), 0.0);
34 BOOST_CHECK(std::isnan(F.
matrix()(0, 9)));
36 ForceSet F3(Eigen::Matrix<double, 3, 12>::Random(), Eigen::Matrix<double, 3, 12>::Random());
39 BOOST_CHECK((aXb.transpose().inverse() * F3.
matrix()).isApprox(F4.
matrix(), 1e-12));
48 (aXb.transpose().inverse() * F3.
matrix().block(0, 3, 6, 6)).isApprox(F36.
matrix(), 1e-12));
52 BOOST_CHECK((aXb.transpose().inverse() * F3.
matrix().block(0, 3, 6, 6))
53 .isApprox(F36full.
matrix().block(0, 3, 6, 6), 1e-12));
61 JointDataRX::Constraint_t
S;
65 BOOST_CHECK(F1.
matrix().isApprox(
Y.matrix().col(3), 1e-12));
67 ForceSet F2(Eigen::Matrix<double, 3, 9>::Random(), Eigen::Matrix<double, 3, 9>::Random());
68 Eigen::MatrixXd StF2 =
S.transpose() * F2.
block(5, 3).
matrix();
69 BOOST_CHECK(StF2.isApprox(
S.matrix().transpose() * F2.
matrix().block(0, 5, 6, 3), 1e-12));
72 template<
typename Jo
intModel>
75 BOOST_CHECK(jmodel.
nq() == nq_ref);
78 template<
typename Jo
intModel>
81 BOOST_CHECK(jmodel.
jmodel().nq() == nq_ref);
84 template<
typename Jo
intModel,
typename Constra
intDerived>
89 BOOST_CHECK(constraint.
nv() == jmodel.
nv());
92 template<
typename Jo
intModel,
typename Constra
intDerived>
97 BOOST_CHECK(constraint.
nv() == jmodel.
jmodel().nv());
100 template<
class Jo
intModel>
112 template<
class Jo
intModel>
127 template<
typename Jo
intModel>
133 typedef Eigen::Matrix<typename JointModel::Scalar, 6, Eigen::Dynamic>
Matrix6x;
136 typedef typename JointModel::ConfigVector_t ConfigVector_t;
145 model, ConfigVector_t::Constant(
model.nq, -1.), ConfigVector_t::Constant(
model.nq, 1.));
148 jmodel.
calc(jdata,
q);
150 ConstraintType constraint(jdata.
S);
153 BOOST_CHECK(constraint.cols() == constraint.nv());
154 BOOST_CHECK(constraint.rows() == 6);
156 typedef typename JointModel::TangentVector_t TangentVector_t;
157 TangentVector_t
v = TangentVector_t::Random(constraint.nv());
159 typename ConstraintType::DenseBase constraint_mat = constraint.matrix();
163 BOOST_CHECK(
m.isApprox(m_ref));
168 typename ConstraintType::DenseBase
S =
M.act(constraint);
169 typename ConstraintType::DenseBase S_ref(6, constraint.nv());
171 for (Eigen::DenseIndex k = 0; k < constraint.nv(); ++k)
173 typedef typename ConstraintType::DenseBase::ColXpr Vector6Like;
179 BOOST_CHECK(
S.isApprox(S_ref));
185 typename ConstraintType::DenseBase
S =
M.actInv(constraint);
186 typename ConstraintType::DenseBase S_ref(6, constraint.nv());
188 for (Eigen::DenseIndex k = 0; k < constraint.nv(); ++k)
190 typedef typename ConstraintType::DenseBase::ColXpr Vector6Like;
193 m_out =
M.actInv(m_in);
196 BOOST_CHECK(
S.isApprox(S_ref));
202 const SE3 Minv =
M.inverse();
204 typename ConstraintType::DenseBase S1_vice =
M.actInv(constraint);
205 typename ConstraintType::DenseBase S2_vice = Minv.act(constraint);
207 BOOST_CHECK(S1_vice.isApprox(S2_vice));
209 typename ConstraintType::DenseBase S1_versa =
M.act(constraint);
210 typename ConstraintType::DenseBase S2_versa = Minv.actInv(constraint);
212 BOOST_CHECK(S1_versa.isApprox(S2_versa));
219 typename ConstraintType::DenseBase
S =
v.cross(constraint);
220 typename ConstraintType::DenseBase S_ref(6, constraint.nv());
222 for (Eigen::DenseIndex k = 0; k < constraint.nv(); ++k)
224 typedef typename ConstraintType::DenseBase::ColXpr Vector6Like;
227 m_out =
v.cross(m_in);
229 BOOST_CHECK(
S.isApprox(S_ref));
234 const Eigen::DenseIndex
dim = 20;
236 Eigen::MatrixXd Fout = constraint.transpose() * Fin;
237 Eigen::MatrixXd Fout_ref = constraint_mat.transpose() * Fin;
238 BOOST_CHECK(Fout.isApprox(Fout_ref));
241 Eigen::MatrixXd Stf = (constraint.transpose() * force_in);
242 Eigen::MatrixXd Stf_ref = constraint_mat.transpose() * force_in.toVector();
243 BOOST_CHECK(Stf_ref.isApprox(Stf));
249 Eigen::MatrixXd YS =
Y * constraint;
250 Eigen::MatrixXd YS_ref =
Y.matrix() * constraint_mat;
251 BOOST_CHECK(YS.isApprox(YS_ref));
257 const Inertia::Matrix6 Y_mat =
Y.matrix();
258 Eigen::MatrixXd YS = Y_mat * constraint;
259 Eigen::MatrixXd YS_ref = Y_mat * constraint_mat;
260 BOOST_CHECK(YS.isApprox(YS_ref));
265 Eigen::MatrixXd StS = constraint.transpose() * constraint;
266 Eigen::MatrixXd StS_ref = constraint_mat.transpose() * constraint_mat;
267 BOOST_CHECK(StS.isApprox(StS_ref));
271 template<
typename Jo
intModel_>
274 template<
typename Jo
intModel_>
280 jmodel.setIndexes(0, 0, 0);
285 template<
typename Scalar,
int Options>
293 JointModel jmodel(Vector3::Random().normalized());
300 template<
typename Scalar,
int Options>
308 JointModel jmodel(Vector3::Random().normalized());
315 template<
typename Scalar,
int Options>
323 JointModel jmodel(Vector3::Random().normalized());
330 template<
typename Scalar,
int Options,
template<
typename,
int>
class JointCollection>
345 template<
typename Scalar,
int Options>
359 template<
typename Scalar,
int Options,
template<
typename,
int>
class JointCollection>
374 jmodel.setIndexes(0, 0, 0);
380 template<
typename Jo
intModel_>
396 template<
typename Scalar,
int Options,
int axis>
410 template<
typename Scalar,
int Options>
418 JointModel jmodel(Vector3::Random().normalized());
428 template<
typename Jo
intModel>
444 BOOST_AUTO_TEST_SUITE_END()