File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
docs/10-prerequisites/25-ros2/50-ros1-ros2-patterns Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ title : Publishers
3+ pagination_label : Publishers
4+ description : ROS2 Publishers
5+ ---
6+
7+ # ROS2 Publishers
8+
9+ ## Creating a latched publisher
10+
11+ Latching can be enabled through QoS.
12+
13+ 1 . Setup a QoS profile using a baseline of your choice.
14+ ``` cpp
15+ rclcpp::QoS qos_profile = rclcpp::SystemDefaultsQoS();
16+ ```
17+ 2 . Enable the ` transient_local() ` durability setting:
18+ ``` cpp
19+ qos_profile.transient_local();
20+ ```
21+ 1 . Pass the QoS profile to the publisher handler using the ` PublisherHandlerOptions ` :
22+ ``` cpp
23+ mrs_lib::PublisherHandlerOptions ph_options;
24+
25+ ph_options.node = node_;
26+ ph_options.qos = qos_profile;
27+
28+ ph_my_topic_ = mrs_lib::PublisherHandler<my_type>(ph_options, " ~/topic_out" );
29+ ```
You can’t perform that action at this time.
0 commit comments