octomap functions for reading and writing binaries
--------------------------------------------------------EDIT 20121031 ----------------------------------------------------------
Hi I think I found the problem: I am using the old version of Octomap which does not correspond to the code API. In the code API, there is a class called AbstractOccupancyOcTree, and in order to get a binary file i need to use the writeBinary function from this class. However, after I check out code trunk for ROS electric and compiled it, I cannot find this file included under octomap_mapping/octomap/octomap/include/octomap. Is there any way you can include this class in there? Thanks !!!!!
--------------------------------------------------------EDIT 20121029 ----------------------------------------------------------
here is my code:
int main(int argc, char **argv){ ros::init(argc, argv, "read_write_node"); ros::NodeHandle n; string fileName; string newfileName; cout << " Please input the filename of the map:" << endl; cin >> fileName; cout << " Please input the filename of the map that's going to be output:" << endl; cin >> newfileName; ofstream mapfile(newfileName.c_str(), ios_base::binary); if (!mapfile.is_open()){ ROS_ERROR("Could not open file %s for writing", newfileName.c_str()); } else { octomap::AbstractOcTree tree(fileName); cout << "Phase 1" << endl; octomath::Pose6D origin(0,0,0,0,0,0); cout << "Phase 2" << endl; tree.write(newfileName); } return 0; }
However, the input file and output file doesn't have the same size. The input file is 214KB while the output file becomes 203KB. Would you please offer some suggestions on where this issue would come from?? Thanks !!
--------------------------------------------------------Original ----------------------------------------------------------
Hi, I am trying to write a program that takes in a binary file which is a 3D map generated by Octomap map_saver and rotate or tilt it and then write it out. So are there any functions I can look into and use ?
Right now for reading I am using the constructor of Octomap::OcTree and writing using Octomap::writeMap. My code is as follows:
octomap::OcTree *tree(fileName); octomath::Pose6D origin(0,0,0,0,0,0); octomap::MapNode<octomap::octree> octomap(tree,origin); octomap.writeMap(newfileName);
But the weird thing is the input file and output file don't have the same file so i suspect these two read and write functions are not a good match. Can someone give some advice on this ? Thanks!!