rclcpp  master
C++ ROS Client Library API
qos.hpp
Go to the documentation of this file.
1 // Copyright 2019 Open Source Robotics Foundation, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef RCLCPP__QOS_HPP_
16 #define RCLCPP__QOS_HPP_
17 
18 #include <string>
19 
20 #include "rclcpp/duration.hpp"
21 #include "rclcpp/exceptions.hpp"
23 #include "rcl/logging_rosout.h"
25 #include "rmw/qos_profiles.h"
26 #include "rmw/types.h"
27 
28 namespace rclcpp
29 {
30 
33 
34 enum class HistoryPolicy
35 {
39  Unknown = RMW_QOS_POLICY_HISTORY_UNKNOWN,
40 };
41 
43 {
47  Unknown = RMW_QOS_POLICY_RELIABILITY_UNKNOWN,
48 };
49 
50 enum class DurabilityPolicy
51 {
55  Unknown = RMW_QOS_POLICY_DURABILITY_UNKNOWN,
56 };
57 
58 enum class LivelinessPolicy
59 {
63  Unknown = RMW_QOS_POLICY_LIVELINESS_UNKNOWN,
64 };
65 
66 enum class QoSCompatibility
67 {
70  Error = RMW_QOS_COMPATIBILITY_ERROR,
71 };
72 
75 {
77  size_t depth;
78 
80  QoSInitialization(rmw_qos_history_policy_t history_policy_arg, size_t depth_arg);
81 
83  static
85  from_rmw(const rmw_qos_profile_t & rmw_qos);
86 };
87 
90 {
91  KeepAll();
92 };
93 
96 {
97  explicit KeepLast(size_t depth);
98 };
99 
101 
111 {
112 public:
114 
127  explicit
128  QoS(
129  const QoSInitialization & qos_initialization,
130  const rmw_qos_profile_t & initial_profile = rmw_qos_profile_default);
131 
133 
140  // cppcheck-suppress noExplicitConstructor
141  QoS(size_t history_depth); // NOLINT(runtime/explicit): conversion constructor
142 
145  get_rmw_qos_profile();
146 
148  const rmw_qos_profile_t &
149  get_rmw_qos_profile() const;
150 
152  QoS &
153  history(HistoryPolicy history);
154 
156  QoS &
157  history(rmw_qos_history_policy_t history);
158 
160  QoS &
161  keep_last(size_t depth);
162 
164  QoS &
165  keep_all();
166 
168  QoS &
169  reliability(rmw_qos_reliability_policy_t reliability);
170 
172  QoS &
173  reliability(ReliabilityPolicy reliability);
174 
176  QoS &
177  reliable();
178 
180  QoS &
181  best_effort();
182 
184  QoS &
185  durability(rmw_qos_durability_policy_t durability);
186 
188  QoS &
189  durability(DurabilityPolicy durability);
190 
192 
195  QoS &
196  durability_volatile();
197 
199  QoS &
200  transient_local();
201 
203  QoS &
204  deadline(rmw_time_t deadline);
205 
207  QoS &
208  deadline(const rclcpp::Duration & deadline);
209 
211  QoS &
212  lifespan(rmw_time_t lifespan);
213 
215  QoS &
216  lifespan(const rclcpp::Duration & lifespan);
217 
219  QoS &
220  liveliness(rmw_qos_liveliness_policy_t liveliness);
221 
223  QoS &
224  liveliness(LivelinessPolicy liveliness);
225 
227  QoS &
228  liveliness_lease_duration(rmw_time_t liveliness_lease_duration);
229 
231  QoS &
232  liveliness_lease_duration(const rclcpp::Duration & liveliness_lease_duration);
233 
235  QoS &
236  avoid_ros_namespace_conventions(bool avoid_ros_namespace_conventions);
237 
240  history() const;
241 
243  size_t
244  depth() const;
245 
248  reliability() const;
249 
252  durability() const;
253 
256  deadline() const;
257 
260  lifespan() const;
261 
264  liveliness() const;
265 
268  liveliness_lease_duration() const;
269 
271  bool
272  avoid_ros_namespace_conventions() const;
273 
274 private:
275  rmw_qos_profile_t rmw_qos_profile_;
276 };
277 
280 bool operator==(const QoS & left, const QoS & right);
282 bool operator!=(const QoS & left, const QoS & right);
283 
285 
289 {
292 
294 
299 };
300 
302 
337 qos_check_compatible(const QoS & publisher_qos, const QoS & subscription_qos);
338 
351 class RCLCPP_PUBLIC ClockQoS : public QoS
352 {
353 public:
354  explicit
355  ClockQoS(
356  const QoSInitialization & qos_initialization = KeepLast(1));
357 };
358 
372 {
373 public:
374  explicit
376  const QoSInitialization & qos_initialization = (
377  QoSInitialization::from_rmw(rmw_qos_profile_sensor_data)
378  ));
379 };
380 
394 {
395 public:
396  explicit
398  const QoSInitialization & qos_initialization = (
399  QoSInitialization::from_rmw(rmw_qos_profile_parameters)
400  ));
401 };
402 
416 {
417 public:
418  explicit
419  ServicesQoS(
420  const QoSInitialization & qos_initialization = (
421  QoSInitialization::from_rmw(rmw_qos_profile_services_default)
422  ));
423 };
424 
438 {
439 public:
440  explicit
442  const QoSInitialization & qos_initialization = (
443  QoSInitialization::from_rmw(rmw_qos_profile_parameter_events)
444  ));
445 };
446 
460 {
461 public:
462  explicit
463  RosoutQoS(
464  const QoSInitialization & rosout_qos_initialization = (
465  QoSInitialization::from_rmw(rcl_qos_profile_rosout_default)
466  ));
467 };
468 
482 {
483 public:
484  explicit
486  const QoSInitialization & qos_initialization = (
487  QoSInitialization::from_rmw(rmw_qos_profile_system_default)
488  ));
489 };
490 
491 } // namespace rclcpp
492 
493 #endif // RCLCPP__QOS_HPP_
rclcpp::ReliabilityPolicy::Unknown
@ Unknown
RMW_QOS_POLICY_LIVELINESS_AUTOMATIC
RMW_QOS_POLICY_LIVELINESS_AUTOMATIC
rclcpp::LivelinessPolicy
LivelinessPolicy
Definition: qos.hpp:58
RMW_QOS_POLICY_HISTORY_KEEP_ALL
RMW_QOS_POLICY_HISTORY_KEEP_ALL
RMW_QOS_POLICY_RELIABILITY_SYSTEM_DEFAULT
RMW_QOS_POLICY_RELIABILITY_SYSTEM_DEFAULT
exceptions.hpp
std::string
RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT
RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT
rmw_time_t
rclcpp::ClockQoS
Definition: qos.hpp:351
logging_rosout.h
rclcpp::ServicesQoS
Definition: qos.hpp:415
rclcpp::QoSCompatibility::Warning
@ Warning
rclcpp::DurabilityPolicy
DurabilityPolicy
Definition: qos.hpp:50
rclcpp::DurabilityPolicy::SystemDefault
@ SystemDefault
rclcpp::HistoryPolicy
HistoryPolicy
Definition: qos.hpp:34
rclcpp::KeepAll
Use to initialize the QoS with the keep_all history setting.
Definition: qos.hpp:89
rclcpp::ReliabilityPolicy::BestEffort
@ BestEffort
rclcpp
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
rmw_qos_liveliness_policy_t
enum RMW_PUBLIC_TYPE rmw_qos_liveliness_policy_t
rclcpp::ReliabilityPolicy::Reliable
@ Reliable
rclcpp::QoSInitialization::depth
size_t depth
Definition: qos.hpp:77
RCLCPP_PUBLIC
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
rclcpp::LivelinessPolicy::Unknown
@ Unknown
rclcpp::LivelinessPolicy::ManualByTopic
@ ManualByTopic
rclcpp::QoS
Encapsulation of Quality of Service settings.
Definition: qos.hpp:110
rclcpp::QoSCompatibility::Error
@ Error
RMW_QOS_COMPATIBILITY_WARNING
RMW_QOS_COMPATIBILITY_WARNING
rclcpp::LivelinessPolicy::SystemDefault
@ SystemDefault
rclcpp::QoSInitialization::from_rmw
static QoSInitialization from_rmw(const rmw_qos_profile_t &rmw_qos)
Create a QoSInitialization from an existing rmw_qos_profile_t, using its history and depth.
rclcpp::DurabilityPolicy::Unknown
@ Unknown
rclcpp::HistoryPolicy::Unknown
@ Unknown
rmw_qos_history_policy_t
enum RMW_PUBLIC_TYPE rmw_qos_history_policy_t
rclcpp::ReliabilityPolicy
ReliabilityPolicy
Definition: qos.hpp:42
rclcpp::SensorDataQoS
Definition: qos.hpp:371
rclcpp::operator==
bool operator==(const NetworkFlowEndpoint &left, const NetworkFlowEndpoint &right)
Check if two NetworkFlowEndpoint instances are equal.
rclcpp::QoSCheckCompatibleResult
Result type for checking QoS compatibility.
Definition: qos.hpp:288
rclcpp::SystemDefaultsQoS
Definition: qos.hpp:481
rclcpp::Duration
Definition: duration.hpp:26
RMW_QOS_POLICY_HISTORY_SYSTEM_DEFAULT
RMW_QOS_POLICY_HISTORY_SYSTEM_DEFAULT
rclcpp::KeepLast
Use to initialize the QoS with the keep_last history setting and the given depth.
Definition: qos.hpp:95
rmw_qos_policy_kind_t
enum RMW_PUBLIC_TYPE rmw_qos_policy_kind_t rmw_qos_policy_kind_t
rmw_qos_durability_policy_t
enum RMW_PUBLIC_TYPE rmw_qos_durability_policy_t
rclcpp::QoSCompatibility
QoSCompatibility
Definition: qos.hpp:66
rclcpp::ReliabilityPolicy::SystemDefault
@ SystemDefault
rclcpp::QoSCheckCompatibleResult::reason
std::string reason
Reason for a (possible) incompatibility.
Definition: qos.hpp:298
RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT
RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT
visibility_control.hpp
RMW_QOS_POLICY_DURABILITY_SYSTEM_DEFAULT
RMW_QOS_POLICY_DURABILITY_SYSTEM_DEFAULT
rclcpp::QoSInitialization
QoS initialization values, cannot be created directly, use KeepAll or KeepLast instead.
Definition: qos.hpp:74
RMW_QOS_POLICY_RELIABILITY_RELIABLE
RMW_QOS_POLICY_RELIABILITY_RELIABLE
rclcpp::operator!=
bool operator!=(const NetworkFlowEndpoint &left, const NetworkFlowEndpoint &right)
Check if two NetworkFlowEndpoint instances are not equal.
RMW_QOS_COMPATIBILITY_OK
RMW_QOS_COMPATIBILITY_OK
rmw_qos_profile_t
rclcpp::ParameterEventsQoS
Definition: qos.hpp:437
rmw_qos_reliability_policy_t
enum RMW_PUBLIC_TYPE rmw_qos_reliability_policy_t
rclcpp::QoSCheckCompatibleResult::compatibility
QoSCompatibility compatibility
Compatibility result.
Definition: qos.hpp:291
rclcpp::DurabilityPolicy::Volatile
@ Volatile
RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC
RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC
rclcpp::DurabilityPolicy::TransientLocal
@ TransientLocal
RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL
RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL
types.h
rclcpp::ParametersQoS
Definition: qos.hpp:393
rclcpp::HistoryPolicy::SystemDefault
@ SystemDefault
rclcpp::QoSCompatibility::Ok
@ Ok
incompatible_qos_events_statuses.h
rclcpp::QoSInitialization::history_policy
rmw_qos_history_policy_t history_policy
Definition: qos.hpp:76
RMW_QOS_POLICY_DURABILITY_VOLATILE
RMW_QOS_POLICY_DURABILITY_VOLATILE
duration.hpp
rclcpp::qos_check_compatible
QoSCheckCompatibleResult qos_check_compatible(const QoS &publisher_qos, const QoS &subscription_qos)
Check if two QoS profiles are compatible.
rclcpp::LivelinessPolicy::Automatic
@ Automatic
rclcpp::qos_policy_name_from_kind
std::string qos_policy_name_from_kind(rmw_qos_policy_kind_t policy_kind)
rclcpp::RosoutQoS
Definition: qos.hpp:459
qos_profiles.h
RMW_QOS_POLICY_HISTORY_KEEP_LAST
RMW_QOS_POLICY_HISTORY_KEEP_LAST