ROS2 Publishers
Creating a latched publisher
Latching can be enabled through QoS.
- Setup a QoS profile using a baseline of your choice.
rclcpp::QoS qos_profile = rclcpp::SystemDefaultsQoS();
- Enable the
transient_local()durability setting:
qos_profile.transient_local();
- Pass the QoS profile to the publisher handler using the
PublisherHandlerOptions:
mrs_lib::PublisherHandlerOptions ph_options;
ph_options.node = node_;
ph_options.qos = qos_profile;
ph_my_topic_ = mrs_lib::PublisherHandler<my_type>(ph_options, "~/topic_out");