rclcpp  master
C++ ROS Client Library API
node_parameters.hpp
Go to the documentation of this file.
1 // Copyright 2016 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__NODE_INTERFACES__NODE_PARAMETERS_HPP_
16 #define RCLCPP__NODE_INTERFACES__NODE_PARAMETERS_HPP_
17 
18 #include <map>
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
23 #include "rcl_interfaces/msg/list_parameters_result.hpp"
24 #include "rcl_interfaces/msg/parameter_descriptor.hpp"
25 #include "rcl_interfaces/msg/parameter_event.hpp"
26 #include "rcl_interfaces/msg/set_parameters_result.hpp"
27 
28 #include "rclcpp/macros.hpp"
33 #include "rclcpp/parameter.hpp"
35 #include "rclcpp/publisher.hpp"
37 
38 namespace rclcpp
39 {
40 namespace node_interfaces
41 {
42 
43 // Internal struct for holding useful info about parameters
45 {
48 
50  rcl_interfaces::msg::ParameterDescriptor descriptor;
51 };
52 
55 {
56 public:
58 
61  const node_interfaces::NodeBaseInterface::SharedPtr node_base,
62  const node_interfaces::NodeLoggingInterface::SharedPtr node_logging,
63  const node_interfaces::NodeTopicsInterface::SharedPtr node_topics,
64  const node_interfaces::NodeServicesInterface::SharedPtr node_services,
65  const node_interfaces::NodeClockInterface::SharedPtr node_clock,
66  const std::vector<Parameter> & parameter_overrides,
67  bool start_parameter_services,
68  bool start_parameter_event_publisher,
69  const rclcpp::QoS & parameter_event_qos,
70  const rclcpp::PublisherOptionsBase & parameter_event_publisher_options,
71  bool allow_undeclared_parameters,
72  bool automatically_declare_parameters_from_overrides);
73 
75  virtual
76  ~NodeParameters();
77 
80  declare_parameter(
81  const std::string & name,
82  const rclcpp::ParameterValue & default_value,
83  const rcl_interfaces::msg::ParameterDescriptor & parameter_descriptor) override;
84 
86  void
87  undeclare_parameter(const std::string & name) override;
88 
90  bool
91  has_parameter(const std::string & name) const override;
92 
95  set_parameters(
96  const std::vector<rclcpp::Parameter> & parameters) override;
97 
99  rcl_interfaces::msg::SetParametersResult
100  set_parameters_atomically(
101  const std::vector<rclcpp::Parameter> & parameters) override;
102 
105  get_parameters(const std::vector<std::string> & names) const override;
106 
109  get_parameter(const std::string & name) const override;
110 
112  bool
113  get_parameter(
114  const std::string & name,
115  rclcpp::Parameter & parameter) const override;
116 
118  bool
119  get_parameters_by_prefix(
120  const std::string & prefix,
121  std::map<std::string, rclcpp::Parameter> & parameters) const override;
122 
125  describe_parameters(const std::vector<std::string> & names) const override;
126 
129  get_parameter_types(const std::vector<std::string> & names) const override;
130 
132  rcl_interfaces::msg::ListParametersResult
133  list_parameters(const std::vector<std::string> & prefixes, uint64_t depth) const override;
134 
137  set_on_parameters_set_callback(OnParametersSetCallbackType callback) override;
138 
139  [[deprecated("use set_on_parameters_set_callback() instead")]]
141  void
142  register_param_change_callback(OnParametersSetCallbackType callback) override;
143 
146  get_parameter_overrides() const override;
147 
148 private:
149  RCLCPP_DISABLE_COPY(NodeParameters)
150 
151  mutable std::mutex mutex_;
152 
153  OnParametersSetCallbackType on_parameters_set_callback_ = nullptr;
154 
156 
158 
159  bool allow_undeclared_ = false;
160 
162 
163  std::shared_ptr<ParameterService> parameter_service_;
164 
165  std::string combined_name_;
166 
167  node_interfaces::NodeLoggingInterface::SharedPtr node_logging_;
168  node_interfaces::NodeClockInterface::SharedPtr node_clock_;
169 };
170 
171 } // namespace node_interfaces
172 } // namespace rclcpp
173 
174 #endif // RCLCPP__NODE_INTERFACES__NODE_PARAMETERS_HPP_
#define RCLCPP_DISABLE_COPY(...)
Definition: macros.hpp:26
Non-templated part of PublisherOptionsWithAllocator<Allocator>.
Definition: publisher_options.hpp:33
rcl_interfaces::msg::ParameterDescriptor descriptor
A description of the parameter.
Definition: node_parameters.hpp:50
Encapsulation of Quality of Service settings.
Definition: qos.hpp:55
Structure to store an arbitrary parameter with templated get/set methods.
Definition: parameter.hpp:51
#define RCLCPP_SMART_PTR_ALIASES_ONLY(...)
Definition: macros.hpp:66
This header provides the get_node_topics_interface() template function.
Definition: allocator_common.hpp:24
rclcpp::ParameterValue value
Current value of the parameter.
Definition: node_parameters.hpp:47
A publisher publishes messages of any type to a topic.
Definition: publisher.hpp:46
Definition: node_parameters.hpp:44
Implementation of the NodeParameters part of the Node API.
Definition: node_parameters.hpp:54
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
Store the type and value of a parameter.
Definition: parameter_value.hpp:71
Pure virtual interface class for the NodeParameters part of the Node API.
Definition: node_parameters_interface.hpp:36