Ask Your Question
0

Visualizing Octomaps on RVIZ [closed]

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

rizasif92 gravatar image

Hi, I am using the following link as a reference.

http://www2.informatik.uni-freiburg.d...

I wanted to display an octomap on RVIZ using a data set provided on

http://ais.informatik.uni-freiburg.de...

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?

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
0

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

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

Comments

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 -0500 )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 -0500 )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 -0500 )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 -0500 )edit

Question Tools

1 follower

Stats

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

Seen: 1,485 times

Last updated: Mar 10 '16