Skip to content

Commit 3c84820

Browse files
mpowelsonLevi-Armstrong
authored andcommitted
Add unit test for generateSkeletonSeed
1 parent 8bb9831 commit 3c84820

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

tesseract/tesseract_planning/tesseract_command_language/include/tesseract_command_language/manipulator_info.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ class ToolCenterPoint
8989
*/
9090
const Eigen::Isometry3d& getTransform() const;
9191

92+
bool operator==(const ToolCenterPoint& other) const
93+
{
94+
bool ret_val = true;
95+
ret_val &= (type_ == other.type_);
96+
ret_val &= (name_ == other.name_);
97+
ret_val &= (transform_.isApprox(transform_, 1e-5));
98+
return ret_val;
99+
}
100+
92101
protected:
93102
int type_{ 0 };
94103
std::string name_;
@@ -134,6 +143,16 @@ struct ManipulatorInfo
134143
bool empty() const;
135144

136145
tinyxml2::XMLElement* toXML(tinyxml2::XMLDocument& doc) const;
146+
147+
bool operator==(const ManipulatorInfo& other) const
148+
{
149+
bool ret_val = true;
150+
ret_val &= (manipulator == other.manipulator);
151+
ret_val &= (manipulator_ik_solver == other.manipulator_ik_solver);
152+
ret_val &= (tcp == other.tcp);
153+
ret_val &= (working_frame == other.working_frame);
154+
return ret_val;
155+
}
137156
};
138157
} // namespace tesseract_planning
139158

tesseract/tesseract_planning/tesseract_command_language/test/utils_test.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,58 @@ TEST(TesseractCommandLanguageUtilsUnit, clampToJointLimits)
428428
}
429429
}
430430

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+
431483
int main(int argc, char** argv)
432484
{
433485
testing::InitGoogleTest(&argc, argv);

0 commit comments

Comments
 (0)