Skip to content

Commit 8cbb8e4

Browse files
Tomas BacaTomas Baca
authored andcommitted
added ros2 publishers section
1 parent 902aace commit 8cbb8e4

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
```

0 commit comments

Comments
 (0)