3 #include <gtest/gtest.h>
4 #include <Eigen/Geometry>
11 TEST(TesseractURDFUnit, parse_joint)
15 R
"(<joint name="my_joint" type="floating" extra="0 0 0">
16 <origin xyz="0 0 1" rpy="0 0 3.1416"/>
17 <parent link="link1" extra="0 0 0"/>
18 <child link="link2" extra="0 0 0"/>
19 <calibration rising="0.0"/>
20 <dynamics damping="0.0" friction="0.0"/>
21 <limit effort="30" velocity="1.0" lower="-2.2" upper="0.7" />
22 <safety_controller k_velocity="10" k_position="15" soft_lower_limit="-2.0" soft_upper_limit="0.5" />
25 EXPECT_TRUE(runTest<tesseract_scene_graph::Joint::Ptr>(
29 EXPECT_FALSE(elem->parent_to_joint_origin_transform.isApprox(Eigen::Isometry3d::Identity(), 1e-8));
30 EXPECT_TRUE(elem->axis.isApprox(Eigen::Vector3d(1, 0, 0), 1e-8));
42 R
"(<joint name="my_joint" type="revolute">
43 <origin xyz="0 0 1" rpy="0 0 3.1416"/>
44 <parent link="link1"/>
46 <calibration rising="0.0"/>
47 <dynamics damping="0.0" friction="0.0"/>
48 <limit effort="30" velocity="1.0" lower="-2.2" upper="0.7" />
49 <safety_controller k_velocity="10" k_position="15" soft_lower_limit="-2.0" soft_upper_limit="0.5" />
52 EXPECT_TRUE(runTest<tesseract_scene_graph::Joint::Ptr>(
56 EXPECT_FALSE(elem->parent_to_joint_origin_transform.isApprox(Eigen::Isometry3d::Identity(), 1e-8));
57 EXPECT_TRUE(elem->axis.isApprox(Eigen::Vector3d(1, 0, 0), 1e-8));
68 std::string str = R
"(<joint name="my_joint" type="revolute">
70 <parent link="link1"/>
72 <limit effort="30" velocity="1.0" lower="-2.2" upper="0.7" />
75 EXPECT_TRUE(runTest<tesseract_scene_graph::Joint::Ptr>(
79 EXPECT_TRUE(elem->parent_to_joint_origin_transform.isApprox(Eigen::Isometry3d::Identity(), 1e-8));
80 EXPECT_TRUE(elem->axis.isApprox(Eigen::Vector3d(0, 0, 1), 1e-8));
91 std::string str = R
"(<joint name="my_joint" type="continuous">
93 <parent link="link1"/>
95 <limit effort="30" velocity="1.0"/>
98 EXPECT_TRUE(runTest<tesseract_scene_graph::Joint::Ptr>(
102 EXPECT_TRUE(elem->parent_to_joint_origin_transform.isApprox(Eigen::Isometry3d::Identity(), 1e-8));
103 EXPECT_TRUE(elem->axis.isApprox(Eigen::Vector3d(0, 0, 1), 1e-8));
114 std::string str = R
"(<joint name="my_joint" type="continuous">
116 <parent link="link1"/>
117 <child link="link2"/>
120 EXPECT_TRUE(runTest<tesseract_scene_graph::Joint::Ptr>(
124 EXPECT_TRUE(elem->parent_to_joint_origin_transform.isApprox(Eigen::Isometry3d::Identity(), 1e-8));
125 EXPECT_TRUE(elem->axis.isApprox(Eigen::Vector3d(0, 0, 1), 1e-8));
136 std::string str = R
"(<joint name="my_joint" type="fixed">
138 <parent link="link1"/>
139 <child link="link2"/>
140 <limit effort="30" velocity="1.0" lower="-2.2" upper="0.7" />
143 EXPECT_TRUE(runTest<tesseract_scene_graph::Joint::Ptr>(
147 EXPECT_TRUE(elem->parent_to_joint_origin_transform.isApprox(Eigen::Isometry3d::Identity(), 1e-8));
148 EXPECT_TRUE(elem->axis.isApprox(Eigen::Vector3d(1, 0, 0), 1e-8));
159 std::string str = R
"(<joint name="my_joint" type="prismatic">
161 <parent link="link1"/>
162 <child link="link2"/>
163 <limit effort="30" velocity="1.0" lower="-2.2" upper="0.7" />
166 EXPECT_TRUE(runTest<tesseract_scene_graph::Joint::Ptr>(
170 EXPECT_TRUE(elem->parent_to_joint_origin_transform.isApprox(Eigen::Isometry3d::Identity(), 1e-8));
171 EXPECT_TRUE(elem->axis.isApprox(Eigen::Vector3d(0, 0, -1), 1e-8));
182 std::string str = R
"(<joint name="my_joint" type="revolute">
184 <parent link="link1"/>
185 <child link="link2"/>
186 <limit effort="30" velocity="1.0" lower="-2.2" upper="0.7" />
189 EXPECT_TRUE(runTest<tesseract_scene_graph::Joint::Ptr>(
193 EXPECT_TRUE(elem->parent_to_joint_origin_transform.isApprox(Eigen::Isometry3d::Identity(), 1e-8));
194 EXPECT_TRUE(elem->axis.isApprox(Eigen::Vector3d(0, 0, -1), 1e-8));
205 std::string str = R
"(<joint name="my_joint" type="planar">
206 <axis xyz="0 0 -1.0"/>
207 <parent link="link1"/>
208 <child link="link2"/>
209 <limit effort="30" velocity="1.0" lower="-2.2" upper="0.7" />
212 EXPECT_TRUE(runTest<tesseract_scene_graph::Joint::Ptr>(
216 EXPECT_TRUE(elem->parent_to_joint_origin_transform.isApprox(Eigen::Isometry3d::Identity(), 1e-8));
217 EXPECT_TRUE(elem->axis.isApprox(Eigen::Vector3d(0, 0, -1), 1e-8));
228 std::string str = R
"(<joint name="my_joint">
229 <parent link="link1"/>
230 <child link="link2"/>
233 EXPECT_FALSE(runTest<tesseract_scene_graph::Joint::Ptr>(
238 std::string str = R"(<joint type="planar">
239 <parent link="link1"/>
240 <child link="link2"/>
243 EXPECT_FALSE(runTest<tesseract_scene_graph::Joint::Ptr>(
248 std::string str = R"(<joint name="my_joint" type="planar">
249 <child link="link2"/>
252 EXPECT_FALSE(runTest<tesseract_scene_graph::Joint::Ptr>(
257 std::string str = R"(<joint name="my_joint" type="planar">
258 <parent link="link1"/>
261 EXPECT_FALSE(runTest<tesseract_scene_graph::Joint::Ptr>(
266 std::string str = R"(<joint name="my_joint" type="planar">
268 <parent link="link1"/>
269 <child link="link2"/>
270 <limit effort="30" velocity="1.0" lower="-2.2" upper="0.7" />
273 EXPECT_FALSE(runTest<tesseract_scene_graph::Joint::Ptr>(
278 std::string str = R"(<joint name="my_joint" type="planar">
279 <axis xyz="0 0 -1.0 4"/>
280 <parent link="link1"/>
281 <child link="link2"/>
282 <limit effort="30" velocity="1.0" lower="-2.2" upper="0.7" />
285 EXPECT_FALSE(runTest<tesseract_scene_graph::Joint::Ptr>(
290 std::string str = R"(<joint name="my_joint" type="planar">
291 <axis xyz="a 0 -1.0"/>
292 <parent link="link1"/>
293 <child link="link2"/>
294 <limit effort="30" velocity="1.0" lower="-2.2" upper="0.7" />
297 EXPECT_FALSE(runTest<tesseract_scene_graph::Joint::Ptr>(
302 std::string str = R"(<joint name="my_joint" type="planar">
303 <axis xyz="0 a -1.0"/>
304 <parent link="link1"/>
305 <child link="link2"/>
306 <limit effort="30" velocity="1.0" lower="-2.2" upper="0.7" />
309 EXPECT_FALSE(runTest<tesseract_scene_graph::Joint::Ptr>(
314 std::string str = R"(<joint name="my_joint" type="planar">
316 <parent link="link1"/>
317 <child link="link2"/>
318 <limit effort="30" velocity="1.0" lower="-2.2" upper="0.7" />
321 EXPECT_FALSE(runTest<tesseract_scene_graph::Joint::Ptr>(
327 R"(<joint name="my_joint" type="floating" extra="0 0 0">
328 <origin xyz="0 0 1 4" rpy="0 0 3.1416"/>
329 <parent link="link1" extra="0 0 0"/>
330 <child link="link2" extra="0 0 0"/>
331 <calibration rising="0.0"/>
332 <dynamics damping="0.0" friction="0.0"/>
333 <limit effort="30" velocity="1.0" lower="-2.2" upper="0.7" />
334 <safety_controller k_velocity="10" k_position="15" soft_lower_limit="-2.0" soft_upper_limit="0.5" />
337 EXPECT_FALSE(runTest<tesseract_scene_graph::Joint::Ptr>(
343 R"(<joint name="my_joint" type="floating" extra="0 0 0">
344 <origin xyz="0 0 1" rpy="0 0 3.1416"/>
345 <parent extra="0 0 0"/>
346 <child link="link2" extra="0 0 0"/>
347 <calibration rising="0.0"/>
348 <dynamics damping="0.0" friction="0.0"/>
349 <limit effort="30" velocity="1.0" lower="-2.2" upper="0.7" />
350 <safety_controller k_velocity="10" k_position="15" soft_lower_limit="-2.0" soft_upper_limit="0.5" />
353 EXPECT_FALSE(runTest<tesseract_scene_graph::Joint::Ptr>(
359 R"(<joint name="my_joint" type="floating" extra="0 0 0">
360 <origin xyz="0 0 1" rpy="0 0 3.1416"/>
361 <parent link="link1" extra="0 0 0"/>
362 <child extra="0 0 0"/>
363 <calibration rising="0.0"/>
364 <dynamics damping="0.0" friction="0.0"/>
365 <limit effort="30" velocity="1.0" lower="-2.2" upper="0.7" />
366 <safety_controller k_velocity="10" k_position="15" soft_lower_limit="-2.0" soft_upper_limit="0.5" />
369 EXPECT_FALSE(runTest<tesseract_scene_graph::Joint::Ptr>(
375 R"(<joint name="my_joint" type="error" extra="0 0 0">
376 <origin xyz="0 0 1" rpy="0 0 3.1416"/>
377 <parent link="link1" extra="0 0 0"/>
378 <child link="link2" extra="0 0 0"/>
379 <calibration rising="0.0"/>
380 <dynamics damping="0.0" friction="0.0"/>
381 <limit effort="30" velocity="1.0" lower="-2.2" upper="0.7" />
382 <safety_controller k_velocity="10" k_position="15" soft_lower_limit="-2.0" soft_upper_limit="0.5" />
385 EXPECT_FALSE(runTest<tesseract_scene_graph::Joint::Ptr>(
391 R"(<joint name="my_joint" type="floating" extra="0 0 0">
392 <origin xyz="0 0 1" rpy="0 0 3.1416"/>
393 <parent link="link1" extra="0 0 0"/>
394 <child link="link2" extra="0 0 0"/>
396 <dynamics damping="0.0" friction="0.0"/>
397 <limit effort="30" velocity="1.0" lower="-2.2" upper="0.7" />
398 <safety_controller k_velocity="10" k_position="15" soft_lower_limit="-2.0" soft_upper_limit="0.5" />
401 EXPECT_FALSE(runTest<tesseract_scene_graph::Joint::Ptr>(
407 R"(<joint name="my_joint" type="floating" extra="0 0 0">
408 <origin xyz="0 0 1" rpy="0 0 3.1416"/>
409 <parent link="link1" extra="0 0 0"/>
410 <child link="link2" extra="0 0 0"/>
411 <calibration rising="0.0"/>
413 <limit effort="30" velocity="1.0" lower="-2.2" upper="0.7" />
414 <safety_controller k_velocity="10" k_position="15" soft_lower_limit="-2.0" soft_upper_limit="0.5" />
417 EXPECT_FALSE(runTest<tesseract_scene_graph::Joint::Ptr>(
423 R"(<joint name="my_joint" type="revolute" extra="0 0 0">
425 <origin xyz="0 0 1" rpy="0 0 3.1416"/>
426 <parent link="link1" extra="0 0 0"/>
427 <child link="link2" extra="0 0 0"/>
428 <calibration rising="0.0"/>
429 <dynamics damping="0.0" friction="0.0"/>
431 <safety_controller k_velocity="10" k_position="15" soft_lower_limit="-2.0" soft_upper_limit="0.5" />
434 EXPECT_FALSE(runTest<tesseract_scene_graph::Joint::Ptr>(
440 R"(<joint name="my_joint" type="floating" extra="0 0 0">
441 <origin xyz="0 0 1" rpy="0 0 3.1416"/>
442 <parent link="link1" extra="0 0 0"/>
443 <child link="link2" extra="0 0 0"/>
444 <calibration rising="0.0"/>
445 <dynamics damping="0.0" friction="0.0"/>
446 <limit effort="30" velocity="1.0" lower="-2.2" upper="0.7" />
450 EXPECT_FALSE(runTest<tesseract_scene_graph::Joint::Ptr>(
455 std::string str = R"(<joint name="my_joint" type="mimic">
457 <parent link="link1"/>
458 <child link="link2"/>
459 <limit effort="30" velocity="1.0" lower="-2.2" upper="0.7" />
460 <mimic multiplier="a" offset="1" />
463 EXPECT_FALSE(runTest<tesseract_scene_graph::Joint::Ptr>(
468 std::string str = R"(<joint name="my_joint" type="revolute">
470 <parent link="link1"/>
471 <child link="link2"/>
474 EXPECT_FALSE(runTest<tesseract_scene_graph::Joint::Ptr>(
479 TEST(TesseractURDFUnit, write_joint)
491 joint->axis = Eigen::Vector3d::UnitX();
508 joint->axis = Eigen::Vector3d::UnitY();
509 joint->limits = std::make_shared<tesseract_scene_graph::JointLimits>();
510 joint->limits->lower = 1.0;
511 joint->limits->upper = 2.0;
512 joint->safety = std::make_shared<tesseract_scene_graph::JointSafety>();
513 joint->calibration = std::make_shared<tesseract_scene_graph::JointCalibration>();
514 joint->mimic = std::make_shared<tesseract_scene_graph::JointMimic>();
515 joint->dynamics = std::make_shared<tesseract_scene_graph::JointDynamics>();
524 joint->parent_to_joint_origin_transform.translation() = Eigen::Vector3d(1.0, 2.0, 3.0);
526 joint->axis = Eigen::Vector3d::UnitY();
527 joint->limits = std::make_shared<tesseract_scene_graph::JointLimits>();
528 joint->limits->lower = 1.0;
529 joint->limits->upper = 2.0;
530 joint->safety = std::make_shared<tesseract_scene_graph::JointSafety>();
531 joint->calibration = std::make_shared<tesseract_scene_graph::JointCalibration>();
532 joint->mimic = std::make_shared<tesseract_scene_graph::JointMimic>();
533 joint->dynamics = std::make_shared<tesseract_scene_graph::JointDynamics>();
542 joint->axis = Eigen::Vector3d::UnitZ();
543 joint->limits = std::make_shared<tesseract_scene_graph::JointLimits>();
544 joint->limits->acceleration = 1.0;
553 joint->limits = std::make_shared<tesseract_scene_graph::JointLimits>();
554 joint->limits->lower = 1.0;
555 joint->limits->upper = 2.0;
556 joint->axis = Eigen::Vector3d::Ones();
573 joint->limits =
nullptr;
574 joint->axis = Eigen::Vector3d::Ones();
583 joint->limits = std::make_shared<tesseract_scene_graph::JointLimits>();
584 joint->limits->lower = 0.0;
585 joint->limits->upper = 0.0;
586 joint->axis = Eigen::Vector3d::Ones();