[rclcpp] How do you specify Subscriber queue_size?
How do you specify the buffered message count in the construction of a subscription object? Looks like there isn't any createsubscription overload with a queuesize parameter.
int queueSize = 10;
auto sub = node->create_subscription<MessageType>("topicName", queueSize, callbackfn); // ERROR
Asked by Pablo Iñigo Blasco on 2020-10-05 13:22:33 UTC
Answers
The old queue_size parameter not in the create_subscription method. Now it is integrated inside the rclcpp::Qos data structure as "depth" field.
There are a few built-in quality of services policies that you may want to use. These have some predefined values for its fields. For example, SensorDataQoS defines depth=10. Nonetheless, you could override this value using the Qos::keep_last(depth) method.
For example:
rclcpp::SensorDataQoS qos;
qos.keep_last(*queueSize);
int queueSize = 10;
auto sub = node->create_subscription<MessageType>("topicName", qos, callbackfn);
References: - https://index.ros.org/doc/ros2/Concepts/About-Quality-of-Service-Settings/ - http://docs.ros2.org/dashing/api/rclcpp/classrclcpp_1_1QoS.html
Asked by Pablo Iñigo Blasco on 2020-10-05 14:08:27 UTC
Comments