iKrishneel / octomap_server2

ROS2 stack for mapping with OctoMap, contains octomap_server package
74 stars 33 forks source link

No callbacks triggered using default qos #7

Closed tim-fan closed 3 years ago

tim-fan commented 3 years ago

Hello, just noting an issue I had (testing on foxy);

I noticed in my case the point cloud callback was not running, and traced this down to qos settings. It seems that the message_filters subscriber defaults to qos rmw_qos_profile_default. With the following diff I fixed this by changing qos to rmw_qos_profile_sensor_data:

diff --git a/include/octomap_server2/octomap_server.hpp b/include/octomap_server2/octomap_server.hpp
index b185818..9dca3fd 100644
--- a/include/octomap_server2/octomap_server.hpp
+++ b/include/octomap_server2/octomap_server.hpp
@@ -7,6 +7,7 @@

 #include <rclcpp/rclcpp.hpp>
 #include <rclcpp_components/register_node_macro.hpp>
+#include <rmw/qos_profiles.h>

 #include <visualization_msgs/msg/marker_array.hpp>
 #include <nav_msgs/msg/occupancy_grid.hpp>
diff --git a/src/octomap_server.cpp b/src/octomap_server.cpp
index ce4f40b..60b202f 100644
--- a/src/octomap_server.cpp
+++ b/src/octomap_server.cpp
@@ -190,7 +190,7 @@ namespace octomap_server {
     void OctomapServer::subscribe() {
         this->m_pointCloudSub = std::make_shared<
             message_filters::Subscriber<sensor_msgs::msg::PointCloud2>>(
-                this, "cloud_in");
+                this, "cloud_in", rmw_qos_profile_sensor_data);

         auto create_timer_interface = std::make_shared<tf2_ros::CreateTimerROS>(
             this->get_node_base_interface(),

I'm not sure if it makes sense to make rmw_qos_profile_sensor_data the default setting, or if there's a better way of managing this. Just thought I'd note this here in case others have the same problem.

iKrishneel commented 3 years ago

@tim-fan thanks for noting this.

I'm not sure if it makes sense to make rmw_qos_profile_sensor_data the default setting

It's tricky and may depend on the resource.

How about PR the changes you suggested in this issue?

tim-fan commented 3 years ago

Awesome, thanks for merging, and thanks for this ROS2 port! I'm finding it very useful 👍