19 #include <boost/test/unit_test.hpp>
20 #include <boost/utility/binary.hpp>
24 BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
34 BOOST_CHECK(subtree.size() == 6);
39 for (
size_t i = 0;
i < children.size(); ++
i)
45 for (
size_t i = 1;
i < subtree.size(); ++
i)
47 BOOST_CHECK(
model.parents[subtree[
i]] == subtree[
i - 1]);
70 BOOST_CHECK_EQUAL(
i,
model.getFrameId(
model.frames[
i].name));
72 BOOST_CHECK_EQUAL(
model.nframes,
model.getFrameId(
"NOT_A_FRAME"));
80 BOOST_CHECK(
model.supports[0] == support0_ref);
88 size_t current_id = support.size() - 2;
92 BOOST_CHECK(
parent_id == support[current_id]);
128 BOOST_CHECK(
model.cast<
double>() ==
model.cast<
double>());
129 BOOST_CHECK(
model.cast<
double>().cast<
long double>() ==
model.cast<
long double>());
143 for (
size_t k = 0; k < 20; ++k)
145 models.push_back(
Model());
148 BOOST_CHECK(
model == models.back());
152 #ifdef PINOCCHIO_WITH_HPP_FCL
156 std::string operator()(
const std::string &
n)
166 AddPrefix(
const char * _p)
178 buildModels::manipulatorGeometries(
manipulator, geomManipulator);
181 AddPrefix addManipulatorPrefix(
"manipulator/");
184 addManipulatorPrefix);
187 addManipulatorPrefix);
192 buildModels::humanoidGeometries(
humanoid, geomHumanoid);
195 AddPrefix addHumanoidPrefix(
"humanoid/");
207 humanoid.referenceConfigurations.insert(std::make_pair(
"common_key", humanoid_config_vector));
209 std::make_pair(
"common_key", manipulator_config_vector));
213 humanoid.referenceConfigurations.insert(std::make_pair(
"humanoid_key", humanoid_config_vector));
215 std::make_pair(
"manipulator_key", manipulator_config_vector));
232 BOOST_CHECK(
model1.referenceConfigurations.size() == 3);
233 for (
typename ConfigVectorMap::const_iterator config_it =
model1.referenceConfigurations.begin();
234 config_it !=
model1.referenceConfigurations.end(); ++config_it)
236 const std::string & config_name = config_it->first;
239 typename ConfigVectorMap::const_iterator humanoid_config =
240 humanoid.referenceConfigurations.find(config_name);
241 typename ConfigVectorMap::const_iterator manipulator_config =
242 manipulator.referenceConfigurations.find(config_name);
247 humanoid_config !=
humanoid.referenceConfigurations.end()
253 joint_model_humanoid.jointConfigSelector(humanoid_config->second)
254 == joint_model1.jointConfigSelector(config_vector));
258 manipulator_config !=
manipulator.referenceConfigurations.end()
264 joint_model_manipulator.jointConfigSelector(manipulator_config->second)
265 == joint_model1.jointConfigSelector(config_vector));
271 joint_model1.jointConfigSelector(neutral_config_vector)
272 == joint_model1.jointConfigSelector(config_vector));
283 BOOST_CHECK(
model1 == model3);
284 BOOST_CHECK(
model2 == model3);
288 BOOST_CHECK(
model1.check(data1));
290 BOOST_TEST_MESSAGE(
model1);
297 "humanoid/add_manipulator",
humanoid.getJointId(
"humanoid/chest2_joint"),
304 neutral_config_vector.resize(
model.nq);
307 BOOST_CHECK(
model.referenceConfigurations.size() == 3);
308 for (
typename ConfigVectorMap::const_iterator config_it =
model.referenceConfigurations.begin();
309 config_it !=
model.referenceConfigurations.end(); ++config_it)
311 const std::string & config_name = config_it->first;
314 typename ConfigVectorMap::const_iterator humanoid_config =
315 humanoid.referenceConfigurations.find(config_name);
316 typename ConfigVectorMap::const_iterator manipulator_config =
317 manipulator.referenceConfigurations.find(config_name);
322 humanoid_config !=
humanoid.referenceConfigurations.end()
328 joint_model_humanoid.jointConfigSelector(humanoid_config->second)
329 == joint_model.jointConfigSelector(config_vector));
333 manipulator_config !=
manipulator.referenceConfigurations.end()
339 joint_model_manipulator.jointConfigSelector(manipulator_config->second)
340 == joint_model.jointConfigSelector(config_vector));
346 joint_model.jointConfigSelector(neutral_config_vector)
347 == joint_model.jointConfigSelector(config_vector));
358 BOOST_CHECK(
model == model3);
359 BOOST_CHECK(
model2 == model3);
362 BOOST_TEST_MESSAGE(
model);
369 model.getJointId(
"humanoid/chest2_joint"),
370 model.parents[
model.getJointId(
"manipulator/shoulder1_joint")]);
378 BOOST_TEST_MESSAGE(
"Checking joint " << jid <<
" " <<
model.names[jid]);
381 BOOST_CHECK_EQUAL(
model.inertias[jid],
humanoid.inertias[jid]);
384 model.inertias[jid].isApprox(
386 model.inertias[jid] <<
" != "
389 BOOST_CHECK_EQUAL(
model.jointPlacements[jid],
humanoid.jointPlacements[jid]);
393 BOOST_TEST_MESSAGE(
"Checking joint " << hnj - 1 + jid <<
" " <<
model.names[hnj + jid]);
395 BOOST_CHECK_EQUAL(
model.inertias[hnj - 1 + jid],
manipulator.inertias[jid]);
398 model.jointPlacements[hnj - 1 + jid], aMb *
manipulator.jointPlacements[jid]);
400 BOOST_CHECK_EQUAL(
model.jointPlacements[hnj - 1 + jid],
manipulator.jointPlacements[jid]);
409 BOOST_CHECK_EQUAL(
parent.name, nparent.name);
418 if (
frame.parentFrame > 0)
420 BOOST_CHECK_EQUAL(
parent.name, nparent.name);
426 Inertia inertia(2., Eigen::Vector3d(0.1, 0.1, 0.1), Eigen::Matrix3d::Identity());
428 humanoid.addFrame(additional_frame);
431 double total_mass = mass_manipulator + mass_humanoid;
454 Model model5, gripperModel;
459 pos.translation() = SE3::LinearType(0.1, 0., 0.);
463 pos.translation() = SE3::LinearType(-0.1, 0., 0.);
477 jidG = gripperModel.
getJointId(
"right_finger");
486 Model humanoid_model;
489 static const std::vector<JointIndex> empty_index_vector;
495 std::pair<std::string, Eigen::VectorXd>(
"neutral",
neutral(humanoid_model)));
497 Model humanoid_copy_model =
498 buildReducedModel(humanoid_model, empty_index_vector, reference_config_humanoid);
500 BOOST_CHECK(humanoid_copy_model.
names == humanoid_model.
names);
501 BOOST_CHECK(humanoid_copy_model.
joints == humanoid_model.
joints);
502 BOOST_CHECK(humanoid_copy_model == humanoid_model);
506 const std::vector<JointIndex> empty_joints_to_lock;
508 const Model reduced_humanoid_model =
509 buildReducedModel(humanoid_model, empty_joints_to_lock, reference_config_humanoid);
510 BOOST_CHECK(reduced_humanoid_model.
njoints == humanoid_model.
njoints);
511 BOOST_CHECK(reduced_humanoid_model.
frames == humanoid_model.
frames);
513 BOOST_CHECK(reduced_humanoid_model.
joints == humanoid_model.
joints);
524 Model humanoid_model;
527 static const std::vector<JointIndex> empty_index_vector;
533 std::pair<std::string, Eigen::VectorXd>(
"neutral",
neutral(humanoid_model)));
535 Model humanoid_copy_model =
536 buildReducedModel(humanoid_model, empty_index_vector, reference_config_humanoid);
538 BOOST_CHECK(humanoid_copy_model.
names == humanoid_model.
names);
539 BOOST_CHECK(humanoid_copy_model.
joints == humanoid_model.
joints);
540 BOOST_CHECK(humanoid_copy_model == humanoid_model);
544 std::vector<JointIndex> joints_to_lock;
545 const std::string joint1_to_lock =
"rarm_shoulder2_joint";
546 joints_to_lock.push_back(humanoid_model.
getJointId(joint1_to_lock));
547 const std::string joint2_to_lock =
"larm_shoulder2_joint";
548 joints_to_lock.push_back(humanoid_model.
getJointId(joint2_to_lock));
550 Model reduced_humanoid_model =
553 reduced_humanoid_model.
njoints == humanoid_model.
njoints - (
int)joints_to_lock.size());
555 BOOST_CHECK(reduced_humanoid_model != humanoid_model);
557 Model reduced_humanoid_model_other_signature;
559 humanoid_model, joints_to_lock, reference_config_humanoid,
560 reduced_humanoid_model_other_signature);
561 BOOST_CHECK(reduced_humanoid_model == reduced_humanoid_model_other_signature);
564 Data data(humanoid_model), reduced_data(reduced_humanoid_model);
565 Eigen::VectorXd
q = reference_config_humanoid;
566 Eigen::VectorXd reduced_q(reduced_humanoid_model.
nq);
573 reduced_humanoid_model.
joints[
joint_id].jointConfigSelector(reduced_q) =
574 humanoid_model.
joints[reference_joint_id].jointConfigSelector(
q);
578 neutral(reduced_humanoid_model)));
586 switch (reduced_frame.
type)
599 BOOST_CHECK(
data.oMf[humanoid_frame_id].isApprox(reduced_data.oMf[
frame_id]));
604 false,
"The frame " << reduced_frame.
name <<
" is not presend in the humanoid_model");
611 BOOST_CHECK(
data.oMf[humanoid_frame_id].isApprox(reduced_data.oMf[
frame_id]));
622 VectorOfModels models;
623 for (
size_t k = 0; k < 100; ++k)
625 models.push_back(
Model());
630 #ifdef PINOCCHIO_WITH_HPP_FCL
633 Model humanoid_model;
641 buildModels::humanoidGeometries(humanoid_model, humanoid_geometry);
643 static const std::vector<JointIndex> empty_index_vector;
645 Model humanoid_copy_model;
648 humanoid_model, humanoid_geometry, empty_index_vector, reference_config_humanoid,
649 humanoid_copy_model, humanoid_copy_geometry);
651 BOOST_CHECK(humanoid_copy_model == humanoid_model);
652 BOOST_CHECK(humanoid_copy_geometry == humanoid_geometry);
654 std::vector<JointIndex> joints_to_lock;
655 const std::string joint1_to_lock =
"rarm_shoulder2_joint";
656 joints_to_lock.push_back(humanoid_model.
getJointId(joint1_to_lock));
657 const std::string joint2_to_lock =
"larm_shoulder2_joint";
658 joints_to_lock.push_back(humanoid_model.
getJointId(joint2_to_lock));
660 Model reduced_humanoid_model;
663 humanoid_model, humanoid_geometry, joints_to_lock, reference_config_humanoid,
664 reduced_humanoid_model, reduced_humanoid_geometry);
666 BOOST_CHECK(reduced_humanoid_geometry.
ngeoms == humanoid_geometry.
ngeoms);
675 BOOST_CHECK_EQUAL(go1.
name, go2.
name);
688 Data data(humanoid_model), reduced_data(reduced_humanoid_model);
689 const Eigen::VectorXd
q = reference_config_humanoid;
690 Eigen::VectorXd reduced_q(reduced_humanoid_model.
nq);
697 reduced_humanoid_model.
joints[
joint_id].jointConfigSelector(reduced_q) =
698 humanoid_model.
joints[reference_joint_id].jointConfigSelector(
q);
707 switch (reduced_frame.
type)
720 BOOST_CHECK(
data.oMf[humanoid_frame_id].isApprox(reduced_data.oMf[
frame_id]));
725 false,
"The frame " << reduced_frame.
name <<
" is not presend in the humanoid_model");
732 BOOST_CHECK(
data.oMf[humanoid_frame_id].isApprox(reduced_data.oMf[
frame_id]));
742 reduced_humanoid_model, reduced_data, reduced_humanoid_geometry, reduded_geom_data);
744 BOOST_CHECK(
geom_data.oMg.size() == reduded_geom_data.oMg.size());
747 BOOST_CHECK(
geom_data.oMg[
i].isApprox(reduded_geom_data.oMg[
i]));
751 std::vector<GeometryModel> full_geometry_models;
752 full_geometry_models.push_back(humanoid_geometry);
753 full_geometry_models.push_back(humanoid_geometry);
754 full_geometry_models.push_back(humanoid_geometry);
756 std::vector<GeometryModel> reduced_geometry_models;
758 Model reduced_humanoid_model_other_sig;
760 humanoid_model, full_geometry_models, joints_to_lock, reference_config_humanoid,
761 reduced_humanoid_model_other_sig, reduced_geometry_models);
763 BOOST_CHECK(reduced_geometry_models[0] == reduced_humanoid_geometry);
764 BOOST_CHECK(reduced_geometry_models[1] == reduced_humanoid_geometry);
765 BOOST_CHECK(reduced_geometry_models[2] == reduced_humanoid_geometry);
767 #endif // PINOCCHIO_WITH_HPP_FCL
775 size_t id_ancestor1, id_ancestor2;
777 BOOST_CHECK(ancestor == 0);
778 BOOST_CHECK(id_ancestor1 == 0);
779 BOOST_CHECK(id_ancestor2 == 0);
783 size_t id_ancestor1, id_ancestor2;
786 BOOST_CHECK(ancestor == 0);
787 BOOST_CHECK(id_ancestor1 == 0);
788 BOOST_CHECK(id_ancestor2 == 0);
792 size_t id_ancestor1, id_ancestor2;
795 BOOST_CHECK(ancestor == 0);
796 BOOST_CHECK(id_ancestor1 == 0);
797 BOOST_CHECK(id_ancestor2 == 0);
801 size_t id_ancestor1, id_ancestor2;
804 BOOST_CHECK(ancestor == 1);
806 BOOST_CHECK(
model.supports[1][id_ancestor2] == ancestor);
812 using namespace Eigen;
818 std::vector<bool> expected_cf_limits_ff({
true,
true,
true,
false,
false,
false,
false});
819 std::vector<bool> expected_cf_limits_tangent_ff({
true,
true,
true,
false,
false,
false});
820 BOOST_CHECK(cf_limits_ff == expected_cf_limits_ff);
821 BOOST_CHECK(cf_limits_tangent_ff == expected_cf_limits_tangent_ff);
826 std::vector<bool> expected_cf_limits_planar({
true,
true,
false,
false});
827 std::vector<bool> expected_cf_limits_tangent_planar({
true,
true,
false});
828 BOOST_CHECK(cf_limits_planar == expected_cf_limits_planar);
829 BOOST_CHECK(cf_limits_tangent_planar == expected_cf_limits_tangent_planar);
834 std::vector<bool> expected_cf_limits_prismatic({
true});
835 std::vector<bool> expected_cf_limits_tangent_prismatic({
true});
836 BOOST_CHECK(cf_limits_prismatic == expected_cf_limits_prismatic);
837 BOOST_CHECK(cf_limits_tangent_prismatic == expected_cf_limits_tangent_prismatic);
845 jointId =
model.addJoint(
846 jointId,
JointModelRUBZ(),
SE3(Matrix3d::Identity(), Vector3d(1.0, 0.0, 0.0)),
"Joint2");
848 std::vector<bool> expected_cf_limits_model(
850 false,
false,
false,
false,
853 std::vector<bool> model_cf_limits =
model.hasConfigurationLimit();
854 BOOST_CHECK((model_cf_limits == expected_cf_limits_model));
857 std::vector<bool> expected_cf_limits_tangent_model(
862 std::vector<bool> model_cf_limits_tangent =
model.hasConfigurationLimitInTangent();
863 BOOST_CHECK((model_cf_limits_tangent == expected_cf_limits_tangent_model));
866 BOOST_AUTO_TEST_SUITE_END()