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

generating boxes from octomap::octree error

asked 2015-02-18 01:25:41 -0500

RSA_kustar gravatar image

I am using the fcl where I have an octree and I want to generate boxes from an octree function I used the following code:

    octomap::OcTree* st_tree = new octomap::OcTree(0.1);
    octomap::Pointcloud st_cld;
    // I fill the tree
    for(int i = 0;i<msg.points.size();i++){
        point3d endpoint((float) msg.points[i].x,(float) msg.points[i].y,(float) msg.points[i].z);
    point3d origin(0.0,0.0,0.0);
   std::vector<CollisionObject*> boxes;
   generateBoxesFromOctomap(boxes, *st_tree);

The function is defined as the following:

 void generateBoxesFromOctomap(std::vector<CollisionObject*>& boxes, octomap::OcTree& tree)

    std::vector<boost::array<FCL_REAL, 6> > boxes_ = tree.toBoxes();
    for(std::size_t i = 0; i < boxes_.size(); ++i)
        FCL_REAL x = boxes_[i][0];
        FCL_REAL y = boxes_[i][1];
        FCL_REAL z = boxes_[i][2];
        FCL_REAL size = boxes_[i][3];
        FCL_REAL cost = boxes_[i][4];
        FCL_REAL threshold = boxes_[i][5];
        Box* box = new Box(size, size, size);

        box->cost_density = cost;
        box->threshold_occupied = threshold;
        CollisionObject* obj = new CollisionObject(boost::shared_ptr<CollisionGeometry>(box), Transform3f(Vec3f(x, y, z)));
    std::cout << "boxes size: " << boxes.size() << std::endl;

I get the following error:

     error: ‘class octomap::OcTree’ has no member named ‘toBoxes’
     std::vector<boost::array<FCL_REAL, 6> > boxes_ = tree.toBoxes();

But I included the all the required libraries??

How can I solve it ?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2015-02-21 15:49:17 -0500

AHornung gravatar image

There is no function toBoxes defined in OctoMap, so that code won't work. Best refer to the official OctoMap documentation.

edit flag offensive delete link more

answered 2016-11-24 03:26:02 -0500

Tal gravatar image

You need to convert your octomap::OcTree to fcl::OcTree (is the same class name that why you have the confusion). by convert your octomap::OcTree to std::shared_pointer<const octomap::octree="">. After you have fcl::OcTree instance. you can do toBoxes. You can look at official FCL documentation.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-02-18 01:25:41 -0500

Seen: 615 times

Last updated: Nov 24 '16