OctoMap / octomap_rviz_plugins

RViz display plugins for visualizing octomap messages in ROS
http://ros.org/wiki/octomap_rviz_plugins
89 stars 63 forks source link

Octomap_RVIZ_Plugin crashes when octomap data is empty #10

Closed lsouchet closed 9 years ago

lsouchet commented 9 years ago

On the latest indigo, using the package ros-indigo-octomap-rviz-plugins.

When I publish a message with an empty data array, it makes rviz segfault, with the following error:

z$ rosrun rviz rviz                                                                                [14-11-06 17:03]
[ INFO] [1415289850.007577884]: rviz version 1.11.3
[ INFO] [1415289850.007641335]: compiled against OGRE version 1.8.1 (Byatis)
[ INFO] [1415289850.245712863]: Stereo is NOT SUPPORTED
[ INFO] [1415289850.245825528]: OpenGl version: 3 (GLSL 1.3).
rviz: /opt/ros/indigo/include/octomap_msgs/conversions.h:58: octomap::AbstractOcTree* octomap_msgs::fullMsgToMap(const Octomap&): Assertion `msg.data.size() > 0' failed.

Here is the publisher sample example:

octomap.binary, octomap.id, octomap.resolution, octomap.data = octomap_str_to_tuple(octomap_bin)
if (len(octomap.data) == 0):
  octomap.data = []
self.pub.publish(octomap)

It works when my resulting octomap is not empty. A workaround consist in NOT publishing when the array is empty but that's kind of bothering. Here is the code of the octomap_str_to_tuple() that takes an octree passed as a string with write():

boost::python::tuple octomap_str_to_tuple(const std::string &str_msg)
{
  std::stringstream ss;
  ss << str_msg;
  ss.seekg(0);
  octomap::OcTree* octree = dynamic_cast<octomap::OcTree*>(octomap::OcTree::read(ss));

  octomap_msgs::Octomap msg;
  bool res = octomap_msgs::fullMapToMsg(*octree, msg);

  return boost::python::make_tuple(msg.binary, msg.id, msg.resolution, std_vector_to_py_list(msg.data));
}
lsouchet commented 9 years ago

Here is the output of the rostopic echo /octomap:

z$ rostopic echo /octomap                                                                         [14-11-07 15:48]
header: 
  seq: 62
  stamp: 
    secs: 1415371717
    nsecs: 223220109
  frame_id: /odom
binary: False
id: OcTree
resolution: 0.1
data: []
---

In a loop. When opening rviz and displaying this topic, it crashes as explained.

ahornung commented 9 years ago

Thanks for the report! I just fixed this in the indigo-devel branch at octomap_msgs (https://github.com/OctoMap/octomap_msgs/commit/ba05c79ef9b24d7045bbf26022adbc58bafc7ac6). Once this gets released and octomap_rviz_plugins are rebuilt it should be all fine.