1 #ifndef TESSERACT_COLLISION_COLLISION_OCTOMAP_MESH_UNIT_HPP
2 #define TESSERACT_COLLISION_COLLISION_OCTOMAP_MESH_UNIT_HPP
7 #include <console_bridge/console.h>
26 std::string path = locator.
locateResource(
"package://tesseract_support/meshes/box_2m.bt")->getFilePath();
27 auto ot = std::make_shared<octomap::OcTree>(path);
30 Eigen::Isometry3d octomap_pose;
31 octomap_pose.setIdentity();
35 obj1_shapes.push_back(dense_octomap);
36 obj1_poses.push_back(octomap_pose);
38 checker.addCollisionObject(
"octomap_link", 0, obj1_shapes, obj1_poses);
43 CollisionShapePtr sphere = tesseract_geometry::createMeshFromPath<tesseract_geometry::Mesh>(
44 locator.
locateResource(
"package://tesseract_support/meshes/plane_4m.stl")->getFilePath(),
45 Eigen::Vector3d(1, 1, 1),
48 Eigen::Isometry3d sphere_pose;
49 sphere_pose.setIdentity();
53 obj2_shapes.push_back(sphere);
54 obj2_poses.push_back(sphere_pose);
56 checker.addCollisionObject(
"plane_link", 0, obj2_shapes, obj2_poses);
58 EXPECT_TRUE(checker.getCollisionObjects().size() == 2);
59 for (
const auto& co : checker.getCollisionObjects())
61 EXPECT_TRUE(checker.getCollisionObjectGeometries(co).size() == 1);
62 EXPECT_TRUE(checker.getCollisionObjectGeometriesTransforms(co).size() == 1);
63 for (
const auto& cgt : checker.getCollisionObjectGeometriesTransforms(co))
65 EXPECT_TRUE(cgt.isApprox(Eigen::Isometry3d::Identity(), 1e-5));
82 std::vector<std::string> active_links{
"octomap_link",
"plane_link" };
85 EXPECT_TRUE(tesseract_common::isIdentical<std::string>(active_links, check_active_links,
false));
96 location[
"octomap_link"] = Eigen::Isometry3d::Identity();
97 location[
"plane_link"] = Eigen::Isometry3d::Identity();
98 location[
"plane_link"].translation() = Eigen::Vector3d(0, 0, 0);
109 const auto& mesh = std::static_pointer_cast<const tesseract_geometry::Mesh>(geom.at(0));
110 const auto& mesh_vertices = mesh->getVertices();
111 const auto& mesh_triangles = mesh->getFaces();
114 std::vector<Eigen::Vector3i> mesh_vertices_color(mesh_vertices->size(), Eigen::Vector3i(0, 128, 0));
116 for (
auto&
r : result_vector)
119 if (
r.link_names[0] !=
"plane_link")
122 mesh_vertices_color[
static_cast<std::size_t
>(
123 (*mesh_triangles)[4 *
r.subshape_id[
static_cast<std::size_t
>(idx)] + 1])] = Eigen::Vector3i(255, 0, 0);
124 mesh_vertices_color[
static_cast<std::size_t
>(
125 (*mesh_triangles)[4 *
r.subshape_id[
static_cast<std::size_t
>(idx)] + 2])] = Eigen::Vector3i(255, 0, 0);
126 mesh_vertices_color[
static_cast<std::size_t
>(
127 (*mesh_triangles)[4 *
r.subshape_id[
static_cast<std::size_t
>(idx)] + 3])] = Eigen::Vector3i(255, 0, 0);
130 writeSimplePlyFile(file_path, *mesh_vertices, mesh_vertices_color, *mesh_triangles, mesh->getFaceCount());
137 #endif // TESSERACT_COLLISION_COLLISION_OCTOMAP_MESH_UNIT_HPP