OctoMap / octomap_mapping

ROS stack for mapping with OctoMap, contains octomap_server package
http://www.ros.org/wiki/octomap_mapping
342 stars 280 forks source link

removed redundant publish in reset service #34

Closed hycwuy closed 5 years ago

hycwuy commented 8 years ago

because already publish all and publish empty binary octomap will crash program

ahornung commented 8 years ago

Do you have some details about the crash?

After resetting there should still be an empty map sent out to clear (through publishAll)

With this patch in place, is the MarkerArray visualization of occupied / free nodes properly cleared when calling the reset service?

hycwuy commented 8 years ago

About the crash (Edit: this crash has been fixed in octomap devel branch, see this) **1. feed data to octomap, make sure the map is NOT empty, otherwise the crash will not be triggered

  1. rosservice call /octomap_server_node/reset
  2. here is part of the stack information from GDB:**

0 0x00007ffff65ca0cd in octomap::OccupancyOcTreeBaseoctomap::OcTreeNode::writeBinaryNode(std::ostream&, octomap::OcTreeNode const*) const ()

from /opt/ros/kinetic/lib/liboctomap.so.1.8

1 0x00007ffff65ca352 in octomap::OccupancyOcTreeBaseoctomap::OcTreeNode::writeBinaryData(std::ostream&) const ()

from /opt/ros/kinetic/lib/liboctomap.so.1.8

2 0x00007ffff7aaef4f in octomap_msgs::binaryMapToMsgoctomap::OcTree (

octomap=..., msg=...)
at /opt/ros/kinetic/include/octomap_msgs/conversions.h:172

3 0x00007ffff7aaa889 in octomap_server::OctomapServer::publishBinaryOctoMap (

this=0x7fffffffcb80, rostime=...)
at /home/someone/catkin_ws/src/octomap_mapping/octomap_server/src/OctomapServer.cpp:801

4 0x00007ffff7aaa436 in octomap_server::OctomapServer::resetSrv (

this=0x7fffffffcb80, req=..., resp=...)
at /home/someone/catkin_ws/src/octomap_mapping/octomap_server/src/OctomapServer.cpp:765
hycwuy commented 8 years ago

Another crash (Edit: this crash has been fixed in octomap devel branch, see this) **1. remove publishBinaryOctoMap() in resetSrv(), which will crash the program when map is empty

  1. feed data to octomap, make sure the map is NOT empty, otherwise the crash may not be triggered
  2. rosservice call /octomap_server_node/reset
  3. here is part of the stack information from GDB:**

Thread 1 "octomapserver" received signal SIGSEGV, Segmentation fault. 0x00007ffff7adbea1 in octomap::OcTreeBaseImpl<octomap::OcTreeNode, octomap::AbstractOccupancyOcTree>::nodeChildExists (this=0x64df00, node=0x6c8e20, childIdx=5) at /opt/ros/kinetic/include/octomap/OcTreeBaseImpl.hxx:237 237 if ((node->children != NULL) && (node->children[childIdx] != NULL)) (gdb) bt

0 0x00007ffff7adbea1 in octomap::OcTreeBaseImpl<octomap::OcTreeNode, octomap::AbstractOccupancyOcTree>::nodeChildExists (this=0x64df00, node=0x6c8e20,

childIdx=5) at /opt/ros/kinetic/include/octomap/OcTreeBaseImpl.hxx:237

1 0x00007ffff7ace6c6 in octomap::OcTreeBaseImpl<octomap::OcTreeNode, octomap::AbstractOccupancyOcTree>::search (this=0x64df00, key=..., depth=16)

at /opt/ros/kinetic/include/octomap/OcTreeBaseImpl.hxx:456

2 0x00007ffff65cdebf in octomap::OccupancyOcTreeBaseoctomap::OcTreeNode::updateNode(octomap::OcTreeKey const&, float, bool) ()

from /opt/ros/kinetic/lib/liboctomap.so.1.8

3 0x00007ffff7aa781a in octomap_server::OctomapServer::insertScan (

this=0x7fffffffcb80, sensorOriginTf=..., ground=..., nonground=...)
at /home/someone/catkin_ws/src/octomap_mapping/octomap_server/src/OctomapServer.cpp:441

4 0x00007ffff7aa6044 in octomap_server::OctomapServer::insertCloudCallback (

this=0x7fffffffcb80, cloud=...)
at /home/someone/catkin_ws/src/octomap_mapping/octomap_server/src/OctomapServer.cpp:348
hycwuy commented 8 years ago

After fixing the crash above, I tested again. Because publishAll() skipped empty map, the map was not published until I fed new data to octomap. So with this patch, MarkerArray will not be cleared, but MarkerArray updates properly after feeding new data to octomap. I don't know why publishAll() should skip empty map. In my opinion, empty map should also be published.

ahornung commented 8 years ago

The crash is likely related to https://github.com/OctoMap/octomap/issues/123

It's fixed in the OctoMap devel branch, could you test with that as an overlay? The fix is not released yet.

hycwuy commented 8 years ago

I have tested the latest version in devel branch, it works fine. Thank you!

wxmerkt commented 5 years ago

@hycwuy can this pull request be closed givne that it's working fine?