1 #ifndef TESSERACT_COLLISION_COLLISION_CLONE_UNIT_HPP
2 #define TESSERACT_COLLISION_COLLISION_CLONE_UNIT_HPP
18 Eigen::Isometry3d sphere_pose;
19 sphere_pose.setIdentity();
23 obj1_shapes.push_back(sphere);
24 obj1_poses.push_back(sphere_pose);
26 checker.addCollisionObject(
"sphere_link", 0, obj1_shapes, obj1_poses);
27 EXPECT_TRUE(checker.isCollisionObjectEnabled(
"sphere_link"));
32 CollisionShapePtr thin_box = std::make_shared<tesseract_geometry::Box>(0.1, 1, 1);
33 Eigen::Isometry3d thin_box_pose;
34 thin_box_pose.setIdentity();
38 obj2_shapes.push_back(thin_box);
39 obj2_poses.push_back(thin_box_pose);
41 checker.addCollisionObject(
"thin_box_link", 0, obj2_shapes, obj2_poses,
false);
42 EXPECT_FALSE(checker.isCollisionObjectEnabled(
"thin_box_link"));
50 Eigen::Isometry3d sphere1_pose;
51 sphere1_pose.setIdentity();
55 obj3_shapes.push_back(sphere1);
56 obj3_poses.push_back(sphere1_pose);
58 checker.addCollisionObject(
"sphere1_link", 0, obj3_shapes, obj3_poses);
59 EXPECT_TRUE(checker.isCollisionObjectEnabled(
"sphere1_link"));
64 CollisionShapePtr remove_box = std::make_shared<tesseract_geometry::Box>(0.1, 1, 1);
65 Eigen::Isometry3d remove_box_pose;
66 remove_box_pose.setIdentity();
70 obj4_shapes.push_back(remove_box);
71 obj4_poses.push_back(remove_box_pose);
73 checker.addCollisionObject(
"remove_box_link", 0, obj4_shapes, obj4_poses);
74 EXPECT_TRUE(checker.getCollisionObjects().size() == 4);
75 EXPECT_TRUE(checker.hasCollisionObject(
"remove_box_link"));
76 EXPECT_TRUE(checker.isCollisionObjectEnabled(
"remove_box_link"));
77 checker.removeCollisionObject(
"remove_box_link");
78 EXPECT_FALSE(checker.hasCollisionObject(
"remove_box_link"));
83 EXPECT_FALSE(checker.removeCollisionObject(
"link_does_not_exist"));
84 EXPECT_FALSE(checker.enableCollisionObject(
"link_does_not_exist"));
85 EXPECT_FALSE(checker.disableCollisionObject(
"link_does_not_exist"));
86 EXPECT_FALSE(checker.isCollisionObjectEnabled(
"link_does_not_exist"));
97 EXPECT_TRUE(checker.getCollisionObjects().size() == 3);
98 for (
const auto& co : checker.getCollisionObjects())
100 EXPECT_TRUE(checker.getCollisionObjectGeometries(co).size() == 1);
101 EXPECT_TRUE(checker.getCollisionObjectGeometriesTransforms(co).size() == 1);
102 for (
const auto& cgt : checker.getCollisionObjectGeometriesTransforms(co))
104 EXPECT_TRUE(cgt.isApprox(Eigen::Isometry3d::Identity(), 1e-5));
125 std::vector<std::string> active_links{
"sphere_link",
"sphere1_link" };
128 EXPECT_TRUE(tesseract_common::isIdentical<std::string>(active_links, check_active_links,
false));
140 location[
"sphere_link"] = Eigen::Isometry3d::Identity();
141 location[
"sphere1_link"] = Eigen::Isometry3d::Identity();
142 location[
"sphere1_link"].translation()(0) = 0.2;
152 std::vector<int> idx = { 0, 1, 1 };
153 if (result_vector[0].link_names[0] !=
"sphere_link")
165 std::vector<int> cloned_idx = { 0, 1, 1 };
166 if (cloned_result_vector[0].link_names[0] !=
"sphere_link")
167 cloned_idx = { 1, 0, -1 };
169 EXPECT_FALSE(cloned_checker->isCollisionObjectEnabled(
"thin_box_link"));
170 EXPECT_TRUE(!result_vector.empty() && !cloned_result_vector.empty());
172 EXPECT_NEAR(result_vector[0].nearest_points[
static_cast<size_t>(idx[0])][0],
173 cloned_result_vector[0].nearest_points[
static_cast<size_t>(cloned_idx[0])][0],
175 EXPECT_NEAR(result_vector[0].nearest_points[
static_cast<size_t>(idx[0])][1],
176 cloned_result_vector[0].nearest_points[
static_cast<size_t>(cloned_idx[0])][1],
178 EXPECT_NEAR(result_vector[0].nearest_points[
static_cast<size_t>(idx[0])][2],
179 cloned_result_vector[0].nearest_points[
static_cast<size_t>(cloned_idx[0])][2],
181 EXPECT_NEAR(result_vector[0].nearest_points[
static_cast<size_t>(idx[1])][0],
182 cloned_result_vector[0].nearest_points[
static_cast<size_t>(cloned_idx[1])][0],
184 EXPECT_NEAR(result_vector[0].nearest_points[
static_cast<size_t>(idx[1])][1],
185 cloned_result_vector[0].nearest_points[
static_cast<size_t>(cloned_idx[1])][1],
187 EXPECT_NEAR(result_vector[0].nearest_points[
static_cast<size_t>(idx[1])][2],
188 cloned_result_vector[0].nearest_points[
static_cast<size_t>(cloned_idx[1])][2],
190 EXPECT_NEAR(result_vector[0].normal[0] * idx[2], cloned_result_vector[0].normal[0] * cloned_idx[2], normal_tol);
191 EXPECT_NEAR(result_vector[0].normal[1] * idx[2], cloned_result_vector[0].normal[1] * cloned_idx[2], normal_tol);
192 EXPECT_NEAR(result_vector[0].normal[2] * idx[2], cloned_result_vector[0].normal[2] * cloned_idx[2], normal_tol);
195 #endif // TESSERACT_COLLISION_COLLISION_CLONE_UNIT_HPP