ROS 2 rclcpp + rcl - rolling  rolling-29de98cf
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/time.hpp"
70 #include "rclcpp/timer.hpp"
71 #include "rclcpp/visibility_control.hpp"
72 
73 namespace rclcpp
74 {
75 
77 class Node : public std::enable_shared_from_this<Node>
78 {
79 public:
80  RCLCPP_SMART_PTR_DEFINITIONS(Node)
81 
82 
88  RCLCPP_PUBLIC
89  explicit Node(
90  const std::string & node_name,
91  const NodeOptions & options = NodeOptions());
92 
94 
100  RCLCPP_PUBLIC
101  explicit Node(
102  const std::string & node_name,
103  const std::string & namespace_,
104  const NodeOptions & options = NodeOptions());
105 
106  RCLCPP_PUBLIC
107  virtual ~Node();
108 
110 
111  RCLCPP_PUBLIC
112  const char *
113  get_name() const;
114 
116 
125  RCLCPP_PUBLIC
126  const char *
127  get_namespace() const;
128 
130 
134  RCLCPP_PUBLIC
135  const char *
136  get_fully_qualified_name() const;
137 
139 
140  RCLCPP_PUBLIC
142  get_logger() const;
143 
145  RCLCPP_PUBLIC
146  rclcpp::CallbackGroup::SharedPtr
148  rclcpp::CallbackGroupType group_type,
149  bool automatically_add_to_executor_with_node = true);
150 
152 
158  RCLCPP_PUBLIC
159  void
160  for_each_callback_group(const node_interfaces::NodeBaseInterface::CallbackGroupFunction & func);
161 
163 
190  template<
191  typename MessageT,
192  typename AllocatorT = std::allocator<void>,
193  typename PublisherT = rclcpp::Publisher<MessageT, AllocatorT>>
194  std::shared_ptr<PublisherT>
196  const std::string & topic_name,
197  const rclcpp::QoS & qos,
200  );
201 
203 
211  template<
212  typename MessageT,
213  typename CallbackT,
214  typename AllocatorT = std::allocator<void>,
215  typename SubscriptionT = rclcpp::Subscription<MessageT, AllocatorT>,
216  typename MessageMemoryStrategyT = typename SubscriptionT::MessageMemoryStrategyType
217  >
218  std::shared_ptr<SubscriptionT>
220  const std::string & topic_name,
221  const rclcpp::QoS & qos,
222  CallbackT && callback,
225  typename MessageMemoryStrategyT::SharedPtr msg_mem_strat = (
226  MessageMemoryStrategyT::create_default()
227  )
228  );
229 
231 
237  template<typename DurationRepT = int64_t, typename DurationT = std::milli, typename CallbackT>
240  std::chrono::duration<DurationRepT, DurationT> period,
241  CallbackT callback,
242  const rclcpp::CallbackGroup::SharedPtr & group = nullptr,
243  bool autostart = true);
244 
246 
251  template<typename DurationRepT = int64_t, typename DurationT = std::milli, typename CallbackT>
253  create_timer(
254  std::chrono::duration<DurationRepT, DurationT> period,
255  CallbackT callback,
256  const rclcpp::CallbackGroup::SharedPtr & group = nullptr);
257 
259 
265  template<typename ServiceT>
268  const std::string & service_name,
269  const rclcpp::QoS & qos = rclcpp::ServicesQoS(),
270  const rclcpp::CallbackGroup::SharedPtr & group = nullptr);
271 
273 
280  template<typename ServiceT, typename CallbackT>
283  const std::string & service_name,
284  CallbackT && callback,
285  const rclcpp::QoS & qos = rclcpp::ServicesQoS(),
286  const rclcpp::CallbackGroup::SharedPtr & group = nullptr);
287 
289 
296  RCLCPP_PUBLIC
297  rclcpp::GenericClient::SharedPtr
299  const std::string & service_name,
300  const std::string & service_type,
301  const rclcpp::QoS & qos = rclcpp::ServicesQoS(),
302  const rclcpp::CallbackGroup::SharedPtr & group = nullptr);
303 
305 
313  template<typename CallbackT>
314  typename rclcpp::GenericService::SharedPtr
316  const std::string & service_name,
317  const std::string & service_type,
318  CallbackT && callback,
319  const rclcpp::QoS & qos = rclcpp::ServicesQoS(),
320  const rclcpp::CallbackGroup::SharedPtr & group = nullptr);
321 
323 
335  template<typename AllocatorT = std::allocator<void>>
336  std::shared_ptr<rclcpp::GenericPublisher> create_generic_publisher(
337  const std::string & topic_name,
338  const std::string & topic_type,
339  const rclcpp::QoS & qos,
342  )
343  );
344 
346 
360  template<
361  typename CallbackT,
362  typename AllocatorT = std::allocator<void>>
363  std::shared_ptr<rclcpp::GenericSubscription> create_generic_subscription(
364  const std::string & topic_name,
365  const std::string & topic_type,
366  const rclcpp::QoS & qos,
367  CallbackT && callback,
370  )
371  );
372 
374 
425  RCLCPP_PUBLIC
426  const rclcpp::ParameterValue &
428  const std::string & name,
429  const rclcpp::ParameterValue & default_value,
430  const rcl_interfaces::msg::ParameterDescriptor & parameter_descriptor =
431  rcl_interfaces::msg::ParameterDescriptor(),
432  bool ignore_override = false);
433 
435 
450  RCLCPP_PUBLIC
451  const rclcpp::ParameterValue &
453  const std::string & name,
454  rclcpp::ParameterType type,
455  const rcl_interfaces::msg::ParameterDescriptor & parameter_descriptor =
456  rcl_interfaces::msg::ParameterDescriptor{},
457  bool ignore_override = false);
458 
460 
480  template<typename ParameterT>
481  auto
483  const std::string & name,
484  const ParameterT & default_value,
485  const rcl_interfaces::msg::ParameterDescriptor & parameter_descriptor =
486  rcl_interfaces::msg::ParameterDescriptor(),
487  bool ignore_override = false);
488 
490 
493  template<typename ParameterT>
494  auto
496  const std::string & name,
497  const rcl_interfaces::msg::ParameterDescriptor & parameter_descriptor =
498  rcl_interfaces::msg::ParameterDescriptor(),
499  bool ignore_override = false);
500 
502 
548  template<typename ParameterT>
549  std::vector<ParameterT>
551  const std::string & namespace_,
552  const std::map<std::string, ParameterT> & parameters,
553  bool ignore_overrides = false);
554 
556 
562  template<typename ParameterT>
563  std::vector<ParameterT>
565  const std::string & namespace_,
566  const std::map<
567  std::string,
568  std::pair<ParameterT, rcl_interfaces::msg::ParameterDescriptor>
569  > & parameters,
570  bool ignore_overrides = false);
571 
573 
584  RCLCPP_PUBLIC
585  void
586  undeclare_parameter(const std::string & name);
587 
589 
593  RCLCPP_PUBLIC
594  bool
595  has_parameter(const std::string & name) const;
596 
598 
639  RCLCPP_PUBLIC
640  rcl_interfaces::msg::SetParametersResult
641  set_parameter(const rclcpp::Parameter & parameter);
642 
644 
691  RCLCPP_PUBLIC
692  std::vector<rcl_interfaces::msg::SetParametersResult>
693  set_parameters(const std::vector<rclcpp::Parameter> & parameters);
694 
696 
739  RCLCPP_PUBLIC
740  rcl_interfaces::msg::SetParametersResult
741  set_parameters_atomically(const std::vector<rclcpp::Parameter> & parameters);
742 
744 
763  RCLCPP_PUBLIC
765  get_parameter(const std::string & name) const;
766 
768 
782  RCLCPP_PUBLIC
783  bool
784  get_parameter(const std::string & name, rclcpp::Parameter & parameter) const;
785 
787 
799  template<typename ParameterT>
800  bool
801  get_parameter(const std::string & name, ParameterT & parameter) const;
802 
804 
818  template<typename ParameterT>
819  bool
821  const std::string & name,
822  ParameterT & parameter,
823  const ParameterT & alternative_value) const;
824 
826 
837  template<typename ParameterT>
838  ParameterT
840  const std::string & name,
841  const ParameterT & alternative_value) const;
842 
844 
863  RCLCPP_PUBLIC
864  std::vector<rclcpp::Parameter>
865  get_parameters(const std::vector<std::string> & names) const;
866 
868 
904  template<typename ParameterT>
905  bool
907  const std::string & prefix,
908  std::map<std::string, ParameterT> & values) const;
909 
911 
927  RCLCPP_PUBLIC
928  rcl_interfaces::msg::ParameterDescriptor
929  describe_parameter(const std::string & name) const;
930 
932 
950  RCLCPP_PUBLIC
951  std::vector<rcl_interfaces::msg::ParameterDescriptor>
952  describe_parameters(const std::vector<std::string> & names) const;
953 
955 
970  RCLCPP_PUBLIC
971  std::vector<uint8_t>
972  get_parameter_types(const std::vector<std::string> & names) const;
973 
975 
987  RCLCPP_PUBLIC
988  rcl_interfaces::msg::ListParametersResult
989  list_parameters(const std::vector<std::string> & prefixes, uint64_t depth) const;
990 
993  using PreSetParametersCallbackType =
994  rclcpp::node_interfaces::NodeParametersInterface::PreSetParametersCallbackType;
995 
998  using OnSetParametersCallbackType =
999  rclcpp::node_interfaces::NodeParametersInterface::OnSetParametersCallbackType;
1000 
1003  using PostSetParametersCallbackType =
1004  rclcpp::node_interfaces::NodeParametersInterface::PostSetParametersCallbackType;
1005 
1007 
1062  RCLCPP_PUBLIC
1063  RCUTILS_WARN_UNUSED
1064  PreSetParametersCallbackHandle::SharedPtr
1065  add_pre_set_parameters_callback(PreSetParametersCallbackType callback);
1066 
1068 
1136  RCLCPP_PUBLIC
1137  RCUTILS_WARN_UNUSED
1138  OnSetParametersCallbackHandle::SharedPtr
1139  add_on_set_parameters_callback(OnSetParametersCallbackType callback);
1140 
1142 
1197  RCLCPP_PUBLIC
1198  RCUTILS_WARN_UNUSED
1199  PostSetParametersCallbackHandle::SharedPtr
1200  add_post_set_parameters_callback(PostSetParametersCallbackType callback);
1201 
1203 
1210  RCLCPP_PUBLIC
1211  void
1213 
1215 
1237  RCLCPP_PUBLIC
1238  void
1240 
1242 
1249  RCLCPP_PUBLIC
1250  void
1252 
1254 
1258  RCLCPP_PUBLIC
1259  std::vector<std::string>
1260  get_node_names() const;
1261 
1263 
1267  RCLCPP_PUBLIC
1268  std::map<std::string, std::vector<std::string>>
1269  get_topic_names_and_types() const;
1270 
1272 
1276  RCLCPP_PUBLIC
1277  std::map<std::string, std::vector<std::string>>
1279 
1281 
1290  RCLCPP_PUBLIC
1291  std::map<std::string, std::vector<std::string>>
1293  const std::string & node_name,
1294  const std::string & namespace_) const;
1295 
1297 
1302  RCLCPP_PUBLIC
1303  size_t
1304  count_publishers(const std::string & topic_name) const;
1305 
1307 
1312  RCLCPP_PUBLIC
1313  size_t
1314  count_subscribers(const std::string & topic_name) const;
1315 
1317 
1322  RCLCPP_PUBLIC
1323  size_t
1324  count_clients(const std::string & service_name) const;
1325 
1327 
1332  RCLCPP_PUBLIC
1333  size_t
1334  count_services(const std::string & service_name) const;
1335 
1337 
1358  RCLCPP_PUBLIC
1359  std::vector<rclcpp::TopicEndpointInfo>
1360  get_publishers_info_by_topic(const std::string & topic_name, bool no_mangle = false) const;
1361 
1363 
1384  RCLCPP_PUBLIC
1385  std::vector<rclcpp::TopicEndpointInfo>
1386  get_subscriptions_info_by_topic(const std::string & topic_name, bool no_mangle = false) const;
1387 
1389 
1414  RCLCPP_PUBLIC
1415  std::vector<rclcpp::ServiceEndpointInfo>
1416  get_clients_info_by_service(const std::string & service_name, bool no_mangle = false) const;
1417 
1419 
1444  RCLCPP_PUBLIC
1445  std::vector<rclcpp::ServiceEndpointInfo>
1446  get_servers_info_by_service(const std::string & service_name, bool no_mangle = false) const;
1447 
1449  /* The graph Event object is a loan which must be returned.
1450  * The Event object is scoped and therefore to return the loan just let it go
1451  * out of scope.
1452  */
1453  RCLCPP_PUBLIC
1454  rclcpp::Event::SharedPtr
1455  get_graph_event();
1456 
1458 
1468  RCLCPP_PUBLIC
1469  void
1471  const rclcpp::Event::SharedPtr & event,
1472  std::chrono::nanoseconds timeout);
1473 
1475 
1478  RCLCPP_PUBLIC
1479  rclcpp::Clock::SharedPtr
1480  get_clock();
1481 
1483 
1486  RCLCPP_PUBLIC
1487  rclcpp::Clock::ConstSharedPtr
1488  get_clock() const;
1489 
1491 
1494  RCLCPP_PUBLIC
1495  Time
1496  now() const;
1497 
1499  RCLCPP_PUBLIC
1500  rclcpp::node_interfaces::NodeBaseInterface::SharedPtr
1502 
1504  RCLCPP_PUBLIC
1505  rclcpp::node_interfaces::NodeClockInterface::SharedPtr
1507 
1509  RCLCPP_PUBLIC
1510  rclcpp::node_interfaces::NodeGraphInterface::SharedPtr
1512 
1514  RCLCPP_PUBLIC
1515  rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr
1517 
1519  RCLCPP_PUBLIC
1520  rclcpp::node_interfaces::NodeTimersInterface::SharedPtr
1522 
1524  RCLCPP_PUBLIC
1525  rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr
1527 
1529  RCLCPP_PUBLIC
1530  rclcpp::node_interfaces::NodeServicesInterface::SharedPtr
1532 
1534  RCLCPP_PUBLIC
1535  rclcpp::node_interfaces::NodeWaitablesInterface::SharedPtr
1537 
1539  RCLCPP_PUBLIC
1540  rclcpp::node_interfaces::NodeParametersInterface::SharedPtr
1542 
1544  RCLCPP_PUBLIC
1545  rclcpp::node_interfaces::NodeTimeSourceInterface::SharedPtr
1547 
1549  RCLCPP_PUBLIC
1550  rclcpp::node_interfaces::NodeTypeDescriptionsInterface::SharedPtr
1552 
1554 
1581  RCLCPP_PUBLIC
1582  const std::string &
1583  get_sub_namespace() const;
1584 
1586 
1609  RCLCPP_PUBLIC
1610  const std::string &
1611  get_effective_namespace() const;
1612 
1614 
1655  RCLCPP_PUBLIC
1656  rclcpp::Node::SharedPtr
1657  create_sub_node(const std::string & sub_namespace);
1658 
1660  RCLCPP_PUBLIC
1661  const rclcpp::NodeOptions &
1662  get_node_options() const;
1663 
1664 protected:
1666 
1672  RCLCPP_PUBLIC
1673  Node(
1674  const Node & other,
1675  const std::string & sub_namespace);
1676 
1677 private:
1678  RCLCPP_DISABLE_COPY(Node)
1679 
1680  rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base_;
1681  rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph_;
1682  rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging_;
1683  rclcpp::node_interfaces::NodeTimersInterface::SharedPtr node_timers_;
1684  rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr node_topics_;
1685  rclcpp::node_interfaces::NodeServicesInterface::SharedPtr node_services_;
1686  rclcpp::node_interfaces::NodeClockInterface::SharedPtr node_clock_;
1687  rclcpp::node_interfaces::NodeParametersInterface::SharedPtr node_parameters_;
1688  rclcpp::node_interfaces::NodeTimeSourceInterface::SharedPtr node_time_source_;
1689  rclcpp::node_interfaces::NodeTypeDescriptionsInterface::SharedPtr node_type_descriptions_;
1690  rclcpp::node_interfaces::NodeWaitablesInterface::SharedPtr node_waitables_;
1691 
1692  const rclcpp::NodeOptions node_options_;
1693  const std::string sub_namespace_;
1694  const std::string effective_namespace_;
1695 
1696  class NodeImpl;
1697  // This member is meant to be a place to backport features into stable distributions,
1698  // and new features targeting Rolling should not use this.
1699  // See the comment in node.cpp for more information.
1700  std::shared_ptr<NodeImpl> hidden_impl_{nullptr};
1701 };
1702 
1703 } // namespace rclcpp
1704 
1705 #ifndef RCLCPP__NODE_IMPL_HPP_
1706 // Template implementations
1707 #include "node_impl.hpp"
1708 #endif
1709 
1710 #endif // RCLCPP__NODE_HPP_
Generic timer. Periodically executes a user-specified callback.
Definition: timer.hpp:227
Encapsulation of options for node initialization.
Node is the single point of entry for creating publishers and subscribers.
Definition: node.hpp:78
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:170
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:331
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:268
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:121
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:206
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:86
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:67
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:104
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:189
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:153
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:79
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.