@@ -495,6 +495,90 @@ tesseract_scene_graph::SceneGraph buildTestSceneGraph()
495495 return g;
496496}
497497
498+ TEST (TesseractSceneGraphUnit, GetSourceLinkUnit) // NOLINT
499+ {
500+ using namespace tesseract_scene_graph ;
501+ SceneGraph g = buildTestSceneGraph ();
502+
503+ for (int i = 1 ; i <= 3 ; ++i)
504+ {
505+ std::string link_name = " link_" + std::to_string (i);
506+ std::string joint_name = " joint_" + std::to_string (i);
507+ Link::ConstPtr l = g.getSourceLink (joint_name);
508+ Joint::ConstPtr j = g.getJoint (joint_name);
509+ EXPECT_EQ (l->getName (), link_name);
510+ EXPECT_EQ (j->parent_link_name , link_name);
511+ EXPECT_TRUE (g.getLink (link_name) == l);
512+ }
513+ }
514+
515+ TEST (TesseractSceneGraphUnit, GetTargetLinkUnit) // NOLINT
516+ {
517+ using namespace tesseract_scene_graph ;
518+ SceneGraph g = buildTestSceneGraph ();
519+
520+ for (int i = 1 ; i <= 3 ; ++i)
521+ {
522+ std::string link_name = " link_" + std::to_string (i + 1 );
523+ std::string joint_name = " joint_" + std::to_string (i);
524+ Link::ConstPtr l = g.getTargetLink (joint_name);
525+ Joint::ConstPtr j = g.getJoint (joint_name);
526+ EXPECT_EQ (l->getName (), link_name);
527+ EXPECT_EQ (j->child_link_name , link_name);
528+ EXPECT_TRUE (g.getLink (link_name) == l);
529+ }
530+ }
531+
532+ TEST (TesseractSceneGraphUnit, GetInboundJointsUnit) // NOLINT
533+ {
534+ using namespace tesseract_scene_graph ;
535+ SceneGraph g = buildTestSceneGraph ();
536+
537+ for (int i = 2 ; i <= 4 ; ++i)
538+ {
539+ std::string link_name = " link_" + std::to_string (i);
540+ std::string joint_name = " joint_" + std::to_string (i - 1 );
541+ std::vector<Joint::ConstPtr> j = g.getInboundJoints (link_name);
542+ Link::ConstPtr l = g.getLink (link_name);
543+ EXPECT_EQ (j.size (), 1 );
544+ EXPECT_EQ (j[0 ]->getName (), joint_name);
545+ EXPECT_EQ (j[0 ]->child_link_name , link_name);
546+ EXPECT_TRUE (g.getJoint (joint_name) == j[0 ]);
547+ }
548+ }
549+
550+ TEST (TesseractSceneGraphUnit, GetOutboundJointsUnit) // NOLINT
551+ {
552+ using namespace tesseract_scene_graph ;
553+ SceneGraph g = buildTestSceneGraph ();
554+
555+ for (int i = 1 ; i <= 3 ; ++i)
556+ {
557+ std::string link_name = " link_" + std::to_string (i);
558+ std::string joint_name = " joint_" + std::to_string (i);
559+ std::vector<Joint::ConstPtr> j = g.getOutboundJoints (link_name);
560+ Link::ConstPtr l = g.getLink (link_name);
561+ if (i == 2 )
562+ {
563+ EXPECT_EQ (j.size (), 2 );
564+ EXPECT_EQ (j[0 ]->getName (), joint_name);
565+ EXPECT_EQ (j[0 ]->parent_link_name , link_name);
566+ EXPECT_TRUE (g.getJoint (joint_name) == j[0 ]);
567+
568+ EXPECT_EQ (j[1 ]->getName (), " joint_4" );
569+ EXPECT_EQ (j[1 ]->parent_link_name , link_name);
570+ EXPECT_TRUE (g.getJoint (" joint_4" ) == j[1 ]);
571+ }
572+ else
573+ {
574+ EXPECT_EQ (j.size (), 1 );
575+ EXPECT_EQ (j[0 ]->getName (), joint_name);
576+ EXPECT_EQ (j[0 ]->parent_link_name , link_name);
577+ EXPECT_TRUE (g.getJoint (joint_name) == j[0 ]);
578+ }
579+ }
580+ }
581+
498582TEST (TesseractSceneGraphUnit, LoadKDLUnit) // NOLINT
499583{
500584 using namespace tesseract_scene_graph ;
@@ -831,10 +915,14 @@ TEST(TesseractSceneGraphUnit, TesseractSceneGraphInsertWithJointWithPrefixUnit)
831915 acm.addAllowedCollision (" link1" , " link3" , " test" );
832916 g.getAllowedCollisionMatrix ()->insertAllowedCollisionMatrix (acm);
833917 EXPECT_EQ (g.getAllowedCollisionMatrix ()->getAllAllowedCollisions ().size (), 2 );
918+ EXPECT_TRUE (g.isCollisionAllowed (" link1" , " link2" ));
919+ EXPECT_TRUE (g.isCollisionAllowed (" link1" , " link3" ));
834920
835921 tesseract_scene_graph::SceneGraph ng = buildTestSceneGraph ();
836922 ng.getAllowedCollisionMatrix ()->insertAllowedCollisionMatrix (acm);
837923 EXPECT_EQ (ng.getAllowedCollisionMatrix ()->getAllAllowedCollisions ().size (), 2 );
924+ EXPECT_TRUE (ng.isCollisionAllowed (" link1" , " link2" ));
925+ EXPECT_TRUE (ng.isCollisionAllowed (" link1" , " link3" ));
838926
839927 std::string prefix = " r1::" ;
840928
0 commit comments