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

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

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

JoshMarino gravatar image

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

Hello,

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 - mesh.binvox.bt. ./binvox2bt --mark-free /path/to/mesh/mesh.binvox

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

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);
  spinner.start();
  ros::NodeHandle nh;

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

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

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

  octomap_publisher.publish(bmap_msg); 

  while(octomap_publisher.getNumSubscribers() < 1)
  {
      ROS_WARN("Waiting for Subscribers");
      ros::Duration(1.0).sleep();
  }

  ros::shutdown();
  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 octomap.data.size().

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?

Thanks

edit retag flag offensive close merge delete

Comments

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

1 Answer

Sort by ยป oldest newest most voted
0

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

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

Question Tools

1 follower

Stats

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

Seen: 513 times

Last updated: Jul 26 '17