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:
Used
meshlab
to export mesh.dae into mesh.stl.Used binvox to convert mesh.stl into mesh.binvoz.
./binvox /path/to/mesh/mesh.stl
Used binvox2b to convert mesh.binvox into - mesh.binvox.bt.
./binvox2bt --mark-free /path/to/mesh/mesh.binvox
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
Originally posted by JoshMarino on ROS Answers with karma: 592 on 2017-07-26
Post score: 0
Original comments
Comment by William on 2017-07-26:
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.