Skip to content

Commit 3e8a389

Browse files
committed
QoS: subscribe to filtered pointcloud with SensorDataQoS (BEST_EFFORT); use rclcpp subscription instead of point_cloud_transport for PC2
1 parent 47a74ce commit 3e8a389

File tree

2 files changed

+9
-24
lines changed

2 files changed

+9
-24
lines changed

elevation_mapping_cupy/scripts/elevation_mapping_node.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ def register_subscribers(self) -> None:
240240
# )
241241
# qos_profile = QoSPresetProfiles.get_from_short_key("sensor_data")
242242
# qos_profile = rclpy.qos.QoSProfile(depth=10)
243-
qos_profile = 10
243+
# Use sensor data QoS (BEST_EFFORT) for point clouds
244+
qos_profile = QoSPresetProfiles.get_from_short_key("sensor_data")
244245
subscription = self.create_subscription(
245246
PointCloud2,
246247
topic_name,

elevation_mapping_cupy/src/elevation_mapping_ros.cpp

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ ElevationMappingNode::ElevationMappingNode(const rclcpp::NodeOptions& options)
186186
// rmw_qos_profile_t qos_profile = rmw_qos_profile_default;
187187
// auto qos = rclcpp::QoS(rclcpp::QoSInitialization(qos_profile.history, qos_profile.depth), qos_profile);
188188

189+
// Use sensor data QoS (BEST_EFFORT) for high-frequency point clouds
189190
rmw_qos_profile_t sensor_qos_profile = rmw_qos_profile_sensor_data;
190191
auto sensor_qos = rclcpp::QoS(rclcpp::QoSInitialization(sensor_qos_profile.history, sensor_qos_profile.depth), sensor_qos_profile);
191192

@@ -201,30 +202,13 @@ ElevationMappingNode::ElevationMappingNode(const rclcpp::NodeOptions& options)
201202
// point_cloud_transport::Subscriber sub = pct.subscribe(pointcloud_topic, 100, callback, {}, transport_hint.get())
202203

203204

204-
auto callback_transport = [this, key](const sensor_msgs::msg::PointCloud2::ConstSharedPtr msg) {
205-
this->pointcloudtransportCallback(msg, key);
206-
};
207-
208-
// Create transport hints (e.g., "draco")
209-
// auto transport_hint = std::make_shared<point_cloud_transport::TransportHints>("draco");
210-
211-
212-
// Use PointCloudTransport to create a subscriber
213-
point_cloud_transport::PointCloudTransport pct(node_);
214-
auto sub_transport = pct.subscribe(pointcloud_topic, 100, callback_transport);
215-
216-
// Add the subscriber to the vector to manage its lifetime
217-
pointcloudtransportSubs_.push_back(sub_transport);
218-
219-
220-
// auto callback = [this, key](const sensor_msgs::msg::PointCloud2::SharedPtr msg) {
221-
// this->pointcloudCallback(msg, key);
222-
// };
223-
224-
// auto sub = this->create_subscription<sensor_msgs::msg::PointCloud2>(pointcloud_topic, sensor_qos, callback);
205+
auto callback = [this, key](const sensor_msgs::msg::PointCloud2::ConstSharedPtr msg) {
206+
this->pointcloudtransportCallback(msg, key);
207+
};
225208

226-
// pointcloudSubs_.push_back(sub);
227-
RCLCPP_INFO(this->get_logger(), "Subscribed to PointCloud2 topic: %s", pointcloud_topic.c_str());
209+
auto sub = this->create_subscription<sensor_msgs::msg::PointCloud2>(pointcloud_topic, sensor_qos, callback);
210+
pointcloudSubs_.push_back(sub);
211+
RCLCPP_INFO(this->get_logger(), "Subscribed to PointCloud2 topic: %s", pointcloud_topic.c_str());
228212
}
229213
}
230214
}

0 commit comments

Comments
 (0)