8 #include <boost/test/unit_test.hpp>
9 #include <boost/utility/binary.hpp>
13 BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
27 const double scaling_factor = 2.;
28 ConstraintType constraint_ref(jdata.
S), constraint_ref_shared(jdata.
S);
29 ScaledJointMotionSubspaceType scaled_constraint(constraint_ref_shared, scaling_factor);
31 BOOST_CHECK(constraint_ref.nv() == scaled_constraint.nv());
33 typedef typename JointModel::TangentVector_t TangentVector_t;
34 TangentVector_t
v = TangentVector_t::Random();
39 BOOST_CHECK(
m.isApprox(m_ref));
43 typename ScaledJointMotionSubspaceType::DenseBase
S =
M.act(scaled_constraint);
44 typename ScaledJointMotionSubspaceType::DenseBase S_ref =
45 scaling_factor *
M.act(constraint_ref);
47 BOOST_CHECK(
S.isApprox(S_ref));
51 typename ScaledJointMotionSubspaceType::DenseBase
S = scaled_constraint.matrix();
52 typename ScaledJointMotionSubspaceType::DenseBase S_ref =
53 scaling_factor * constraint_ref.matrix();
55 BOOST_CHECK(
S.isApprox(S_ref));
60 typename ScaledJointMotionSubspaceType::DenseBase
S =
v.cross(scaled_constraint);
61 typename ScaledJointMotionSubspaceType::DenseBase S_ref =
62 scaling_factor *
v.cross(constraint_ref);
64 BOOST_CHECK(
S.isApprox(S_ref));
69 const Eigen::DenseIndex
dim = 20;
71 Eigen::MatrixXd Fout = scaled_constraint.transpose() * Fin;
72 Eigen::MatrixXd Fout_ref = scaling_factor * (constraint_ref.transpose() * Fin);
73 BOOST_CHECK(Fout.isApprox(Fout_ref));
76 Eigen::MatrixXd Stf = (scaled_constraint.transpose() * force_in);
77 Eigen::MatrixXd Stf_ref = scaling_factor * (constraint_ref.transpose() * force_in);
78 BOOST_CHECK(Stf_ref.isApprox(Stf));
84 Eigen::MatrixXd YS =
Y * scaled_constraint;
85 Eigen::MatrixXd YS_ref = scaling_factor * (
Y * constraint_ref);
87 BOOST_CHECK(YS.isApprox(YS_ref));
94 template<
typename Jo
intModel>
123 typedef boost::variant<
132 template<
typename Jo
intModel>
140 const double scaling_factor = 1.;
141 const double offset = 0.;
148 JointModelMimicType jmodel_mimic(jmodel.
derived(), scaling_factor, offset);
149 JointDataMimicType jdata_mimic = jmodel_mimic.createData();
151 BOOST_CHECK(jmodel_mimic.nq() == 0);
152 BOOST_CHECK(jmodel_mimic.nv() == 0);
154 BOOST_CHECK(jmodel_mimic.idx_q() == jmodel.
idx_q());
155 BOOST_CHECK(jmodel_mimic.idx_v() == jmodel.
idx_v());
157 BOOST_CHECK(jmodel_mimic.idx_q() == 0);
158 BOOST_CHECK(jmodel_mimic.idx_v() == 0);
160 typedef typename JointModelMimicType::ConfigVector_t ConfigVectorType;
162 ConfigVectorType
q0 =
163 LieGroupType().randomConfiguration(-ConfigVectorType::Ones(), ConfigVectorType::Ones());
166 jmodel_mimic.calc(jdata_mimic,
q0);
168 BOOST_CHECK(((
SE3)jdata.
M).isApprox((
SE3)jdata_mimic.M()));
169 BOOST_CHECK(jdata.
S.matrix().isApprox(jdata_mimic.S.matrix()));
171 typedef typename JointModelMimicType::TangentVector_t TangentVectorType;
173 q0 = LieGroupType().randomConfiguration(-ConfigVectorType::Ones(), ConfigVectorType::Ones());
174 TangentVectorType
v0 = TangentVectorType::Random();
176 jmodel_mimic.calc(jdata_mimic,
q0,
v0);
178 BOOST_CHECK(((
SE3)jdata.
M).isApprox((
SE3)jdata_mimic.M()));
179 BOOST_CHECK(jdata.
S.matrix().isApprox(jdata_mimic.S.matrix()));
180 BOOST_CHECK(((
Motion)jdata.
v).isApprox((
Motion)jdata_mimic.v()));
186 template<
typename Jo
intModel>
215 typedef boost::variant<
226 typedef JointModelRX::ConfigVector_t ConfigVectorType;
227 double scaling = 1., offset = 0.;
229 ConfigVectorType
q0 = ConfigVectorType::Random();
232 BOOST_CHECK(
q0 ==
q1);
236 BOOST_CHECK(
q1 == ConfigVectorType::Constant(offset));
241 typedef JointModelRUBX::ConfigVector_t ConfigVectorType;
242 double scaling = 1., offset = 0.;
244 ConfigVectorType
q0 = ConfigVectorType::Random().normalized();
247 BOOST_CHECK(
q0.isApprox(
q1));
251 BOOST_CHECK(
q1 == ConfigVectorType(math::cos(offset), math::sin(offset)));
262 BOOST_CHECK(jmodel.
id() == jmodel_ref.
id());
263 BOOST_CHECK(jmodel.
idx_q() == jmodel_ref.
idx_q());
264 BOOST_CHECK(jmodel.
idx_v() == jmodel_ref.
idx_v());
269 BOOST_CHECK(jmodel_generic.id() == jmodel_ref.
id());
271 BOOST_AUTO_TEST_SUITE_END()