Ask Your Question

Rviz not showing octomap from converting .dae mesh to .bt

asked 2017-07-26 15:14:38 -0600

JoshMarino gravatar image

updated 2017-07-26 15:16:55 -0600


I am trying to convert a static Collada (.dae) mesh into an octomap_msgs::Octomap. This link was provided to me for assistance. Here are the steps I took:

1) Used meshlab to export mesh.dae into mesh.stl.

2) Used binvox to convert mesh.stl into mesh.binvoz. ./binvox /path/to/mesh/mesh.stl

3) Used binvox2b to convert mesh.binvox into - ./binvox2bt --mark-free /path/to/mesh/mesh.binvox

4) Confirmed I could see Octomap using Octovis. octovis /path/to/mesh/

I then tried using the following ROS C++ code to display the Octomap in Rviz using octomap_rviz_plugins->OccupancyGrid.

#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;

  ros::Publisher octomap_publisher = nh.advertise<octomap_msgs::Octomap>("octomap",1);

  octomap::OcTree* octree = new octomap::OcTree("/path/to/mesh/");  

  octomap_msgs::Octomap bmap_msg;
  octomap_msgs::binaryMapToMsg(*octree, bmap_msg);  

  bmap_msg.header.seq = 0;
  bmap_msg.header.stamp = ros::Time::now();
  bmap_msg.header.frame_id = "base_link"; 


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

  return 0;

However, when running the code, nothing happens and the status stays at 0 binary octomap messages received. If I change the octomap file to an Octomap from OctoMap 3D scan dataset, it works just fine and shows up. I tried examining both octomap_msgs::OctoMap and they are nearly identical. The only difference is the Resolution and octomap.resolution and

What could be going wrong with my Octomap I am creating from a Collada mesh if I can see it using Octovis but not inside of Rviz?


edit retag flag offensive close merge delete


You probably need to publish after waiting for a subscriber or make the publisher latched. I'd also recommend not exiting immediately after publishing. Just spin instead and ctrl-c it when you're done.

William gravatar image William  ( 2017-07-26 15:27:31 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-07-26 15:39:16 -0600

JoshMarino gravatar image

I solved the problem. The OctoMap was too large and was not being received when only publishing it once. I put the publish(octomap) inside of a rate function, and it showed up after a few seconds.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-07-26 15:14:38 -0600

Seen: 248 times

Last updated: Jul 26 '17