Rosanswers logo

I have two objects. The first object is my robot which I want to represent it as a shpare and the second object is the obstacle that has unkonwn shape. I want to represent the shape of the obstacle with octree.

how can i use the api of the fcl to check collision between these two objects ( true or false) usinf fcl libraries using the api form ROS wiki? giving that the robot is moving.

Also, the obstacle is detected using laser scan data?? how to fill it in octree object ??


I wrote the following code but I dont know how to fill the octree

boost::shared_ptr<Sphere> Shpere0(new Sphere(1));
OcTree* tree = new OcTree(boost::shared_ptr<const octomap::OcTree>(generateOcTree()));
// GJKSolver_indep solver;
GJKSolver_libccd solver;
Vec3f contact_points;
FCL_REAL penetration_depth;
Vec3f normal;
Transform3f tf0, tf1;
tf0.setQuatRotation(Quaternion3f(0, 0, 0, 0));

 // HOW TO FILL the OCTREE HERE with point cloud data ???  
 bool res = solver.shapeIntersect(*Shpere0, tf0, *box1, tf1, &contact_points, &penetration_depth, &normal);
 cout << "contact points: " << contact_points << endl;
 cout << "pen depth: " << penetration_depth << endl;
 cout << "normal: " << normal << endl;
 cout << "result: " << res << endl;
 static const int num_max_contacts = std::numeric_limits<int>::max();
 static const bool enable_contact = true;
 fcl::CollisionResult result;
 fcl::CollisionRequest request(num_max_contacts, enable_contact);
 CollisionObject co0(Shpere0, tf0);
 CollisionObject co1(tree, tf1);
bool res_1 =   fcl::collide(&co0, &co1, request, result);


How can I fill the octree or octmap to be presented as an object and I can use the function collied to check if the shapre ( which represent my robot) is going to collied with the octree or octmap that I should construct from a point cloud data ?

Originally posted by RSA_kustar on ROS Answers with karma: 275 on 2015-02-12

Post score: 1

Original comments

Comment by gvdhoorn on 2015-02-12:
Isn't this a duplicate of Collision detection using FCL by shere and octree objects following Ros wiki?

Comment by RSA_kustar on 2015-02-12:
No that one is general for FCL and and BVH and this one more specified for collision detection and octree.. I thought your comment was an answer !!!

Comment by ap on 2019-03-27:
@RSA_kustar Hi, were you able to check for collisions with the octree as a CollisionObject? Or did you have to convert the tree to boxes like in your other question? Thank you


1 Answer 1


Rosanswers logo

I would recommend looking at the source code for the Octomap Server. Its purpose is to take in a pointcloud and update an octree (this happens in function void OctomapServer::insertCloudCallback).

Originally posted by cyberguy42 with karma: 188 on 2017-05-09

This answer was ACCEPTED on the original site

Post score: 0


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.