ROS 2 rclcpp + rcl - rolling  rolling-20536064
ROS 2 C++ Client Library with ROS Client Library
node.hpp
1 // Copyright 2014 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_HPP_
16 #define RCLCPP__NODE_HPP_
17 
18 #include <atomic>
19 #include <condition_variable>
20 #include <functional>
21 #include <map>
22 #include <memory>
23 #include <mutex>
24 #include <string>
25 #include <tuple>
26 #include <utility>
27 #include <vector>
28 
29 #include "rcutils/macros.h"
30 
31 #include "rcl/error_handling.h"
32 #include "rcl/node.h"
33 
34 #include "rcl_interfaces/msg/list_parameters_result.hpp"
35 #include "rcl_interfaces/msg/parameter_descriptor.hpp"
36 #include "rcl_interfaces/msg/set_parameters_result.hpp"
37 
38 #include "rclcpp/callback_group.hpp"
39 #include "rclcpp/client.hpp"
40 #include "rclcpp/clock.hpp"
41 #include "rclcpp/context.hpp"
42 #include "rclcpp/event.hpp"
43 #include "rclcpp/generic_client.hpp"
44 #include "rclcpp/generic_publisher.hpp"
45 #include "rclcpp/generic_service.hpp"
46 #include "rclcpp/generic_subscription.hpp"
47 #include "rclcpp/logger.hpp"
48 #include "rclcpp/macros.hpp"
49 #include "rclcpp/message_memory_strategy.hpp"
50 #include "rclcpp/node_interfaces/node_base_interface.hpp"
51 #include "rclcpp/node_interfaces/node_clock_interface.hpp"
52 #include "rclcpp/node_interfaces/node_graph_interface.hpp"
53 #include "rclcpp/node_interfaces/node_logging_interface.hpp"
54 #include "rclcpp/node_interfaces/node_parameters_interface.hpp"
55 #include "rclcpp/node_interfaces/node_services_interface.hpp"
56 #include "rclcpp/node_interfaces/node_time_source_interface.hpp"
57 #include "rclcpp/node_interfaces/node_timers_interface.hpp"
58 #include "rclcpp/node_interfaces/node_topics_interface.hpp"
59 #include "rclcpp/node_interfaces/node_type_descriptions_interface.hpp"
60 #include "rclcpp/node_interfaces/node_waitables_interface.hpp"
61 #include "rclcpp/node_options.hpp"
62 #include "rclcpp/parameter.hpp"
63 #include "rclcpp/publisher.hpp"
64 #include "rclcpp/publisher_options.hpp"
65 #include "rclcpp/qos.hpp"
66 #include "rclcpp/service.hpp"
67 #include "rclcpp/subscription.hpp"
68 #include "rclcpp/subscription_options.hpp"
69 #include "rclcpp/subscription_traits.hpp"
70 #include "rclcpp/time.hpp"
71 #include "rclcpp/timer.hpp"
72 #include "rclcpp/visibility_control.hpp"
73 
74 namespace rclcpp
75 {
76 
78 class Node : public std::enable_shared_from_this<Node>
79 {
80 public:
81  RCLCPP_SMART_PTR_DEFINITIONS(Node)
82 
83 
89  RCLCPP_PUBLIC
90  explicit Node(
91  const std::string & node_name,
92  const NodeOptions & options = NodeOptions());
93 
95 
101  RCLCPP_PUBLIC
102  explicit Node(
103  const std::string & node_name,
104  const std::string & namespace_,
105  const NodeOptions & options = NodeOptions());
106 
107  RCLCPP_PUBLIC
108  virtual ~Node();
109 
111 
112  RCLCPP_PUBLIC
113  const char *
114  get_name() const;
115 
117 
126  RCLCPP_PUBLIC
127  const char *
128  get_namespace() const;
129 
131 
135  RCLCPP_PUBLIC
136  const char *
137  get_fully_qualified_name() const;
138 
140 
141  RCLCPP_PUBLIC
143  get_logger() const;
144 
146  RCLCPP_PUBLIC
147  rclcpp::CallbackGroup::SharedPtr
149  rclcpp::CallbackGroupType group_type,
150  bool automatically_add_to_executor_with_node = true);
151 
153 
159  RCLCPP_PUBLIC
160  void
161  for_each_callback_group(const node_interfaces::NodeBaseInterface::CallbackGroupFunction & func);
162 
164 
191  template<
192  typename MessageT,
193  typename AllocatorT = std::allocator<void>,
194  typename PublisherT = rclcpp::Publisher<MessageT, AllocatorT>>
195  std::shared_ptr<PublisherT>
197  const std::string & topic_name,
198  const rclcpp::QoS & qos,
201  );
202 
204 
212  template<
213  typename MessageT,
214  typename CallbackT,
215  typename AllocatorT = std::allocator<void>,
216  typename SubscriptionT = rclcpp::Subscription<MessageT, AllocatorT>,
217  typename MessageMemoryStrategyT = typename SubscriptionT::MessageMemoryStrategyType
218  >
219  std::shared_ptr<SubscriptionT>
221  const std::string & topic_name,
222  const rclcpp::QoS & qos,
223  CallbackT && callback,
226  typename MessageMemoryStrategyT::SharedPtr msg_mem_strat = (
227  MessageMemoryStrategyT::create_default()
228  )
229  );
230 
232 
238  template<typename DurationRepT = int64_t, typename DurationT = std::milli, typename CallbackT>
241  std::chrono::duration<DurationRepT, DurationT> period,
242  CallbackT callback,
243  const rclcpp::CallbackGroup::SharedPtr & group = nullptr,
244  bool autostart = true);
245 
247 
252  template<typename DurationRepT = int64_t, typename DurationT = std::milli, typename CallbackT>
254  create_timer(
255  std::chrono::duration<DurationRepT, DurationT> period,
256  CallbackT callback,
257  const rclcpp::CallbackGroup::SharedPtr & group = nullptr);
258 
260 
266  template<typename ServiceT>
269  const std::string & service_name,
270  const rclcpp::QoS & qos = rclcpp::ServicesQoS(),
271  const rclcpp::CallbackGroup::SharedPtr & group = nullptr);
272 
274 
281  template<typename ServiceT, typename CallbackT>
284  const std::string & service_name,
285  CallbackT && callback,
286  const rclcpp::QoS & qos = rclcpp::ServicesQoS(),
287  const rclcpp::CallbackGroup::SharedPtr & group = nullptr);
288 
290 
297  RCLCPP_PUBLIC
298  rclcpp::GenericClient::SharedPtr
300  const std::string & service_name,
301  const std::string & service_type,
302  const rclcpp::QoS & qos = rclcpp::ServicesQoS(),
303  const rclcpp::CallbackGroup::SharedPtr & group = nullptr);
304 
306 
314  template<typename CallbackT>
315  typename rclcpp::GenericService::SharedPtr
317  const std::string & service_name,
318  const std::string & service_type,
319  CallbackT && callback,
320  const rclcpp::QoS & qos = rclcpp::ServicesQoS(),
321  const rclcpp::CallbackGroup::SharedPtr & group = nullptr);
322 
324 
336  template<typename AllocatorT = std::allocator<void>>
337  std::shared_ptr<rclcpp::GenericPublisher> create_generic_publisher(
338  const std::string & topic_name,
339  const std::string & topic_type,
340  const rclcpp::QoS & qos,
343  )
344  );
345 
347 
361  template<
362  typename CallbackT,
363  typename AllocatorT = std::allocator<void>>
364  std::shared_ptr<rclcpp::GenericSubscription> create_generic_subscription(
365  const std::string & topic_name,
366  const std::string & topic_type,
367  const rclcpp::QoS & qos,
368  CallbackT && callback,
371  )
372  );
373 
375 
426  RCLCPP_PUBLIC
427  const rclcpp::ParameterValue &
429  const std::string & name,
430  const rclcpp::ParameterValue & default_value,
431  const rcl_interfaces::msg::ParameterDescriptor & parameter_descriptor =
432  rcl_interfaces::msg::ParameterDescriptor(),
433  bool ignore_override = false);
434 
436 
451  RCLCPP_PUBLIC
452  const rclcpp::ParameterValue &
454  const std::string & name,
455  rclcpp::ParameterType type,
456  const rcl_interfaces::msg::ParameterDescriptor & parameter_descriptor =
457  rcl_interfaces::msg::ParameterDescriptor{},
458  bool ignore_override = false);
459 
461 
481  template<typename ParameterT>
482  auto
484  const std::string & name,
485  const ParameterT & default_value,
486  const rcl_interfaces::msg::ParameterDescriptor & parameter_descriptor =
487  rcl_interfaces::msg::ParameterDescriptor(),
488  bool ignore_override = false);
489 
491 
494  template<typename ParameterT>
495  auto
497  const std::string & name,
498  const rcl_interfaces::msg::ParameterDescriptor & parameter_descriptor =
499  rcl_interfaces::msg::ParameterDescriptor(),
500  bool ignore_override = false);
501 
503 
549  template<typename ParameterT>
550  std::vector<ParameterT>
552  const std::string & namespace_,
553  const std::map<std::string, ParameterT> & parameters,
554  bool ignore_overrides = false);
555 
557 
563  template<typename ParameterT>
564  std::vector<ParameterT>
566  const std::string & namespace_,
567  const std::map<
568  std::string,
569  std::pair<ParameterT, rcl_interfaces::msg::ParameterDescriptor>
570  > & parameters,
571  bool ignore_overrides = false);
572 
574 
585  RCLCPP_PUBLIC
586  void
587  undeclare_parameter(const std::string & name);
588 
590 
594  RCLCPP_PUBLIC
595  bool
596  has_parameter(const std::string & name) const;
597 
599 
640  RCLCPP_PUBLIC
641  rcl_interfaces::msg::SetParametersResult
642  set_parameter(const rclcpp::Parameter & parameter);
643 
645 
692  RCLCPP_PUBLIC
693  std::vector<rcl_interfaces::msg::SetParametersResult>
694  set_parameters(const std::vector<rclcpp::Parameter> & parameters);
695 
697 
740  RCLCPP_PUBLIC
741  rcl_interfaces::msg::SetParametersResult
742  set_parameters_atomically(const std::vector<rclcpp::Parameter> & parameters);
743 
745 
764  RCLCPP_PUBLIC
766  get_parameter(const std::string & name) const;
767 
769 
783  RCLCPP_PUBLIC
784  bool
785  get_parameter(const std::string & name, rclcpp::Parameter & parameter) const;
786 
788 
800  template<typename ParameterT>
801  bool
802  get_parameter(const std::string & name, ParameterT & parameter) const;
803 
805 
819  template<typename ParameterT>
820  bool
822  const std::string & name,
823  ParameterT & parameter,
824  const ParameterT & alternative_value) const;
825 
827 
838  template<typename ParameterT>
839  ParameterT
841  const std::string & name,
842  const ParameterT & alternative_value) const;
843 
845 
864  RCLCPP_PUBLIC
865  std::vector<rclcpp::Parameter>
866  get_parameters(const std::vector<std::string> & names) const;
867 
869 
905  template<typename ParameterT>
906  bool
908  const std::string & prefix,
909  std::map<std::string, ParameterT> & values) const;
910 
912 
928  RCLCPP_PUBLIC
929  rcl_interfaces::msg::ParameterDescriptor
930  describe_parameter(const std::string & name) const;
931 
933 
951  RCLCPP_PUBLIC
952  std::vector<rcl_interfaces::msg::ParameterDescriptor>
953  describe_parameters(const std::vector<std::string> & names) const;
954 
956 
971  RCLCPP_PUBLIC
972  std::vector<uint8_t>
973  get_parameter_types(const std::vector<std::string> & names) const;
974 
976 
988  RCLCPP_PUBLIC
989  rcl_interfaces::msg::ListParametersResult
990  list_parameters(const std::vector<std::string> & prefixes, uint64_t depth) const;
991 
994  using PreSetParametersCallbackType =
995  rclcpp::node_interfaces::NodeParametersInterface::PreSetParametersCallbackType;
996 
999  using OnSetParametersCallbackType =
1000  rclcpp::node_interfaces::NodeParametersInterface::OnSetParametersCallbackType;
1001 
1004  using PostSetParametersCallbackType =
1005  rclcpp::node_interfaces::NodeParametersInterface::PostSetParametersCallbackType;
1006 
1008 
1063  RCLCPP_PUBLIC
1064  RCUTILS_WARN_UNUSED
1065  PreSetParametersCallbackHandle::SharedPtr
1066  add_pre_set_parameters_callback(PreSetParametersCallbackType callback);
1067 
1069 
1137  RCLCPP_PUBLIC
1138  RCUTILS_WARN_UNUSED
1139  OnSetParametersCallbackHandle::SharedPtr
1140  add_on_set_parameters_callback(OnSetParametersCallbackType callback);
1141 
1143 
1198  RCLCPP_PUBLIC
1199  RCUTILS_WARN_UNUSED
1200  PostSetParametersCallbackHandle::SharedPtr
1201  add_post_set_parameters_callback(PostSetParametersCallbackType callback);
1202 
1204 
1211  RCLCPP_PUBLIC
1212  void
1214 
1216 
1238  RCLCPP_PUBLIC
1239  void
1241 
1243 
1250  RCLCPP_PUBLIC
1251  void
1253 
1255 
1259  RCLCPP_PUBLIC
1260  std::vector<std::string>
1261  get_node_names() const;
1262 
1264 
1268  RCLCPP_PUBLIC
1269  std::map<std::string, std::vector<std::string>>
1270  get_topic_names_and_types() const;
1271 
1273 
1277  RCLCPP_PUBLIC
1278  std::map<std::string, std::vector<std::string>>
1280 
1282 
1291  RCLCPP_PUBLIC
1292  std::map<std::string, std::vector<std::string>>
1294  const std::string & node_name,
1295  const std::string & namespace_) const;
1296 
1298 
1303  RCLCPP_PUBLIC
1304  size_t
1305  count_publishers(const std::string & topic_name) const;
1306 
1308 
1313  RCLCPP_PUBLIC
1314  size_t
1315  count_subscribers(const std::string & topic_name) const;
1316 
1318 
1323  RCLCPP_PUBLIC
1324  size_t
1325  count_clients(const std::string & service_name) const;
1326 
1328 
1333  RCLCPP_PUBLIC
1334  size_t
1335  count_services(const std::string & service_name) const;
1336 
1338 
1359  RCLCPP_PUBLIC
1360  std::vector<rclcpp::TopicEndpointInfo>
1361  get_publishers_info_by_topic(const std::string & topic_name, bool no_mangle = false) const;
1362 
1364 
1385  RCLCPP_PUBLIC
1386  std::vector<rclcpp::TopicEndpointInfo>
1387  get_subscriptions_info_by_topic(const std::string & topic_name, bool no_mangle = false) const;
1388 
1390 
1415  RCLCPP_PUBLIC
1416  std::vector<rclcpp::ServiceEndpointInfo>
1417  get_clients_info_by_service(const std::string & service_name, bool no_mangle = false) const;
1418 
1420 
1445  RCLCPP_PUBLIC
1446  std::vector<rclcpp::ServiceEndpointInfo>
1447  get_servers_info_by_service(const std::string & service_name, bool no_mangle = false) const;
1448 
1450  /* The graph Event object is a loan which must be returned.
1451  * The Event object is scoped and therefore to return the loan just let it go
1452  * out of scope.
1453  */
1454  RCLCPP_PUBLIC
1455  rclcpp::Event::SharedPtr
1456  get_graph_event();
1457 
1459 
1469  RCLCPP_PUBLIC
1470  void
1472  const rclcpp::Event::SharedPtr & event,
1473  std::chrono::nanoseconds timeout);
1474 
1476 
1479  RCLCPP_PUBLIC
1480  rclcpp::Clock::SharedPtr
1481  get_clock();
1482 
1484 
1487  RCLCPP_PUBLIC
1488  rclcpp::Clock::ConstSharedPtr
1489  get_clock() const;
1490 
1492 
1495  RCLCPP_PUBLIC
1496  Time
1497  now() const;
1498 
1500  RCLCPP_PUBLIC
1501  rclcpp::node_interfaces::NodeBaseInterface::SharedPtr
1503 
1505  RCLCPP_PUBLIC
1506  rclcpp::node_interfaces::NodeClockInterface::SharedPtr
1508 
1510  RCLCPP_PUBLIC
1511  rclcpp::node_interfaces::NodeGraphInterface::SharedPtr
1513 
1515  RCLCPP_PUBLIC
1516  rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr
1518 
1520  RCLCPP_PUBLIC
1521  rclcpp::node_interfaces::NodeTimersInterface::SharedPtr
1523 
1525  RCLCPP_PUBLIC
1526  rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr
1528 
1530  RCLCPP_PUBLIC
1531  rclcpp::node_interfaces::NodeServicesInterface::SharedPtr
1533 
1535  RCLCPP_PUBLIC
1536  rclcpp::node_interfaces::NodeWaitablesInterface::SharedPtr
1538 
1540  RCLCPP_PUBLIC
1541  rclcpp::node_interfaces::NodeParametersInterface::SharedPtr
1543 
1545  RCLCPP_PUBLIC
1546  rclcpp::node_interfaces::NodeTimeSourceInterface::SharedPtr
1548 
1550  RCLCPP_PUBLIC
1551  rclcpp::node_interfaces::NodeTypeDescriptionsInterface::SharedPtr
1553 
1555 
1582  RCLCPP_PUBLIC
1583  const std::string &
1584  get_sub_namespace() const;
1585 
1587 
1610  RCLCPP_PUBLIC
1611  const std::string &
1612  get_effective_namespace() const;
1613 
1615 
1656  RCLCPP_PUBLIC
1657  rclcpp::Node::SharedPtr
1658  create_sub_node(const std::string & sub_namespace);
1659 
1661  RCLCPP_PUBLIC
1662  const rclcpp::NodeOptions &
1663  get_node_options() const;
1664 
1665 protected:
1667 
1673  RCLCPP_PUBLIC
1674  Node(
1675  const Node & other,
1676  const std::string & sub_namespace);
1677 
1678 private:
1679  RCLCPP_DISABLE_COPY(Node)
1680 
1681  rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base_;
1682  rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph_;
1683  rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging_;
1684  rclcpp::node_interfaces::NodeTimersInterface::SharedPtr node_timers_;
1685  rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr node_topics_;
1686  rclcpp::node_interfaces::NodeServicesInterface::SharedPtr node_services_;
1687  rclcpp::node_interfaces::NodeClockInterface::SharedPtr node_clock_;
1688  rclcpp::node_interfaces::NodeParametersInterface::SharedPtr node_parameters_;
1689  rclcpp::node_interfaces::NodeTimeSourceInterface::SharedPtr node_time_source_;
1690  rclcpp::node_interfaces::NodeTypeDescriptionsInterface::SharedPtr node_type_descriptions_;
1691  rclcpp::node_interfaces::NodeWaitablesInterface::SharedPtr node_waitables_;
1692 
1693  const rclcpp::NodeOptions node_options_;
1694  const std::string sub_namespace_;
1695  const std::string effective_namespace_;
1696 
1697  class NodeImpl;
1698  // This member is meant to be a place to backport features into stable distributions,
1699  // and new features targeting Rolling should not use this.
1700  // See the comment in node.cpp for more information.
1701  std::shared_ptr<NodeImpl> hidden_impl_{nullptr};
1702 };
1703 
1704 } // namespace rclcpp
1705 
1706 #ifndef RCLCPP__NODE_IMPL_HPP_
1707 // Template implementations
1708 #include "node_impl.hpp"
1709 #endif
1710 
1711 #endif // RCLCPP__NODE_HPP_
Generic timer. Periodically executes a user-specified callback.
Definition: timer.hpp:228
Encapsulation of options for node initialization.
Node is the single point of entry for creating publishers and subscribers.
Definition: node.hpp:79
RCLCPP_PUBLIC rclcpp::Logger get_logger() const
Get the logger of the node.
Definition: node.cpp:332
RCLCPP_PUBLIC rclcpp::node_interfaces::NodeWaitablesInterface::SharedPtr get_node_waitables_interface()
Return the Node's internal NodeWaitablesInterface implementation.
Definition: node.cpp:664
RCLCPP_PUBLIC rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr get_node_topics_interface()
Return the Node's internal NodeTopicsInterface implementation.
Definition: node.cpp:640
RCLCPP_PUBLIC std::vector< rclcpp::ServiceEndpointInfo > get_clients_info_by_service(const std::string &service_name, bool no_mangle=false) const
Return the service endpoint information about clients on a given service.
Definition: node.cpp:553
RCLCPP_PUBLIC std::vector< rclcpp::Parameter > get_parameters(const std::vector< std::string > &names) const
Return the parameters by the given parameter names.
Definition: node.cpp:416
RCLCPP_PUBLIC RCUTILS_WARN_UNUSED OnSetParametersCallbackHandle::SharedPtr add_on_set_parameters_callback(OnSetParametersCallbackType callback)
Add a callback to validate parameters before they are set.
Definition: node.cpp:460
RCLCPP_PUBLIC bool has_parameter(const std::string &name) const
Return true if a given parameter is declared.
Definition: node.cpp:380
RCLCPP_PUBLIC rclcpp::Node::SharedPtr create_sub_node(const std::string &sub_namespace)
Create a sub-node, which will extend the namespace of all entities created with it.
Definition: node.cpp:682
RCLCPP_PUBLIC rcl_interfaces::msg::SetParametersResult set_parameter(const rclcpp::Parameter &parameter)
Set a single parameter.
Definition: node.cpp:386
RCLCPP_PUBLIC rclcpp::Clock::SharedPtr get_clock()
Get a clock as a non-const shared pointer which is managed by the node.
Definition: node.cpp:586
RCLCPP_PUBLIC rclcpp::node_interfaces::NodeTimersInterface::SharedPtr get_node_timers_interface()
Return the Node's internal NodeTimersInterface implementation.
Definition: node.cpp:634
RCLCPP_PUBLIC rclcpp::node_interfaces::NodeParametersInterface::SharedPtr get_node_parameters_interface()
Return the Node's internal NodeParametersInterface implementation.
Definition: node.cpp:658
RCLCPP_PUBLIC std::vector< rclcpp::TopicEndpointInfo > get_publishers_info_by_topic(const std::string &topic_name, bool no_mangle=false) const
Return the topic endpoint information about publishers on a given topic.
Definition: node.cpp:541
rclcpp::GenericService::SharedPtr create_generic_service(const std::string &service_name, const std::string &service_type, CallbackT &&callback, const rclcpp::QoS &qos=rclcpp::ServicesQoS(), const rclcpp::CallbackGroup::SharedPtr &group=nullptr)
Create and return a GenericService.
Definition: node_impl.hpp:177
RCLCPP_PUBLIC const rclcpp::ParameterValue & declare_parameter(const std::string &name, const rclcpp::ParameterValue &default_value, const rcl_interfaces::msg::ParameterDescriptor &parameter_descriptor=rcl_interfaces::msg::ParameterDescriptor(), bool ignore_override=false)
Declare and initialize a parameter, return the effective value.
Definition: node.cpp:346
RCLCPP_PUBLIC rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr get_node_logging_interface()
Return the Node's internal NodeLoggingInterface implementation.
Definition: node.cpp:622
bool get_parameter_or(const std::string &name, ParameterT &parameter, const ParameterT &alternative_value) const
Get the parameter value, or the "alternative_value" if not set, and assign it to "parameter".
Definition: node_impl.hpp:338
RCLCPP_PUBLIC const std::string & get_effective_namespace() const
Return the effective namespace that is used when creating entities.
Definition: node.cpp:676
RCLCPP_PUBLIC size_t count_publishers(const std::string &topic_name) const
Return the number of publishers created for a given topic.
Definition: node.cpp:517
RCLCPP_PUBLIC std::map< std::string, std::vector< std::string > > get_service_names_and_types() const
Return a map of existing service names to list of service types.
Definition: node.cpp:502
RCLCPP_PUBLIC size_t count_subscribers(const std::string &topic_name) const
Return the number of subscribers created for a given topic.
Definition: node.cpp:523
std::vector< ParameterT > declare_parameters(const std::string &namespace_, const std::map< std::string, ParameterT > &parameters, bool ignore_overrides=false)
Declare and initialize several parameters with the same namespace and type.
Definition: node_impl.hpp:275
RCLCPP_PUBLIC std::vector< rcl_interfaces::msg::ParameterDescriptor > describe_parameters(const std::vector< std::string > &names) const
Return a vector of parameter descriptors, one for each of the given names.
Definition: node.cpp:436
RCLCPP_PUBLIC Time now() const
Returns current time from the node clock.
Definition: node.cpp:598
RCLCPP_PUBLIC rclcpp::Event::SharedPtr get_graph_event()
Return a graph event, which will be set anytime a graph change occurs.
Definition: node.cpp:572
RCLCPP_PUBLIC void for_each_callback_group(const node_interfaces::NodeBaseInterface::CallbackGroupFunction &func)
Iterate over the callback groups in the node, calling the given function on each valid one.
Definition: node.cpp:565
RCLCPP_PUBLIC rcl_interfaces::msg::ParameterDescriptor describe_parameter(const std::string &name) const
Return the parameter descriptor for the given parameter name.
Definition: node.cpp:423
RCLCPP_PUBLIC std::vector< rclcpp::ServiceEndpointInfo > get_servers_info_by_service(const std::string &service_name, bool no_mangle=false) const
Return the service endpoint information about servers on a given service.
Definition: node.cpp:559
RCLCPP_PUBLIC void remove_on_set_parameters_callback(const OnSetParametersCallbackHandle *const handler)
Remove a callback registered with add_on_set_parameters_callback.
Definition: node.cpp:478
RCLCPP_PUBLIC std::map< std::string, std::vector< std::string > > get_topic_names_and_types() const
Return a map of existing topic names to list of topic types.
Definition: node.cpp:496
RCLCPP_PUBLIC rclcpp::Parameter get_parameter(const std::string &name) const
Return the parameter by the given name.
Definition: node.cpp:404
RCLCPP_PUBLIC Node(const std::string &node_name, const NodeOptions &options=NodeOptions())
Create a new node with the specified name.
Definition: node.cpp:129
RCLCPP_PUBLIC size_t count_services(const std::string &service_name) const
Return the number of services created for a given service.
Definition: node.cpp:535
rclcpp::GenericTimer< CallbackT >::SharedPtr create_timer(std::chrono::duration< DurationRepT, DurationT > period, CallbackT callback, const rclcpp::CallbackGroup::SharedPtr &group=nullptr)
Create a timer that uses the node clock to drive the callback.
Definition: node_impl.hpp:128
RCLCPP_PUBLIC const rclcpp::NodeOptions & get_node_options() const
Return the NodeOptions used when creating this node.
Definition: node.cpp:690
RCLCPP_PUBLIC rclcpp::node_interfaces::NodeBaseInterface::SharedPtr get_node_base_interface()
Return the Node's internal NodeBaseInterface implementation.
Definition: node.cpp:604
RCLCPP_PUBLIC rcl_interfaces::msg::SetParametersResult set_parameters_atomically(const std::vector< rclcpp::Parameter > &parameters)
Set one or more parameters, all at once.
Definition: node.cpp:398
RCLCPP_PUBLIC rclcpp::node_interfaces::NodeClockInterface::SharedPtr get_node_clock_interface()
Return the Node's internal NodeClockInterface implementation.
Definition: node.cpp:610
RCLCPP_PUBLIC void remove_pre_set_parameters_callback(const PreSetParametersCallbackHandle *const handler)
Remove a callback registered with add_pre_set_parameters_callback.
Definition: node.cpp:472
RCLCPP_PUBLIC const char * get_name() const
Get the name of the node.
Definition: node.cpp:314
RCLCPP_PUBLIC std::vector< rcl_interfaces::msg::SetParametersResult > set_parameters(const std::vector< rclcpp::Parameter > &parameters)
Set one or more parameters, one at a time.
Definition: node.cpp:392
RCLCPP_PUBLIC rclcpp::node_interfaces::NodeTypeDescriptionsInterface::SharedPtr get_node_type_descriptions_interface()
Return the Node's internal NodeTypeDescriptionsInterface implementation.
Definition: node.cpp:646
RCLCPP_PUBLIC rclcpp::node_interfaces::NodeServicesInterface::SharedPtr get_node_services_interface()
Return the Node's internal NodeServicesInterface implementation.
Definition: node.cpp:652
RCLCPP_PUBLIC std::map< std::string, std::vector< std::string > > get_service_names_and_types_by_node(const std::string &node_name, const std::string &namespace_) const
Return a map of existing service names to list of service types for a specific node.
Definition: node.cpp:508
RCLCPP_PUBLIC void undeclare_parameter(const std::string &name)
Undeclare a previously declared parameter.
Definition: node.cpp:374
RCLCPP_PUBLIC std::vector< uint8_t > get_parameter_types(const std::vector< std::string > &names) const
Return a vector of parameter types, one for each of the given names.
Definition: node.cpp:442
RCLCPP_PUBLIC std::vector< rclcpp::TopicEndpointInfo > get_subscriptions_info_by_topic(const std::string &topic_name, bool no_mangle=false) const
Return the topic endpoint information about subscriptions on a given topic.
Definition: node.cpp:547
std::shared_ptr< rclcpp::GenericSubscription > create_generic_subscription(const std::string &topic_name, const std::string &topic_type, const rclcpp::QoS &qos, CallbackT &&callback, const rclcpp::SubscriptionOptionsWithAllocator< AllocatorT > &options=(rclcpp::SubscriptionOptionsWithAllocator< AllocatorT >()))
Create and return a GenericSubscription.
Definition: node_impl.hpp:213
RCLCPP_PUBLIC rclcpp::CallbackGroup::SharedPtr create_callback_group(rclcpp::CallbackGroupType group_type, bool automatically_add_to_executor_with_node=true)
Create and return a callback group.
Definition: node.cpp:338
RCLCPP_PUBLIC rclcpp::node_interfaces::NodeTimeSourceInterface::SharedPtr get_node_time_source_interface()
Return the Node's internal NodeTimeSourceInterface implementation.
Definition: node.cpp:628
RCLCPP_PUBLIC RCUTILS_WARN_UNUSED PreSetParametersCallbackHandle::SharedPtr add_pre_set_parameters_callback(PreSetParametersCallbackType callback)
Add a callback that gets triggered before parameters are validated.
Definition: node.cpp:454
RCLCPP_PUBLIC rcl_interfaces::msg::ListParametersResult list_parameters(const std::vector< std::string > &prefixes, uint64_t depth) const
Return a list of parameters with any of the given prefixes, up to the given depth.
Definition: node.cpp:448
std::shared_ptr< SubscriptionT > create_subscription(const std::string &topic_name, const rclcpp::QoS &qos, CallbackT &&callback, const SubscriptionOptionsWithAllocator< AllocatorT > &options=SubscriptionOptionsWithAllocator< AllocatorT >(), typename MessageMemoryStrategyT::SharedPtr msg_mem_strat=(MessageMemoryStrategyT::create_default()))
Create and return a Subscription.
Definition: node_impl.hpp:93
RCLCPP_PUBLIC size_t count_clients(const std::string &service_name) const
Return the number of clients created for a given service.
Definition: node.cpp:529
std::shared_ptr< PublisherT > create_publisher(const std::string &topic_name, const rclcpp::QoS &qos, const PublisherOptionsWithAllocator< AllocatorT > &options=PublisherOptionsWithAllocator< AllocatorT >())
Create and return a Publisher.
Definition: node_impl.hpp:74
rclcpp::WallTimer< CallbackT >::SharedPtr create_wall_timer(std::chrono::duration< DurationRepT, DurationT > period, CallbackT callback, const rclcpp::CallbackGroup::SharedPtr &group=nullptr, bool autostart=true)
Create a wall timer that uses the wall clock to drive the callback.
Definition: node_impl.hpp:111
RCLCPP_PUBLIC const char * get_fully_qualified_name() const
Get the fully-qualified name of the node.
Definition: node.cpp:326
RCLCPP_PUBLIC const std::string & get_sub_namespace() const
Return the sub-namespace, if this is a sub-node, otherwise an empty string.
Definition: node.cpp:670
RCLCPP_PUBLIC std::vector< std::string > get_node_names() const
Get the fully-qualified names of all available nodes.
Definition: node.cpp:490
rclcpp::Client< ServiceT >::SharedPtr create_client(const std::string &service_name, const rclcpp::QoS &qos=rclcpp::ServicesQoS(), const rclcpp::CallbackGroup::SharedPtr &group=nullptr)
Create and return a Client.
RCLCPP_PUBLIC void wait_for_graph_change(const rclcpp::Event::SharedPtr &event, std::chrono::nanoseconds timeout)
Wait for a graph event to occur by waiting on an Event to become set.
Definition: node.cpp:578
RCLCPP_PUBLIC const char * get_namespace() const
Get the namespace of the node.
Definition: node.cpp:320
RCLCPP_PUBLIC RCUTILS_WARN_UNUSED PostSetParametersCallbackHandle::SharedPtr add_post_set_parameters_callback(PostSetParametersCallbackType callback)
Add a callback that gets triggered after parameters are set successfully.
Definition: node.cpp:466
RCLCPP_PUBLIC rclcpp::node_interfaces::NodeGraphInterface::SharedPtr get_node_graph_interface()
Return the Node's internal NodeGraphInterface implementation.
Definition: node.cpp:616
RCLCPP_PUBLIC void remove_post_set_parameters_callback(const PostSetParametersCallbackHandle *const handler)
Remove a callback registered with add_post_set_parameters_callback.
Definition: node.cpp:484
std::shared_ptr< rclcpp::GenericPublisher > create_generic_publisher(const std::string &topic_name, const std::string &topic_type, const rclcpp::QoS &qos, const rclcpp::PublisherOptionsWithAllocator< AllocatorT > &options=(rclcpp::PublisherOptionsWithAllocator< AllocatorT >()))
Create and return a GenericPublisher.
Definition: node_impl.hpp:196
RCLCPP_PUBLIC rclcpp::GenericClient::SharedPtr create_generic_client(const std::string &service_name, const std::string &service_type, const rclcpp::QoS &qos=rclcpp::ServicesQoS(), const rclcpp::CallbackGroup::SharedPtr &group=nullptr)
Create and return a GenericClient.
Definition: node.cpp:696
rclcpp::Service< ServiceT >::SharedPtr create_service(const std::string &service_name, CallbackT &&callback, const rclcpp::QoS &qos=rclcpp::ServicesQoS(), const rclcpp::CallbackGroup::SharedPtr &group=nullptr)
Create and return a Service.
Definition: node_impl.hpp:160
Store the type and value of a parameter.
Structure to store an arbitrary parameter with templated get/set methods.
Definition: parameter.hpp:53
A publisher publishes messages of any type to a topic.
Definition: publisher.hpp:81
Encapsulation of Quality of Service settings.
Definition: qos.hpp:114
Subscription implementation, templated on the type of message this subscription receives.
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.
Structure containing optional configuration for Publishers.
Structure containing optional configuration for Subscriptions.