read file from binary file and convert into pcd file

937 views
Skip to first unread message

YUE

unread,
Nov 2, 2015, 9:48:45 PM11/2/15
to OctoMap developers and users discussion
hi, sorry for disturbing your guys. I am new to this octomap,so I have so questions may seem to be very simple.

Now I already have the bt file and ot file,and I want to read then followed by the instructions on API.
 
when I read ot file, the code works fine:

 string filenameot = "map1.ot";
 AbstractOcTree* otTree = AbstractOcTree::read(filenameot);

but when i read bt file, here is the problem


string filenamebt = "map1.bt";
AbstractOccupancyOcTree* binaryTree = AbstractOccupancyOcTree::readBinary(filenamebt);

and the error is:

In function ‘int main(int, char**)’:
cannot call member function ‘bool octomap::AbstractOccupancyOcTree::readBinary(const string&)’ without object
AbstractOccupancyOcTree* binaryTree = AbstractOccupancyOcTree::readBinary(filenamebt);
                                                                                         ^
make[2]: *** [CMakeFiles/octo_to_pcd.dir/octo_to_pcd.cpp.o] Error 1
make[1]: *** [CMakeFiles/octo_to_pcd.dir/all] Error 2
make: *** [all] Error 2

Another thing is that I want to convert the bt/ot file into pcl, and I followed some code from Internet

    std::list<octomap::OcTreeVolume> occupiedCells;
    binaryTree.getOccupied(occupiedCells);

    //cloud to store the points
    pcl::PointCloud<pcl::PointXYZ> cloud;
    cloud.points.resize(occupiedCells.size());

    std::list<octomap::OcTreeVolume>::iterator it;
    int i=0;
    for (it = occupiedCells.begin(); it != occupiedCells.end(); ++it, i++)
    {
        //add point in point cloud
        cloud.points[i].x = it->first.x();
        cloud.points[i].y = it->first.y();
        cloud.points[i].z = it->first.z();
    }
    //save cloud
    pcl::io::savePCDFileASCII ("file.pcd", cloud);
   return 0;


But the code doesn't work  anymore, because the h file no longer exist.
So, thank you very much for yuor help!

Armin Hornung

unread,
Nov 3, 2015, 1:39:43 PM11/3/15
to oct...@googlegroups.com
Hi Yue,


Am 03.11.2015 um 03:48 schrieb YUE:
hi, sorry for disturbing your guys. I am new to this octomap,so I have so questions may seem to be very simple.

Now I already have the bt file and ot file,and I want to read then followed by the instructions on API.
 
when I read ot file, the code works fine:

 string filenameot = "map1.ot";
 AbstractOcTree* otTree = AbstractOcTree::read(filenameot);

but when i read bt file, here is the problem
string filenamebt = "map1.bt";
AbstractOccupancyOcTree* binaryTree = AbstractOccupancyOcTree::readBinary(filenamebt);
There is no abstract function like that. You can't read a .bt file like that since it always returns an OcTree (not the abtract base class).
You will have to read a .bt file like here:
https://github.com/OctoMap/octomap/blob/devel/octomap/src/bt2vrml.cpp#L70



Another thing is that I want to convert the bt/ot file into pcl, and I followed some code from Internet

    std::list<octomap::OcTreeVolume> occupiedCells;
binaryTree.getOccupied(occupiedCells);
[...]



But the code doesn't work  anymore, because the h file no longer exist.

No idea what code or error you refer to, so please post an exact source for the code you mentioned. But there is definitely no function "getOccupied" in the OctoMap sources.

Best regards,
Armin
Reply all
Reply to author
Forward
0 new messages