Visualizing Octomaps on RVIZ
Hi, I am using the following link as a reference.
http://www2.informatik.uni-freiburg.de/~hornunga/pub/hornung13roscon.pdf
I wanted to display an octomap on RVIZ using a data set provided on
http://ais.informatik.uni-freiburg.de/projects/datasets/octomap/
My code is provided below:
#include <ros/ros.h>
#include <octomap_msgs/conversions.h>
#include <octomap_msgs/Octomap.h>
#include <octomap_msgs/GetOctomap.h>
#include <octomap_ros/conversions.h>
int main(int argc, char** argv){
ros::init(argc, argv, "octomap_read");
ros::AsyncSpinner spinner(1);
spinner.start();
ros::NodeHandle nh;
std::cout<<"Reading File"<<std::endl;
octomap::OcTree* octree = new octomap::OcTree("freiburg1_360.bt");
std::cout << "File Read Sccessfully" << std::endl;
for(octomap::OcTree::leaf_iterator it = octree->begin_leafs(),
end=octree->end_leafs(); it!= end; ++it)
{
std::cout << "Node center: " << it.getCoordinate();
std::cout << " value: " << it->getValue() << "\n";
}
octomap_msgs::Octomap bmap_msg;
octomap_msgs::binaryMapToMsg(*octree, bmap_msg);
ros::Publisher octomap_publisher = nh.advertise<octomap_msgs::Octomap>("display_env",1);
octomap_publisher.publish(bmap_msg);
while(octomap_publisher.getNumSubscribers() < 1)
{
ROS_WARN("Waiting for Subscribers");
}
ros::shutdown();
return 0;
}
According to the reference link the file should be read correctly but the error I receive is:
ERROR: Filestream to freiburg1_360.bt not open, nothing read.
It is an error from within octomap::OcTree can someone help?
Asked by rizasif92 on 2016-03-09 14:55:43 UTC
Answers
This may sound simple, but have you checked the file name is correct and it's in the right path on your computer. The working path of the node will be the directory you're in when you execute it, but the path the binary file is actually in.
If you're working on linux you can use the following code to check what the current working path of your node is:
char path[1024]; getcwd(path, sizeof(path)); ROS_INFO("Current path is [%s]", path);
If it the filename and path are correct you might need to check the file permissions. Let us know how you get on.
Asked by PeteBlackerThe3rd on 2016-03-10 04:49:59 UTC
Comments
Also check whether the file extension should be ".ot". .bt are binary octrees, .ot octrees. Not sure if it matters though.
Asked by Felix Endres on 2016-03-10 09:17:34 UTC
Hi Felix, thanks for the comment. About the file type yes I made sure that I'm using the right code as provided in the reference link. I tried to use both ".ot" and ".bt" files downloaded from the same site and relevant approach; but the result is same.
Asked by rizasif92 on 2016-03-10 15:35:14 UTC
About the file path; I'm pretty sure there is not problem with that. Because I created my own ".bt" file and placed it in the same folder. My own file was read successfully by this very code (just by changing the file name in the initializer).
Asked by rizasif92 on 2016-03-10 15:38:36 UTC
If you get no answer here, try to raise the issue at the github page
Asked by Felix Endres on 2016-03-11 11:52:18 UTC
Comments