Visualizing Octomaps on RVIZ [closed]
Hi, I am using the following link as a reference.
I wanted to display an octomap on RVIZ using a data set provided on
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?