15 #ifndef RCLCPP__NODE_INTERFACES__NODE_PARAMETERS_HPP_
16 #define RCLCPP__NODE_INTERFACES__NODE_PARAMETERS_HPP_
24 #include "rcutils/macros.h"
26 #include "rcl_interfaces/msg/list_parameters_result.hpp"
27 #include "rcl_interfaces/msg/parameter_descriptor.hpp"
28 #include "rcl_interfaces/msg/parameter_event.hpp"
29 #include "rcl_interfaces/msg/set_parameters_result.hpp"
31 #include "rclcpp/macros.hpp"
32 #include "rclcpp/node_interfaces/node_base_interface.hpp"
33 #include "rclcpp/node_interfaces/node_logging_interface.hpp"
34 #include "rclcpp/node_interfaces/node_parameters_interface.hpp"
35 #include "rclcpp/node_interfaces/node_services_interface.hpp"
36 #include "rclcpp/node_interfaces/node_topics_interface.hpp"
37 #include "rclcpp/parameter.hpp"
38 #include "rclcpp/parameter_service.hpp"
39 #include "rclcpp/publisher.hpp"
40 #include "rclcpp/visibility_control.hpp"
44 namespace node_interfaces
62 : allow_modification_(allow_mod)
64 if (!allow_modification_) {
66 "cannot set or declare a parameter, or change the callback from within set callback");
69 allow_modification_ =
false;
74 allow_modification_ =
true;
78 bool & allow_modification_;
89 const node_interfaces::NodeBaseInterface::SharedPtr node_base,
90 const node_interfaces::NodeLoggingInterface::SharedPtr node_logging,
91 const node_interfaces::NodeTopicsInterface::SharedPtr node_topics,
92 const node_interfaces::NodeServicesInterface::SharedPtr node_services,
93 const node_interfaces::NodeClockInterface::SharedPtr node_clock,
94 const std::vector<Parameter> & parameter_overrides,
95 bool start_parameter_services,
96 bool start_parameter_event_publisher,
99 bool allow_undeclared_parameters,
100 bool automatically_declare_parameters_from_overrides);
109 const std::string & name,
111 const rcl_interfaces::msg::ParameterDescriptor & parameter_descriptor =
112 rcl_interfaces::msg::ParameterDescriptor{},
113 bool ignore_override =
false)
override;
118 const std::string & name,
119 rclcpp::ParameterType type,
120 const rcl_interfaces::msg::ParameterDescriptor & parameter_descriptor =
121 rcl_interfaces::msg::ParameterDescriptor(),
122 bool ignore_override =
false)
override;
133 std::vector<rcl_interfaces::msg::SetParametersResult>
135 const std::vector<rclcpp::Parameter> & parameters)
override;
138 rcl_interfaces::msg::SetParametersResult
140 const std::vector<rclcpp::Parameter> & parameters)
override;
143 std::vector<rclcpp::Parameter>
144 get_parameters(
const std::vector<std::string> & names)
const override;
153 const std::string & name,
159 const std::string & prefix,
160 std::map<std::string, rclcpp::Parameter> & parameters)
const override;
163 std::vector<rcl_interfaces::msg::ParameterDescriptor>
164 describe_parameters(
const std::vector<std::string> & names)
const override;
168 get_parameter_types(
const std::vector<std::string> & names)
const override;
171 rcl_interfaces::msg::ListParametersResult
172 list_parameters(
const std::vector<std::string> & prefixes, uint64_t depth)
const override;
176 OnSetParametersCallbackHandle::SharedPtr
184 const std::map<std::string, rclcpp::ParameterValue> &
187 using CallbacksContainerType = std::list<OnSetParametersCallbackHandle::WeakPtr>;
192 mutable std::recursive_mutex mutex_;
197 bool parameter_modification_enabled_{
true};
199 OnParametersSetCallbackType on_parameters_set_callback_ =
nullptr;
201 CallbacksContainerType on_parameters_set_callback_container_;
203 std::map<std::string, ParameterInfo> parameters_;
205 std::map<std::string, rclcpp::ParameterValue> parameter_overrides_;
207 bool allow_undeclared_ =
false;
211 std::shared_ptr<ParameterService> parameter_service_;
213 std::string combined_name_;
215 node_interfaces::NodeLoggingInterface::SharedPtr node_logging_;
216 node_interfaces::NodeClockInterface::SharedPtr node_clock_;
Store the type and value of a parameter.
Structure to store an arbitrary parameter with templated get/set methods.
A publisher publishes messages of any type to a topic.
Encapsulation of Quality of Service settings.
Thrown if parameter is modified while in a set callback.
Pure virtual interface class for the NodeParameters part of the Node API.
Implementation of the NodeParameters part of the Node API.
RCLCPP_PUBLIC const std::map< std::string, rclcpp::ParameterValue > & get_parameter_overrides() const override
Return the initial parameter values used by the NodeParameters to override default values.
RCLCPP_PUBLIC void remove_on_set_parameters_callback(const OnSetParametersCallbackHandle *const handler) override
Remove a callback registered with add_on_set_parameters_callback.
RCLCPP_PUBLIC std::vector< rclcpp::Parameter > get_parameters(const std::vector< std::string > &names) const override
Get descriptions of parameters given their names.
RCLCPP_PUBLIC void undeclare_parameter(const std::string &name) override
Undeclare a parameter.
RCLCPP_PUBLIC const rclcpp::ParameterValue & declare_parameter(const std::string &name, const rclcpp::ParameterValue &default_value, const rcl_interfaces::msg::ParameterDescriptor ¶meter_descriptor=rcl_interfaces::msg::ParameterDescriptor{}, bool ignore_override=false) override
Declare and initialize a parameter.
RCLCPP_PUBLIC bool get_parameters_by_prefix(const std::string &prefix, std::map< std::string, rclcpp::Parameter > ¶meters) const override
Get all parameters that have the specified prefix into the parameters map.
RCLCPP_PUBLIC std::vector< rcl_interfaces::msg::SetParametersResult > set_parameters(const std::vector< rclcpp::Parameter > ¶meters) override
Set one or more parameters, one at a time.
RCLCPP_PUBLIC RCUTILS_WARN_UNUSED OnSetParametersCallbackHandle::SharedPtr add_on_set_parameters_callback(OnParametersSetCallbackType callback) override
Add a callback for when parameters are being set.
RCLCPP_PUBLIC rcl_interfaces::msg::SetParametersResult set_parameters_atomically(const std::vector< rclcpp::Parameter > ¶meters) override
Set one or more parameters, all at once.
RCLCPP_PUBLIC rclcpp::Parameter get_parameter(const std::string &name) const override
Get the description of one parameter given a name.
RCLCPP_PUBLIC bool has_parameter(const std::string &name) const override
Return true if the parameter has been declared, otherwise false.
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.
Non-templated part of PublisherOptionsWithAllocator<Allocator>.
rcl_interfaces::msg::ParameterDescriptor descriptor
A description of the parameter.
rclcpp::ParameterValue value
Current value of the parameter.