1#ifndef TESSERACT_COLLISION_COLLISION_BOX_SPHERE_UNIT_HPP
2#define TESSERACT_COLLISION_COLLISION_BOX_SPHERE_UNIT_HPP
13inline void addCollisionObjects(DiscreteContactManager& checker,
bool use_convex_mesh =
false)
19 Eigen::Isometry3d box_pose;
20 box_pose.setIdentity();
24 obj1_shapes.push_back(
box);
25 obj1_poses.push_back(box_pose);
27 checker.addCollisionObject(
"box_link", 0, obj1_shapes, obj1_poses,
false);
28 checker.enableCollisionObject(
"box_link");
33 CollisionShapePtr thin_box = std::make_shared<tesseract_geometry::Box>(0.1, 1, 1);
34 Eigen::Isometry3d thin_box_pose;
35 thin_box_pose.setIdentity();
39 obj2_shapes.push_back(thin_box);
40 obj2_poses.push_back(thin_box_pose);
42 checker.addCollisionObject(
"thin_box_link", 0, obj2_shapes, obj2_poses);
43 checker.disableCollisionObject(
"thin_box_link");
53 auto mesh_vertices = std::make_shared<tesseract_common::VectorVector3d>();
54 auto mesh_faces = std::make_shared<Eigen::VectorXi>();
56 std::string(TESSERACT_SUPPORT_DIR) +
"/meshes/sphere_p25m.ply", *mesh_vertices, *mesh_faces,
true),
59 auto mesh = std::make_shared<tesseract_geometry::Mesh>(mesh_vertices, mesh_faces);
64 sphere = std::make_shared<tesseract_geometry::Sphere>(0.25);
67 Eigen::Isometry3d sphere_pose;
68 sphere_pose.setIdentity();
72 obj3_shapes.push_back(
sphere);
73 obj3_poses.push_back(sphere_pose);
75 checker.addCollisionObject(
"sphere_link", 0, obj3_shapes, obj3_poses);
80 CollisionShapePtr remove_box = std::make_shared<tesseract_geometry::Box>(0.1, 1, 1);
81 Eigen::Isometry3d remove_box_pose;
82 thin_box_pose.setIdentity();
86 obj4_shapes.push_back(remove_box);
87 obj4_poses.push_back(remove_box_pose);
89 checker.addCollisionObject(
"remove_box_link", 0, obj4_shapes, obj4_poses);
90 EXPECT_TRUE(checker.getCollisionObjects().size() == 4);
91 EXPECT_TRUE(checker.hasCollisionObject(
"remove_box_link"));
92 checker.removeCollisionObject(
"remove_box_link");
93 EXPECT_FALSE(checker.hasCollisionObject(
"remove_box_link"));
98 EXPECT_FALSE(checker.removeCollisionObject(
"link_does_not_exist"));
99 EXPECT_FALSE(checker.enableCollisionObject(
"link_does_not_exist"));
100 EXPECT_FALSE(checker.disableCollisionObject(
"link_does_not_exist"));
111 EXPECT_TRUE(checker.getCollisionObjects().size() == 3);
112 for (
const auto& co : checker.getCollisionObjects())
114 EXPECT_TRUE(checker.getCollisionObjectGeometries(co).size() == 1);
115 EXPECT_TRUE(checker.getCollisionObjectGeometriesTransforms(co).size() == 1);
116 for (
const auto& cgt : checker.getCollisionObjectGeometriesTransforms(co))
118 EXPECT_TRUE(cgt.isApprox(Eigen::Isometry3d::Identity(), 1e-5));
128 std::vector<std::string>
active_links{
"box_link",
"sphere_link" };
140 location[
"box_link"] = Eigen::Isometry3d::Identity();
141 location[
"sphere_link"] = Eigen::Isometry3d::Identity();
142 location[
"sphere_link"].translation()(0) = 0.2;
155 std::vector<int> idx = { 0, 1, 1 };
184 location[
"sphere_link"].translation() = Eigen::Vector3d(1, 0, 0);
241 std::vector<std::string>
active_links{
"box_link",
"sphere_link" };
253 location[
"box_link"] = Eigen::Isometry3d::Identity();
254 location[
"sphere_link"] = Eigen::Isometry3d::Identity();
255 location[
"sphere_link"].translation()(0) = 0.2;
270 std::vector<int> idx = { 0, 1, 1 };
287 EXPECT_LT(std::abs(std::acos((idx[2] *
result_vector[0].
normal).dot(Eigen::Vector3d(1, 0, 0)))), 0.00001);
292 location[
"sphere_link"].translation() = Eigen::Vector3d(1, 0, 0);
335 EXPECT_LT(std::abs(std::acos((idx[2] *
result_vector[0].
normal).dot(Eigen::Vector3d(1, 0, 0)))), 0.00001);
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 addCollisionObjects(ContinuousContactManager &checker)
Definition: collision_box_box_cast_unit.hpp:11
void runTestConvex(DiscreteContactManager &checker)
Definition: collision_box_sphere_unit.hpp:236
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 box
Definition: tesseract_geometry_unit.cpp:18
auto sphere
Definition: tesseract_geometry_unit.cpp:23
auto mesh
Definition: tesseract_geometry_unit.cpp:25