@@ -428,6 +428,58 @@ TEST(TesseractCommandLanguageUtilsUnit, clampToJointLimits)
428
428
}
429
429
}
430
430
431
+ TEST (TesseractCommandLanguageUtilsUnit, generateSkeletonSeed)
432
+ {
433
+ // Create a composite
434
+ CompositeInstruction composite;
435
+ composite.setDescription (" generateSkeletonSeed: Composite" );
436
+ composite.setProfile (" COMPOSITE_PROFILE" );
437
+ std::size_t i_max = 4 ;
438
+
439
+ for (std::size_t i = 0 ; i < i_max; i++)
440
+ {
441
+ Waypoint wp = CartesianWaypoint (Eigen::Isometry3d::Identity ());
442
+ PlanInstruction instruction (wp, PlanInstructionType::LINEAR);
443
+ instruction.setDescription (" PlanInstruction" );
444
+ instruction.setProfile (" CART_PROFILE" );
445
+ composite.push_back (instruction);
446
+ }
447
+
448
+ // generateSkeletonSeed
449
+ auto skeleton = generateSkeletonSeed (composite);
450
+
451
+ // Check that high level composite is correct
452
+ EXPECT_EQ (skeleton.getProfile (), composite.getProfile ());
453
+ EXPECT_EQ (skeleton.getOrder (), composite.getOrder ());
454
+ EXPECT_EQ (skeleton.getDescription (), composite.getDescription ());
455
+ EXPECT_EQ (skeleton.getManipulatorInfo (), composite.getManipulatorInfo ());
456
+ // TODO: Test startInstruction
457
+
458
+ // Check that each PlanInstruction has been turned into a CompositeInstruction
459
+ // Check that CompositeInstructions are recursively handled (TODO)
460
+ // Check that non-PlanInstructions are passed through (TODO)
461
+ ASSERT_EQ (skeleton.size (), composite.size ());
462
+ for (std::size_t i = 0 ; i < i_max; i++)
463
+ {
464
+ const auto & skeleton_i = skeleton[i];
465
+ const auto & composite_i = composite[i];
466
+ if (isPlanInstruction (composite_i))
467
+ {
468
+ ASSERT_TRUE (isCompositeInstruction (skeleton_i));
469
+ const auto cast = skeleton_i.cast_const <CompositeInstruction>();
470
+
471
+ EXPECT_EQ (cast->getProfile (), composite_i.cast_const <PlanInstruction>()->getProfile ());
472
+ EXPECT_EQ (cast->getOrder (), CompositeInstructionOrder::ORDERED);
473
+ EXPECT_EQ (cast->getDescription (), " PlanInstruction" );
474
+ EXPECT_EQ (cast->getManipulatorInfo (), composite_i.cast_const <PlanInstruction>()->getManipulatorInfo ());
475
+ }
476
+ else
477
+ {
478
+ EXPECT_EQ (skeleton_i.getType (), composite_i.getType ());
479
+ }
480
+ }
481
+ }
482
+
431
483
int main (int argc, char ** argv)
432
484
{
433
485
testing::InitGoogleTest (&argc, argv);
0 commit comments