@@ -8,6 +8,7 @@ RosCompressedStreamer::RosCompressedStreamer(const async_web_server_cpp::HttpReq
88 ImageStreamer (request, connection, nh), stream_(std::bind(&rclcpp::Node::now, nh), connection)
99{
1010 stream_.sendInitialHeader ();
11+ qos_profile_name_ = request.get_query_param_value_or_default (" qos_profile" , " default" );
1112}
1213
1314RosCompressedStreamer::~RosCompressedStreamer ()
@@ -17,9 +18,23 @@ RosCompressedStreamer::~RosCompressedStreamer()
1718}
1819
1920void RosCompressedStreamer::start () {
20- std::string compressed_topic = topic_ + " /compressed" ;
21+ const std::string compressed_topic = topic_ + " /compressed" ;
22+
23+ // Get QoS profile from query parameter
24+ RCLCPP_INFO (nh_->get_logger (), " Streaming topic %s with QoS profile %s" , compressed_topic.c_str (), qos_profile_name_.c_str ());
25+ auto qos_profile = get_qos_profile_from_name (qos_profile_name_);
26+ if (!qos_profile) {
27+ qos_profile = rmw_qos_profile_default;
28+ RCLCPP_ERROR (
29+ nh_->get_logger (),
30+ " Invalid QoS profile %s specified. Using default profile." ,
31+ qos_profile_name_.c_str ());
32+ }
33+
34+ // Create subscriber
35+ const auto qos = rclcpp::QoS (rclcpp::QoSInitialization (qos_profile.value ().history , 1 ), qos_profile.value ());
2136 image_sub_ = nh_->create_subscription <sensor_msgs::msg::CompressedImage>(
22- compressed_topic, 1 , std::bind (&RosCompressedStreamer::imageCallback, this , std::placeholders::_1));
37+ compressed_topic, qos , std::bind (&RosCompressedStreamer::imageCallback, this , std::placeholders::_1));
2338}
2439
2540void RosCompressedStreamer::restreamFrame (double max_age)
0 commit comments