1#ifndef TESSERACT_COLLISION_COLLISION_SPHERE_SPHERE_UNIT_HPP
2#define TESSERACT_COLLISION_COLLISION_SPHERE_SPHERE_UNIT_HPP
13inline void addCollisionObjects(DiscreteContactManager& checker,
bool use_convex_mesh =
false)
21 auto mesh_vertices = std::make_shared<tesseract_common::VectorVector3d>();
22 auto mesh_faces = std::make_shared<Eigen::VectorXi>();
24 std::string(TESSERACT_SUPPORT_DIR) +
"/meshes/sphere_p25m.ply", *mesh_vertices, *mesh_faces,
true),
27 auto mesh = std::make_shared<tesseract_geometry::Mesh>(mesh_vertices, mesh_faces);
32 sphere = std::make_shared<tesseract_geometry::Sphere>(0.25);
35 Eigen::Isometry3d sphere_pose;
36 sphere_pose.setIdentity();
40 obj1_shapes.push_back(
sphere);
41 obj1_poses.push_back(sphere_pose);
43 checker.addCollisionObject(
"sphere_link", 0, obj1_shapes, obj1_poses);
48 CollisionShapePtr thin_box = std::make_shared<tesseract_geometry::Box>(0.1, 1, 1);
49 Eigen::Isometry3d thin_box_pose;
50 thin_box_pose.setIdentity();
54 obj2_shapes.push_back(thin_box);
55 obj2_poses.push_back(thin_box_pose);
57 checker.addCollisionObject(
"thin_box_link", 0, obj2_shapes, obj2_poses,
false);
67 auto mesh_vertices = std::make_shared<tesseract_common::VectorVector3d>();
68 auto mesh_faces = std::make_shared<Eigen::VectorXi>();
70 std::string(TESSERACT_SUPPORT_DIR) +
"/meshes/sphere_p25m.ply", *mesh_vertices, *mesh_faces,
true),
73 auto mesh = std::make_shared<tesseract_geometry::Mesh>(mesh_vertices, mesh_faces);
78 sphere1 = std::make_shared<tesseract_geometry::Sphere>(0.25);
81 Eigen::Isometry3d sphere1_pose;
82 sphere1_pose.setIdentity();
86 obj3_shapes.push_back(sphere1);
87 obj3_poses.push_back(sphere1_pose);
89 checker.addCollisionObject(
"sphere1_link", 0, obj3_shapes, obj3_poses);
94 CollisionShapePtr remove_box = std::make_shared<tesseract_geometry::Box>(0.1, 1, 1);
95 Eigen::Isometry3d remove_box_pose;
96 thin_box_pose.setIdentity();
100 obj4_shapes.push_back(remove_box);
101 obj4_poses.push_back(remove_box_pose);
103 checker.addCollisionObject(
"remove_box_link", 0, obj4_shapes, obj4_poses);
104 EXPECT_TRUE(checker.getCollisionObjects().size() == 4);
105 EXPECT_TRUE(checker.hasCollisionObject(
"remove_box_link"));
106 checker.removeCollisionObject(
"remove_box_link");
107 EXPECT_FALSE(checker.hasCollisionObject(
"remove_box_link"));
108 EXPECT_TRUE(checker.getCollisionObjects().size() == 3);
113 EXPECT_FALSE(checker.removeCollisionObject(
"link_does_not_exist"));
114 EXPECT_FALSE(checker.enableCollisionObject(
"link_does_not_exist"));
115 EXPECT_FALSE(checker.disableCollisionObject(
"link_does_not_exist"));
122 EXPECT_TRUE(checker.getCollisionObjects().size() == 3);
130 std::vector<std::string>
active_links{
"sphere_link",
"sphere1_link" };
132 std::vector<std::string> check_active_links = checker.getActiveCollisionObjects();
135 EXPECT_TRUE(checker.getIsContactAllowedFn() ==
nullptr);
138 EXPECT_NEAR(checker.getCollisionMarginData().getMaxCollisionMargin(), 0.1, 1e-5);
142 location[
"sphere_link"] = Eigen::Isometry3d::Identity();
143 location[
"sphere1_link"] = Eigen::Isometry3d::Identity();
144 location[
"sphere1_link"].translation()(0) = 0.2;
145 checker.setCollisionObjectsTransform(location);
148 ContactResultMap result;
157 std::vector<int> idx = { 0, 1, 1 };
189 location[
"sphere1_link"].translation() = Eigen::Vector3d(1, 0, 0);
192 checker.setCollisionObjectsTransform(
"sphere1_link", location[
"sphere1_link"]);
206 EXPECT_NEAR(checker.getCollisionMarginData().getMaxCollisionMargin(), 0.52, 1e-5);
247 std::vector<std::string>
active_links{
"sphere_link",
"sphere1_link" };
259 location[
"sphere_link"] = Eigen::Isometry3d::Identity();
260 location[
"sphere1_link"] = Eigen::Isometry3d::Identity();
261 location[
"sphere1_link"].translation()(0) = 0.2;
276 std::vector<int> idx = { 0, 1, 1 };
301 EXPECT_LT(std::abs(std::acos((idx[2] *
result_vector[0].
normal).dot(Eigen::Vector3d(1, 0, 0)))), 0.5);
306 location[
"sphere1_link"].translation() = Eigen::Vector3d(1, 0, 0);
325 std::vector<std::string>
active_links{
"sphere_link",
"sphere1_link" };
333 location[
"sphere_link"] = Eigen::Isometry3d::Identity();
334 location[
"sphere1_link"] = Eigen::Isometry3d::Identity();
335 location[
"sphere1_link"].translation() = Eigen::Vector3d(1, 0, 0);
350 std::vector<int> idx = { 0, 1, 1 };
367 EXPECT_LT(std::abs(std::acos((idx[2] *
result_vector[0].
normal).dot(Eigen::Vector3d(1, 0, 0)))), 0.00001);
375 std::vector<std::string>
active_links{
"sphere_link",
"sphere1_link" };
386 location[
"sphere1_link"] = Eigen::Isometry3d::Identity();
387 location[
"sphere1_link"].translation()(1) = 0.2;
401 std::vector<int> idx = { 0, 1, 1 };
426 EXPECT_LT(std::abs(std::acos((idx[2] *
result_vector[0].
normal).dot(Eigen::Vector3d(0, 1, 0)))), 0.4);
437inline void runTest(DiscreteContactManager& checker,
bool use_convex_mesh)
double getMaxCollisionMargin() const
Get the largest collision margin.
Definition: collision_margin_data.h:165
EXPECT_NEAR(config.contact_manager_config.margin_data.getDefaultCollisionMargin(), 5, 1e-6)
tesseract_collision::ContactResultVector result_vector
Definition: collision_core_unit.cpp:410
results distance
Definition: collision_core_unit.cpp:139
results link_names[0]
Definition: collision_core_unit.cpp:146
results normal
Definition: collision_core_unit.cpp:154
EXPECT_FALSE(tesseract_collision::isContactAllowed("base_link", "link_2", acm, false))
results nearest_points[0]
Definition: collision_core_unit.cpp:140
results single_contact_point
Definition: collision_core_unit.cpp:161
EXPECT_TRUE(tesseract_common::isIdentical< tesseract_collision::ObjectPairKey >(pairs, check_pairs, false))
This is a collection of common methods.
This is a collection of common methods.
EXPECT_GT(m.m.condition, 1e+20)
void runTestConvex3(DiscreteContactManager &checker)
Definition: collision_sphere_sphere_unit.hpp:370
void runTestConvex2(DiscreteContactManager &checker)
Definition: collision_sphere_sphere_unit.hpp:317
void addCollisionObjects(ContinuousContactManager &checker)
Definition: collision_box_box_cast_unit.hpp:11
void runTestConvex(DiscreteContactManager &checker)
Definition: collision_box_sphere_unit.hpp:236
void runTestConvex1(DiscreteContactManager &checker)
Definition: collision_sphere_sphere_unit.hpp:242
void runTestPrimitive(DiscreteContactManager &checker)
Definition: collision_box_sphere_unit.hpp:123
Definition: large_dataset_benchmarks.hpp:17
void runTest(ContinuousContactManager &checker)
Definition: collision_box_box_cast_unit.hpp:111
tesseract_common::CollisionMarginData CollisionMarginData
Definition: types.h:50
tesseract_geometry::Geometry::Ptr CollisionShapePtr
Definition: types.h:49
std::vector< tesseract_geometry::Geometry::ConstPtr > CollisionShapesConst
Definition: types.h:47
tesseract_common::AlignedVector< ContactResult > ContactResultVector
Definition: types.h:134
int loadSimplePlyFile(const std::string &path, tesseract_common::VectorVector3d &vertices, Eigen::VectorXi &faces, bool triangles_only=false)
Loads a simple ply file given a path.
Definition: common.cpp:285
tesseract_geometry::ConvexMesh::Ptr makeConvexMesh(const tesseract_geometry::Mesh &mesh)
Definition: convex_hull_utils.cpp:114
AlignedMap< std::string, Eigen::Isometry3d > TransformMap
Definition: types.h:66
template bool isIdentical< std::string >(const std::vector< std::string > &, const std::vector< std::string > &, bool, const std::function< bool(const std::string &, const std::string &)> &, const std::function< bool(const std::string &, const std::string &)> &)
AlignedVector< Eigen::Isometry3d > VectorIsometry3d
Definition: types.h:62
std::vector< std::string > active_links
Definition: tesseract_environment_collision.cpp:112
auto sphere
Definition: tesseract_geometry_unit.cpp:23
auto mesh
Definition: tesseract_geometry_unit.cpp:25