19 #include <boost/test/unit_test.hpp>
20 #include <boost/filesystem/fstream.hpp>
25 struct TemporaryFileHolder
28 :
path(
boost::filesystem::temp_directory_path() /
boost::filesystem::unique_path())
32 ~TemporaryFileHolder()
34 boost::filesystem::remove(
path);
37 TemporaryFileHolder(
const TemporaryFileHolder &) =
delete;
38 TemporaryFileHolder &
operator=(
const TemporaryFileHolder &) =
delete;
40 TemporaryFileHolder(TemporaryFileHolder &&) =
default;
41 TemporaryFileHolder &
operator=(TemporaryFileHolder &&) =
default;
43 std::string
name()
const
55 TemporaryFileHolder temp_file;
58 boost::filesystem::ofstream file_stream(temp_file.path);
61 std::cerr <<
"Error opening file for writing" << std::endl;
64 file_stream <<
data.rdbuf();
74 if (pt1.size() != pt2.size())
78 for (
auto it1 = pt1.begin(), it2 = pt2.begin(); it1 != pt1.end(); ++it1, ++it2)
81 if (it1->first != it2->first)
85 if (it1->second.data() != it2->second.data())
96 BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
105 std::istringstream xmlData(R
"(
106 <inertial mass="0.629769" pos="-0.041018 -0.00014 0.049974"
107 fullinertia="0.00315 0.00388 0.004285 8.2904e-7 0.00015 8.2299e-6"/>
112 boost::property_tree::read_xml(xmlData, pt);
114 typedef ::pinocchio::mjcf::details::MjcfGraph MjcfGraph;
118 MjcfGraph
graph(visitor,
"fakeMjcf");
123 Matrix3 inertia_matrix;
125 inertia_matrix << 0.00315, 8.2904e-7, 0.00015, 8.2904e-7, 0.00388, 8.2299e-6, 0.00015, 8.2299e-6,
129 BOOST_CHECK(inertia.
isEqual(real_inertia));
139 std::istringstream xmlData(R
"(
140 <inertial mass="0.629769" pos="-0.041018 -0.00014 0.049974"
141 diaginertia="0.00315 0.00388 0.004285"/>
146 boost::property_tree::read_xml(xmlData, pt);
148 typedef ::pinocchio::mjcf::details::MjcfGraph MjcfGraph;
152 MjcfGraph
graph(visitor,
"fakeMjcf");
157 Matrix3 inertia_matrix = Eigen::Matrix3d::Zero();
158 inertia_matrix(0, 0) = 0.00315;
159 inertia_matrix(1, 1) = 0.00388;
160 inertia_matrix(2, 2) = 0.004285;
163 BOOST_CHECK(inertia.isApprox(real_inertia, 1e-7));
169 double pi = boost::math::constants::pi<double>();
171 std::istringstream xmlData(R
"(<mujoco model="inertiaFromGeom">
172 <compiler inertiafromgeom="true" />
174 <body pos="0 0 0" name="bodyCylinder">
175 <geom type="cylinder" size=".01" fromto="0 0 0 0 0 .5"/>
176 <geom type="cylinder" size=".01 0.25" pos="0 0 0" quat="1 0 0 0"/>
177 <body pos="0 0 0" name="bodyBox">
178 <geom type="box" size=".01" fromto="0 0 0 0 0 .5"/>
179 <geom type="box" size=".01 0.01 0.25" pos="0 0 0" quat="1 0 0 0"/>
181 <body pos="0 0 0" name="bodyCapsule">
182 <geom type="capsule" size=".01" fromto="0 0 0 0 0 .5"/>
183 <geom type="capsule" size=".01 0.25" pos="0 0 0" quat="1 0 0 0"/>
185 <body pos="0 0 0" name="bodySphere">
186 <geom type="sphere" size=".01 0.25" pos="0 0 0" quat="1 0 0 0"/>
188 <body pos="0 0 0" name="bodyEllip">
189 <geom type="ellipsoid" size=".01" fromto="0 0 0 0 0 .5"/>
190 <geom type="ellipsoid" size=".01 0.01 0.25" pos="0 0 0" quat="1 0 0 0"/>
198 typedef ::pinocchio::mjcf::details::MjcfGraph MjcfGraph;
202 MjcfGraph
graph(visitor,
"fakeMjcf");
203 graph.parseGraphFromXML(namefile.name());
207 double mass = 1000 * std::pow(0.01, 2) * 0.25 * pi * 2;
209 Eigen::Vector2d sizeCy;
210 sizeCy << 0.01, 0.25;
214 BOOST_CHECK(geom.size == sizeCy);
216 BOOST_CHECK(geom.geomInertia.isApprox(inertTest));
219 bodyTest =
graph.mapOfBodies.at(
"bodyBox");
220 mass = 1000 * 0.02 * 0.02 * 0.5;
222 Eigen::Vector3d sizeB;
223 sizeB << 0.02, 0.02, .5;
227 BOOST_CHECK(geom.size == sizeB);
229 BOOST_CHECK(geom.geomInertia.isApprox(inertTest));
232 bodyTest =
graph.mapOfBodies.at(
"bodyCapsule");
233 mass = 1000 * (4.0 / 3 * pi * std::pow(0.01, 3) + 2 * pi * std::pow(0.01, 2) * 0.25);
235 Eigen::Vector2d sizeCa;
236 sizeCa << 0.01, 0.25;
240 BOOST_CHECK(geom.size == sizeCa);
242 BOOST_CHECK(geom.geomInertia.isApprox(inertTest));
245 bodyTest =
graph.mapOfBodies.at(
"bodySphere");
246 mass = 1000 * 4.0 / 3 * pi * std::pow(0.01, 3);
248 Eigen::VectorXd sizeS(1);
253 BOOST_CHECK(geom.size == sizeS);
255 BOOST_CHECK(geom.geomInertia.isApprox(inertTest));
258 bodyTest =
graph.mapOfBodies.at(
"bodyEllip");
259 mass = 1000 * 4.0 / 3 * pi * 0.01 * 0.01 * 0.25;
261 Eigen::Vector3d sizeEl;
262 sizeEl << 0.01, 0.01, 0.25;
266 BOOST_CHECK(geom.size == sizeEl);
268 BOOST_CHECK(geom.geomInertia.isApprox(inertTest));
277 std::istringstream xmlData(R
"(<mujoco model="inertiaFromGeom">
278 <compiler inertiafromgeom="true" />
280 <body pos="0 0 0" name="body0">
281 <geom type="box" size=".01 .01 .01" pos="0 0 0.01"/>
282 <geom type="box" size=".01 .01 .01" pos="0 0 0.03"/>
289 typedef ::pinocchio::mjcf::details::MjcfGraph MjcfGraph;
293 MjcfGraph
graph(visitor,
"fakeMjcf");
294 graph.parseGraphFromXML(namefile.name());
295 graph.parseRootTree();
300 double massBigBox = 1000 * 0.02 * 0.02 * 0.04;
306 inertBigBox = placementBigBox.act(inertBigBox);
308 BOOST_CHECK(inertBigBox.isApprox(inertBody));
318 std::istringstream xmlData(R
"(
319 <compiler angle="radian" eulerseq="xyz"/>
320 <quaternion pos="0.3 0.2 0.5" quat="1 -1 0 0"/>
321 <axis pos="0.3 0.2 0.5" axisangle="-1 0 0 1.5707963"/>
322 <euler pos="0.3 0.2 0.5" euler="-1.57079633 0 0"/>
323 <xyaxes pos="0.3 0.2 0.5" xyaxes="1 0 0 0 0 -1"/>
324 <zaxis pos="0.3 0.2 0.5" zaxis="0 1 0"/>
329 boost::property_tree::read_xml(xmlData, pt);
331 typedef ::pinocchio::mjcf::details::MjcfGraph MjcfGraph;
335 MjcfGraph
graph(visitor,
"fakeMjcf");
337 graph.parseCompiler(pt.get_child(
"compiler"));
345 Matrix3 rotation_matrix;
346 rotation_matrix << 1., 0., 0., 0., 0., 1., 0., -1., 0.;
350 BOOST_CHECK(placement_q.isApprox(real_placement, 1e-7));
351 BOOST_CHECK(placement_e.isApprox(real_placement, 1e-7));
352 BOOST_CHECK(placement_a.isApprox(real_placement, 1e-7));
353 BOOST_CHECK(placement_xy.isApprox(real_placement, 1e-7));
354 BOOST_CHECK(placement_z.isApprox(real_placement, 1e-7));
361 namespace pt = boost::property_tree;
362 std::istringstream xmlIn(R
"(
364 <default class="mother">
365 <joint A="a0" B="b0" />
367 <default class="layer1">
368 <joint A="a1" C="c1" />
369 <default class="layer2">
374 <default class="layerP">
383 pt::read_xml(xmlIn, ptr, pt::xml_parser::trim_whitespace);
385 typedef ::pinocchio::mjcf::details::MjcfGraph MjcfGraph;
389 MjcfGraph
graph(visitor,
"fakeMjcf");
390 graph.parseDefault(ptr.get_child(
"default"), ptr,
"default");
392 std::unordered_map<std::string, pt::ptree> TrueMap;
394 std::istringstream xml1(R
"(<default class="mother">
395 <joint A="a0" B="b0" />
397 <default class="layer1">
398 <joint A="a1" C="c1" />
399 <default class="layer2">
404 <default class="layerP">
410 pt::read_xml(xml1, p1, pt::xml_parser::trim_whitespace);
414 std::istringstream xml2(R
"(<default class="layer1">
415 <joint A="a1" B="b0" C="c1" />
416 <default class="layer2">
423 pt::read_xml(xml2, p2, pt::xml_parser::trim_whitespace);
426 std::string
name =
"layer1";
427 TrueMap.insert(std::make_pair(
name, p2.get_child(
"default")));
429 std::istringstream xml3(R
"(<default class="layer2">
430 <joint A="a1" B="b2" C="c1"/>
431 <geom A="a0" C="c2"/>
434 pt::read_xml(xml3, p3, pt::xml_parser::trim_whitespace);
438 std::istringstream xml4(R
"(<default class="layerP">
439 <joint A="a0" B="b0" K="b2"/>
444 pt::read_xml(xml4, p4, pt::xml_parser::trim_whitespace);
449 #ifdef PINOCCHIO_WITH_URDFDOM
462 std::string file_u =
PINOCCHIO_MODEL_DIR + std::string(
"/../unittest/models/test_mjcf.urdf");
473 for (
size_t i = 0;
i < size_t(model_m.
njoints);
i++)
476 #endif // PINOCCHIO_WITH_URDFDOM
482 std::istringstream xmlDataNoStrip(R
"(<mujoco model="parseDirs">
483 <compiler meshdir="meshes" texturedir="textures"/>
485 <texture name="testTexture" file="texture.png" type="2d"/>
486 <material name="matTest" texture="testTexture"/>
487 <mesh file="C:/auto/mesh.obj"/>
491 std::istringstream xmlDataNoStrip(R
"(<mujoco model="parseDirs">
492 <compiler meshdir="meshes" texturedir="textures"/>
494 <texture name="testTexture" file="texture.png" type="2d"/>
495 <material name="matTest" texture="testTexture"/>
496 <mesh file="/auto/mesh.obj"/>
503 typedef ::pinocchio::mjcf::details::MjcfGraph MjcfGraph;
507 MjcfGraph
graph(visitor,
"/fakeMjcf/fake.xml");
508 graph.parseGraphFromXML(namefile.name());
512 BOOST_CHECK_EQUAL(text.
textType,
"2d");
517 BOOST_CHECK_EQUAL(
mat.texture,
"testTexture");
531 std::istringstream xmlDataNoStrip(R
"(<mujoco model="parseDirs">
532 <compiler meshdir="meshes" texturedir="textures" strippath="true"/>
534 <mesh file="/auto/mesh.obj"/>
540 typedef ::pinocchio::mjcf::details::MjcfGraph MjcfGraph;
544 MjcfGraph
graph(visitor,
"/fakeMjcf/fake.xml");
545 graph.parseGraphFromXML(namefile.name());
559 std::istringstream xmlData(R
"(
560 <mujoco model="model_RX">
563 <body name="link1" pos="0 0 0">
564 <joint name="joint1" type="hinge" axis="1 0 0"/>
572 typedef ::pinocchio::mjcf::details::MjcfGraph MjcfGraph;
576 MjcfGraph
graph(visitor,
"fakeMjcf");
577 graph.parseGraphFromXML(namefile.name());
578 graph.parseRootTree();
586 for (
size_t i = 0;
i < size_t(model_m.
njoints);
i++)
596 std::istringstream xmlData(R
"(
597 <mujoco model="model_PX">
600 <body name="link1" pos="0 0 0">
601 <joint name="joint1" type="slide" axis="1 0 0"/>
609 typedef ::pinocchio::mjcf::details::MjcfGraph MjcfGraph;
613 MjcfGraph
graph(visitor,
"fakeMjcf");
614 graph.parseGraphFromXML(namefile.name());
615 graph.parseRootTree();
623 for (
size_t i = 0;
i < size_t(model_m.
njoints);
i++)
633 std::istringstream xmlData(R
"(
634 <mujoco model="model_Sphere">
637 <body name="link1" pos="0 0 0">
638 <joint name="joint1" type="ball"/>
646 typedef ::pinocchio::mjcf::details::MjcfGraph MjcfGraph;
650 MjcfGraph
graph(visitor,
"fakeMjcf");
651 graph.parseGraphFromXML(namefile.name());
652 graph.parseRootTree();
660 for (
size_t i = 0;
i < size_t(model_m.
njoints);
i++)
670 std::istringstream xmlData(R
"(
671 <mujoco model="model_Free">
674 <body name="link1" pos="0 0 0">
675 <freejoint name="joint1"/>
683 typedef ::pinocchio::mjcf::details::MjcfGraph MjcfGraph;
687 MjcfGraph
graph(visitor,
"fakeMjcf");
688 graph.parseGraphFromXML(namefile.name());
689 graph.parseRootTree();
697 for (
size_t i = 0;
i < size_t(model_m.
njoints);
i++)
707 std::istringstream xmlData(R
"(
708 <mujoco model="composite_RXRY">
711 <body name="link1" pos="0 0 0">
712 <joint name="joint1" type="hinge" axis="1 0 0"/>
713 <joint name="joint2" type="hinge" axis="0 1 0"/>
721 typedef ::pinocchio::mjcf::details::MjcfGraph MjcfGraph;
725 MjcfGraph
graph(visitor,
"fakeMjcf");
726 graph.parseGraphFromXML(namefile.name());
727 graph.parseRootTree();
739 for (
size_t i = 0;
i < size_t(model_m.
njoints);
i++)
749 std::istringstream xmlData(R
"(
750 <mujoco model="composite_PXPY">
753 <body name="link1" pos="0 0 0">
754 <joint name="joint1" type="slide" axis="1 0 0"/>
755 <joint name="joint2" type="slide" axis="0 1 0"/>
763 typedef ::pinocchio::mjcf::details::MjcfGraph MjcfGraph;
767 MjcfGraph
graph(visitor,
"fakeMjcf");
768 graph.parseGraphFromXML(namefile.name());
769 graph.parseRootTree();
781 for (
size_t i = 0;
i < size_t(model_m.
njoints);
i++)
791 std::istringstream xmlData(R
"(
792 <mujoco model="composite_PXRY">
795 <body name="link1" pos="0 0 0">
796 <joint name="joint1" type="slide" axis="1 0 0"/>
797 <joint name="joint2" type="hinge" axis="0 1 0"/>
805 typedef ::pinocchio::mjcf::details::MjcfGraph MjcfGraph;
809 MjcfGraph
graph(visitor,
"fakeMjcf");
810 graph.parseGraphFromXML(namefile.name());
811 graph.parseRootTree();
823 for (
size_t i = 0;
i < size_t(model_m.
njoints);
i++)
833 std::istringstream xmlData(R
"(
834 <mujoco model="composite_PXSphere">
837 <body name="link1" pos="0 0 0">
838 <joint name="joint1" type="slide" axis="1 0 0"/>
839 <joint name="joint2" type="ball"/>
847 typedef ::pinocchio::mjcf::details::MjcfGraph MjcfGraph;
851 MjcfGraph
graph(visitor,
"fakeMjcf");
852 graph.parseGraphFromXML(namefile.name());
853 graph.parseRootTree();
865 for (
size_t i = 0;
i < size_t(model_m.
njoints);
i++)
881 q << 1.57079633, 0.3, 0.5;
887 Eigen::Matrix3d refOrient;
888 refOrient << 0, -.9553, .2955, 1, 0, 0, 0, .2955, .9553;
890 pos << .8522, 2, 0.5223;
891 BOOST_CHECK(pinPos.isApprox(
SE3(refOrient,
pos), 1e-4));
893 f_id =
model.getFrameId(
"body2");
894 pinPos =
data.oMf[f_id];
896 refOrient << 0, -.9553, .2955, 1, 0, 0, 0, .2955, .9553;
898 pos << .8522, 4, 0.5223;
899 BOOST_CHECK(pinPos.isApprox(
SE3(refOrient,
pos), 1e-4));
905 std::istringstream xmlData(R
"(
906 <mujoco model="testKeyFrame">
908 <position ctrllimited="true" ctrlrange="-.1 .1" kp="30"/>
909 <default class="joint">
910 <geom type="cylinder" size=".006" fromto="0 0 0 0 0 .05" rgba=".9 .6 1 1"/>
916 <geom type="capsule" size=".01" fromto="0 0 0 .2 0 0"/>
917 <body pos=".2 0 0" name="body2">
918 <joint type="ball" damping=".1"/>
919 <geom type="capsule" size=".01" fromto="0 -.15 0 0 0 0"/>
926 0.988015 0 0.154359 0
927 0.988015 0 0.154359 0
939 Eigen::VectorXd vect_ref(model_m.
nq);
940 vect_ref << 0, 0, 0.596, 0, 0.154359, 0, 0.988015, 0, 0.154359, 0, 0.988015;
942 BOOST_CHECK(vect_model.size() == vect_ref.size());
943 BOOST_CHECK(vect_model == vect_ref);
952 std::istringstream xmlData(R
"(
953 <mujoco model="testJointInertia">
957 <inertial mass="0.629769" pos="-0.041018 -0.00014 0.049974"
958 diaginertia="0.00315 0.00388 0.004285"/>
970 Matrix3 inertia_matrix = Eigen::Matrix3d::Zero();
971 inertia_matrix(0, 0) = 0.00315;
972 inertia_matrix(1, 1) = 0.00388;
973 inertia_matrix(2, 2) = 0.004285;
976 BOOST_CHECK(model_m.
inertias[1].isApprox(real_inertia));
983 std::cout <<
" Armature ------------ " << std::endl;
984 std::istringstream xmlData(R
"(
985 <mujoco model="model_RX">
987 <joint armature="1" damping="1" limited="true"/>
991 <body name="link1" pos="0 0 0">
992 <joint name="joint1" type="hinge" axis="1 0 0" armature="1.3"/>
993 <joint name="joint2" type="hinge" axis="0 1 0" armature="2.4"/>
994 <joint name="joint3" type="hinge" axis="0 0 1" armature="0.4"/>
995 <body pos=".2 0 0" name="body2">
1005 typedef ::pinocchio::mjcf::details::MjcfGraph MjcfGraph;
1009 MjcfGraph
graph(visitor,
"fakeMjcf");
1010 graph.parseGraphFromXML(namefile.name());
1011 graph.parseRootTree();
1013 Eigen::VectorXd armature_real(model_m.
nv);
1014 armature_real << 1.3, 2.4, 0.4, 1, 1, 1;
1016 for (
size_t i = 0;
i < size_t(model_m.
nv);
i++)
1017 BOOST_CHECK_EQUAL(model_m.
armature[
i], armature_real[
i]);
1023 std::istringstream xmlData(R
"(
1024 <mujoco model="testRefPose">
1025 <compiler angle="radian"/>
1028 <body pos=".2 0 0" name="body2">
1029 <joint type="slide" ref="0.14"/>
1030 <body pos=".2 0 0" name="body3">
1031 <joint type="hinge" ref="0.1"/>
1037 <key name="test" qpos=".8 .5"/>
1047 Eigen::VectorXd vect_ref(model_m.
nq);
1048 vect_ref << 0.66, 0.4;
1050 BOOST_CHECK(vect_model.size() == vect_ref.size());
1051 BOOST_CHECK(vect_model == vect_ref);
1057 std::istringstream xmlData(R
"(
1058 <mujoco model="keyframeComposite">
1059 <compiler angle="radian"/>
1062 <body pos=".2 0 0" name="body2">
1063 <joint type="slide"/>
1064 <joint type="hinge"/>
1065 <body pos=".2 0 0" name="body3">
1066 <joint type="hinge"/>
1072 <key name="test" qpos=".8 .5 .5"/>
1082 Eigen::VectorXd vect_ref(model_m.
nq);
1083 vect_ref << 0.8, 0.5, 0.5;
1085 BOOST_CHECK(vect_model.size() == vect_ref.size());
1086 BOOST_CHECK(vect_model == vect_ref);
1095 std::istringstream xmlData(R
"(
1096 <mujoco model="site">
1097 <compiler angle="radian"/>
1100 <body pos=".2 0 0" name="body2">
1101 <joint type="hinge"/>
1102 <body pos=".2 0 0" name="body3">
1103 <joint type="hinge"/>
1104 <site name="testSite" pos="0.03 0 -0.05"/>
1118 Matrix3 rotation_matrix;
1119 rotation_matrix << 1., 0., 0., 0., 1., 0., 0., 0., 1.;
1122 BOOST_CHECK(model_m.
frames[model_m.
getFrameId(
"testSite")].placement.isApprox(real_placement));
1135 BOOST_CHECK_EQUAL(model_m.
nq, 29);
1145 BOOST_CHECK(
model.names[1] ==
"root_joint");
1148 const std::string name_ =
"freeFlyer_joint";
1150 BOOST_CHECK(model_name.
names[1] == name_);
1153 #ifdef PINOCCHIO_WITH_URDFDOM
1166 const std::string filename_urdf =
PINOCCHIO_MODEL_DIR + std::string(
"/simple_humanoid.urdf");
1171 BOOST_CHECK(model_urdf.
nq == model_m.
nq);
1172 BOOST_CHECK(model_urdf.
nv == model_m.
nv);
1178 BOOST_CHECK(model_urdf.
names == model_m.
names);
1181 BOOST_CHECK(model_urdf.
name == model_m.
name);
1183 BOOST_CHECK(model_urdf.
nqs == model_m.
nqs);
1185 BOOST_CHECK(model_urdf.
nvs == model_m.
nvs);
1188 typename ConfigVectorMap::const_iterator it_model_urdf =
1192 std::advance(
it, k);
1193 std::advance(it_model_urdf, k);
1194 BOOST_CHECK(
it->second.size() == it_model_urdf->second.size());
1195 BOOST_CHECK(
it->second == it_model_urdf->second);
1204 BOOST_CHECK(model_urdf.
damping.size() == model_m.
damping.size());
1226 for (
size_t k = 1; k < model_m.
inertias.size(); ++k)
1238 BOOST_CHECK(model_urdf.
frames.size() == model_m.
frames.size());
1239 for (
size_t k = 1; k < model_urdf.
frames.size(); ++k)
1241 BOOST_CHECK(model_urdf.
frames[k] == model_m.
frames[k]);
1244 #endif // PINOCCHIO_WITH_URDFDOM
1246 #if defined(PINOCCHIO_WITH_HPP_FCL)
1253 std::istringstream xmlData(R
"(<mujoco model="inertiaFromGeom">
1254 <compiler inertiafromgeom="true" />
1256 <body pos="0 0 0" name="bodyCylinder">
1257 <geom type="cylinder" size=".01 0.25" pos="0 0 0" quat="1 0 0 0"/>
1258 <body pos="0 0 0" name="bodyBox">
1259 <geom type="box" size=".01 0.01 0.25" pos="0 0 0" quat="1 0 0 0"/>
1261 <body pos="0 0 0" name="bodyCapsule">
1262 <geom type="capsule" size=".01 0.25" pos="0 0 0" quat="1 0 0 0"/>
1264 <body pos="0 0 0" name="bodySphere">
1265 <geom type="sphere" size=".01" pos="0 0 0" quat="1 0 0 0"/>
1267 <body pos="0 0 0" name="bodyEllip">
1268 <geom type="ellipsoid" size=".01 0.01 0.25" pos="0 0 0" quat="1 0 0 0"/>
1282 BOOST_CHECK(geomModel_m.
ngeoms == 5);
1286 BOOST_CHECK(cyl->halfLength == 0.25);
1287 BOOST_CHECK(cyl->radius == 0.01);
1291 BOOST_CHECK(cap->halfLength == 0.25);
1292 BOOST_CHECK(cap->radius == 0.01);
1296 BOOST_CHECK(s->radius == 0.01);
1300 Eigen::Vector3d sides;
1301 sides << 0.01, 0.01, 0.25;
1302 BOOST_CHECK(
b->halfSide == sides);
1306 BOOST_CHECK(e->radii == sides);
1308 #endif // if defined(PINOCCHIO_WITH_HPP_FCL)
1329 BOOST_CHECK(
cm.joint2_placement.isApprox(
cm.joint1_placement.inverse()));
1335 std::istringstream xmlData(R
"(<mujoco model="arm">
1336 <compiler angle="radian" />
1339 <body name="body" pos="0 0 0.01" euler="1.57 0 0">
1347 typedef ::pinocchio::mjcf::details::MjcfGraph MjcfGraph;
1351 MjcfGraph
graph(visitor,
"fakeMjcf");
1352 graph.parseGraphFromXML(namefile.name());
1353 graph.parseRootTree();
1357 Eigen::Vector3d(0.0, 0.0, 0.01));
1359 BOOST_CHECK(
graph.mapOfBodies[
"body"].bodyPlacement.isApprox(
placement));
1366 std::istringstream xmlDataNoStrip(R
"(<mujoco model="parseVertices">
1368 <mesh name="chasis" scale=".01 .006 .0015"
1383 typedef ::pinocchio::mjcf::details::MjcfGraph MjcfGraph;
1387 MjcfGraph
graph(visitor,
"/fakeMjcf/fake.xml");
1388 graph.parseGraphFromXML(namefile.name());
1392 BOOST_CHECK_EQUAL(
mesh.scale, Eigen::Vector3d(0.01, 0.006, 0.0015));
1393 Eigen::MatrixX3d vertices(9, 3);
1394 vertices << 9, 2, 0, -10, 10, 10, 9, -2, 0, 10, 3, -10, 10, -3, -10, -8, 10, -10, -10, -10, 10,
1395 -8, -10, -10, -5, 0, 20;
1396 BOOST_CHECK_EQUAL(
mesh.vertices.rows(), 9);
1397 for (
auto i = 0;
i <
mesh.vertices.rows(); ++
i)
1399 BOOST_CHECK(
mesh.vertices.row(
i) == vertices.row(
i));
1406 BOOST_CHECK(
v.size() == 0);
1409 BOOST_CHECK(v1.size() == 3);
1410 Eigen::VectorXd expected(3);
1411 expected << 1, 2, 3;
1412 BOOST_CHECK(v1 == expected);
1416 BOOST_CHECK(v2.size() == 6);
1417 Eigen::VectorXd expected2(6);
1418 expected2 << 1, 2, 3, 4, 5, 6;
1419 BOOST_CHECK(v2 == expected2);
1425 BOOST_CHECK(v3.size() == 9);
1426 Eigen::VectorXd expected3(9);
1427 expected3 << 1, 2, 3, 4, 5, 6, 7, 8, 9;
1428 BOOST_CHECK(v3 == expected3);
1431 BOOST_AUTO_TEST_SUITE_END()