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

Visualizing Octomaps on RVIZ [closed]

asked 2016-03-09 13:57:46 -0600

rizasif92 gravatar image

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);
  ros::NodeHandle nh;

  std::cout<<"Reading File"<<std::endl;

  octomap::OcTree* octree = new octomap::OcTree("");
  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);


  while(octomap_publisher.getNumSubscribers() < 1)
       ROS_WARN("Waiting for Subscribers");

  return 0;

According to the reference link the file should be read correctly but the error I receive is:

ERROR: Filestream to not open, nothing read.

It is an error from within octomap::OcTree can someone help?

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2017-04-20 14:53:45.758384

1 Answer

Sort by ยป oldest newest most voted

answered 2016-03-10 03:49:59 -0600

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.

edit flag offensive delete link more


Also check whether the file extension should be ".ot". .bt are binary octrees, .ot octrees. Not sure if it matters though.

Felix Endres gravatar image Felix Endres  ( 2016-03-10 08:17:34 -0600 )edit

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.

rizasif92 gravatar image rizasif92  ( 2016-03-10 14:35:14 -0600 )edit

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).

rizasif92 gravatar image rizasif92  ( 2016-03-10 14:38:36 -0600 )edit

If you get no answer here, try to raise the issue at the github page

Felix Endres gravatar image Felix Endres  ( 2016-03-11 10:52:18 -0600 )edit

Question Tools

1 follower


Asked: 2016-03-09 13:55:43 -0600

Seen: 1,833 times

Last updated: Mar 10 '16