rclcpp
master
C++ ROS Client Library API
|
Go to the documentation of this file.
15 #ifndef RCLCPP__DETAIL__QOS_PARAMETERS_HPP_
16 #define RCLCPP__DETAIL__QOS_PARAMETERS_HPP_
21 #include <initializer_list>
24 #include <type_traits>
27 #include "rcl_interfaces/msg/parameter_descriptor.hpp"
28 #include "rcpputils/pointer_traits.hpp"
44 static constexpr
const char *
entity_type() {
return "publisher";}
64 static constexpr
const char *
entity_type() {
return "subscription";}
82 ::rclcpp::ParameterValue
97 rcl_interfaces::msg::ParameterDescriptor descriptor)
101 param_name, param_value, descriptor);
119 template<
typename NodeT,
typename EntityQosParametersTraits>
122 decltype(
std::declval<
typename rcpputils::remove_pointer<NodeT>::type>())>::value ||
124 rclcpp::node_interfaces::NodeParametersInterface::SharedPtr>::value,
127 const ::rclcpp::QosOverridingOptions & options,
130 const ::rclcpp::QoS & default_qos,
131 EntityQosParametersTraits)
135 const auto &
id = options.get_id();
138 oss << topic_name <<
"." << EntityQosParametersTraits::entity_type();
143 param_prefix = oss.str();
148 oss << EntityQosParametersTraits::entity_type() <<
" {" << topic_name <<
"}";
150 oss <<
" with id {" <<
id <<
"}";
152 param_description_suffix = oss.str();
155 for (
auto policy : EntityQosParametersTraits::allowed_policies()) {
157 std::count(options.get_policy_kinds().begin(), options.get_policy_kinds().end(), policy))
163 rcl_interfaces::msg::ParameterDescriptor descriptor{};
164 descriptor.description = param_desciption.str();
165 descriptor.read_only =
true;
167 parameters_interface, param_name.str(),
172 const auto & validation_callback = options.get_validation_callback();
173 if (validation_callback) {
174 auto result = validation_callback(qos);
175 if (!result.successful) {
177 "validation callback failed: " + result.reason};
185 template<
typename NodeT,
typename EntityQosParametersTraits>
188 decltype(
std::declval<
typename rcpputils::remove_pointer<NodeT>::type>())>::value ||
190 rclcpp::node_interfaces::NodeParametersInterface::SharedPtr>::value),
193 const ::rclcpp::QosOverridingOptions & options,
196 const ::rclcpp::QoS & default_qos,
197 EntityQosParametersTraits)
199 if (options.get_policy_kinds().size()) {
201 "passed non-default qos overriding options without providing a parameters interface"};
208 #define RCLCPP_DETAIL_APPLY_QOS_OVERRIDE_FROM_PARAMETER_STRING( \
209 kind_lower, kind_upper, parameter_value, rclcpp_qos) \
211 auto policy_string = (parameter_value).get<std::string>(); \
212 auto policy_value = rmw_qos_ ## kind_lower ## _policy_from_str(policy_string.c_str()); \
213 if (RMW_QOS_POLICY_ ## kind_upper ## _UNKNOWN == policy_value) { \
214 throw std::invalid_argument{"unknown QoS policy " #kind_lower " value: " + policy_string}; \
216 ((rclcpp_qos).kind_lower)(policy_value); \
233 durability, DURABILITY, value, qos);
237 history, HISTORY, value, qos);
247 liveliness, LIVELINESS, value, qos);
254 reliability, RELIABILITY, value, qos);
266 return ::rclcpp::Duration(
267 static_cast<int32_t
>(rmw_duration.
sec),
268 static_cast<uint32_t
>(rmw_duration.
nsec)
277 if (!policy_value_stringified) {
282 return policy_value_stringified;
286 ::rclcpp::ParameterValue
326 #endif // RCLCPP__DETAIL__QOS_PARAMETERS_HPP_
const char * rmw_qos_reliability_policy_to_str(enum rmw_qos_reliability_policy_t value)
LivelinessLeaseDuration
Definition: qos_overriding_options.hpp:43
Store the type and value of a parameter.
Definition: parameter_value.hpp:71
const char * qos_policy_kind_to_cstr(const QosPolicyKind &qpk)
Depth
Definition: qos_overriding_options.hpp:38
History
Definition: qos_overriding_options.hpp:40
constexpr std::enable_if< type==ParameterType::PARAMETER_BOOL, const bool & >::type get() const
Definition: parameter_value.hpp:148
rmw_qos_profile_t & get_rmw_qos_profile()
Return the rmw qos profile.
int64_t rmw_duration_to_int64_t(rmw_time_t rmw_duration)
Convert rmw_time_t to int64_t that can be used as a parameter value.
Definition: qos_parameters.hpp:264
QoS & avoid_ros_namespace_conventions(bool avoid_ros_namespace_conventions)
Set the avoid_ros_namespace_conventions setting.
Deadline
Definition: qos_overriding_options.hpp:37
virtual rclcpp::Parameter get_parameter(const std::string &name) const =0
Get the description of one parameter given a name.
QoS & lifespan(rmw_time_t lifespan)
Set the lifespan setting.
Liveliness
Definition: qos_overriding_options.hpp:42
std::enable_if_t< rclcpp::node_interfaces::has_node_parameters_interface< decltype(std::declval< typename rcpputils::remove_pointer< NodeT >::type >))>::value||std::is_same< typename std::decay_t< NodeT >, rclcpp::node_interfaces::NodeParametersInterface::SharedPtr >::value, rclcpp::QoS > declare_qos_parameters(const ::rclcpp::QosOverridingOptions &options, NodeT &node, const std::string &topic_name, const ::rclcpp::QoS &default_qos, EntityQosParametersTraits)
Definition: qos_parameters.hpp:126
#define RCLCPP_DETAIL_APPLY_QOS_OVERRIDE_FROM_PARAMETER_STRING(kind_lower, kind_upper, parameter_value, rclcpp_qos)
Definition: qos_parameters.hpp:208
const char * check_if_stringified_policy_is_null(const char *policy_value_stringified, QosPolicyKind kind)
Definition: qos_parameters.hpp:275
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
virtual const rclcpp::ParameterValue & declare_parameter(const std::string &name)=0
Declare a parameter.
const char * rmw_qos_history_policy_to_str(enum rmw_qos_history_policy_t value)
Encapsulation of Quality of Service settings.
Definition: qos.hpp:110
inline ::rclcpp::ParameterValue get_default_qos_param_value(rclcpp::QosPolicyKind policy, const rclcpp::QoS &qos)
Definition: qos_parameters.hpp:287
Pure virtual interface class for the NodeParameters part of the Node API.
Definition: node_parameters_interface.hpp:60
static constexpr const char * entity_type()
Definition: qos_parameters.hpp:44
Thrown if parameter is already declared.
Definition: exceptions.hpp:258
static constexpr auto allowed_policies()
Definition: qos_parameters.hpp:45
const rclcpp::ParameterValue & get_parameter_value() const
Get the internal storage for the parameter value.
static constexpr const char * entity_type()
Definition: qos_parameters.hpp:64
Durability
Definition: qos_overriding_options.hpp:39
Definition: qos_parameters.hpp:62
const char * rmw_qos_durability_policy_to_str(enum rmw_qos_durability_policy_t value)
Reliability
Definition: qos_overriding_options.hpp:44
QoS & deadline(rmw_time_t deadline)
Set the deadline setting.
static Duration from_nanoseconds(rcl_duration_value_t nanoseconds)
Create a duration object from an integer number representing nanoseconds.
Lifespan
Definition: qos_overriding_options.hpp:41
std::shared_ptr< rclcpp::node_interfaces::NodeParametersInterface > get_node_parameters_interface(NodeType &&node)
Get the NodeParametersInterface as a shared pointer from a pointer to a "Node like" object.
Definition: get_node_parameters_interface.hpp:72
AvoidRosNamespaceConventions
Definition: qos_overriding_options.hpp:36
rclcpp::ParameterValue declare_parameter_or_get(rclcpp::node_interfaces::NodeParametersInterface ¶meters_interface, const std::string ¶m_name, rclcpp::ParameterValue param_value, rcl_interfaces::msg::ParameterDescriptor descriptor)
Definition: qos_parameters.hpp:93
static constexpr auto allowed_policies()
Definition: qos_parameters.hpp:65
Definition: qos_parameters.hpp:42
Thrown if the QoS overrides provided aren't valid.
Definition: exceptions.hpp:300
const char * rmw_qos_liveliness_policy_to_str(enum rmw_qos_liveliness_policy_t value)
QoS & liveliness_lease_duration(rmw_time_t liveliness_lease_duration)
Set the liveliness_lease_duration setting.
void apply_qos_override(rclcpp::QosPolicyKind policy, rclcpp::ParameterValue value, rclcpp::QoS &qos)
Definition: qos_parameters.hpp:221
Definition: node_parameters_interface_traits.hpp:29