ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Can't convert OcTree to Fcl

asked 2019-04-14 09:53:47 -0500

Costuz gravatar image

updated 2019-04-14 15:41:06 -0500

Hello everyone,

I'm trying to create a code for 2D collision checking using fcl and octomap.

Here i'm trying to convert the octomap::octree to fcl::octree so that i can use the function: "generateBoxesFromOctomap".

I am following this program as a guide: link

I'm using ROS kinetic on Ubuntu 16.04, fcl is version 0.6.

This is my code:

   OcTree* octTree = new OcTree(0.1);
   Pointcloud octPointCloud;

   for (int x=-20; x<20; x++) {
   for (int y=-20; y<20; y++) {
   point3d endpoint ((float) x*0.05f, (float) y*0.05f, (float) 0.0);
   if (endpoint.x() < 0.7 && endpoint.x() > 0.3 && endpoint.y()< 0.6 && endpoint.y() > 0.8)          //size of the obstacle
   octPointCloud.push_back(endpoint); 
      } 
    }
  point3d origin(0.0,0.0,0.0);
  octTree->insertPointCloud(octPointCloud,origin);
  octTree->updateInnerOccupancy();     

  //convert the octomap 
  fcl::OcTree<double>* tree2 = new fcl::OcTree(boost::shared_ptr<const octomap::OcTree>(octTree));
  std::vector<fcl::CollisionObject<double>*> boxes;
  generateBoxesFromOctomap(boxes, *tree2);

but i get this error:

error: expected type-specifier
  fcl::OcTree<double>* tree2 = new fcl::OcTree(boost::shared_ptr<const octomap::OcTree>(octTree))

What can i do?

edit retag flag offensive close merge delete

Comments

1

In a similar working example I have, I am using : fcl::OcTree* tree2, try without using the <double> maybe

kosmastsk gravatar image kosmastsk  ( 2019-04-14 15:02:27 -0500 )edit

Now it gives me two more error:

 error: missing template arguments before ‘*’ token
        fcl::OcTree* tree2 = new fcl::OcTree(boost::shared_ptr<const octomap::OcTree
                   ^
    error: ‘tree2’ was not declared in this scope
        fcl::OcTree* tree2 = new fcl::OcTree(boost::shared_ptr<const octomap::OcTree
                     ^
    error: expected type-specifier
       fcl::OcTree* tree2 = new fcl::OcTree(boost::shared_ptr<const octomap::OcTree
                                ^

don't know what to do

Costuz gravatar image Costuz  ( 2019-04-14 15:21:34 -0500 )edit
1

My fault, my previous comment is for CollisionGeometry type and not ColiisionObject. But, according to this test file, you should have fcl::OcTree<double>* tree2 = new fcl::OcTree<double>(std::shared_ptr<const octomap::OcTree>(octTree));

kosmastsk gravatar image kosmastsk  ( 2019-04-14 15:31:20 -0500 )edit
1

Yes, now it works Thanks for your help!

Costuz gravatar image Costuz  ( 2019-04-14 15:55:39 -0500 )edit

Added the answer below, you may mark it as correct :)

kosmastsk gravatar image kosmastsk  ( 2019-04-14 15:59:05 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2019-04-14 15:58:33 -0500

kosmastsk gravatar image

According to this test file, you should have fcl::OcTree<double>* tree2 = new fcl::OcTree<double>(std::shared_ptr<const octomap::OcTree>(octTree));
instead of fcl::OcTree<double>* tree2 = new fcl::OcTree(boost::shared_ptr<const octomap::OcTree>(octTree));

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-04-14 09:53:47 -0500

Seen: 454 times

Last updated: Apr 14 '19