15 #ifndef RCLCPP__NODE_INTERFACES__NODE_BASE_HPP_
16 #define RCLCPP__NODE_INTERFACES__NODE_BASE_HPP_
25 #include "rclcpp/callback_group.hpp"
26 #include "rclcpp/context.hpp"
27 #include "rclcpp/macros.hpp"
28 #include "rclcpp/node_interfaces/node_base_interface.hpp"
29 #include "rclcpp/visibility_control.hpp"
33 namespace node_interfaces
40 RCLCPP_SMART_PTR_ALIASES_ONLY(
NodeBase)
51 const std::string & node_name,
52 const std::string & namespace_,
53 rclcpp::Context::SharedPtr context,
55 bool use_intra_process_default,
56 bool enable_topic_statistics_default,
57 rclcpp::CallbackGroup::SharedPtr default_callback_group =
nullptr);
76 rclcpp::Context::SharedPtr
88 std::shared_ptr<rcl_node_t>
92 std::shared_ptr<const rcl_node_t>
96 rclcpp::CallbackGroup::SharedPtr
98 rclcpp::CallbackGroupType group_type,
99 bool automatically_add_to_executor_with_node =
true)
override;
102 rclcpp::CallbackGroup::SharedPtr
124 [[deprecated(
"Use get_shared_notify_guard_condition or trigger_notify_guard_condition instead")]]
130 rclcpp::GuardCondition::SharedPtr
146 const std::string & name,
bool is_service,
bool only_expand =
false)
const override;
151 rclcpp::Context::SharedPtr context_;
152 bool use_intra_process_default_;
153 bool enable_topic_statistics_default_;
155 std::shared_ptr<rcl_node_t> node_handle_;
157 rclcpp::CallbackGroup::SharedPtr default_callback_group_;
158 std::mutex callback_groups_mutex_;
159 std::vector<rclcpp::CallbackGroup::WeakPtr> callback_groups_;
161 std::atomic_bool associated_with_executor_;
164 mutable std::recursive_mutex notify_guard_condition_mutex_;
165 std::shared_ptr<rclcpp::GuardCondition> notify_guard_condition_;
166 bool notify_guard_condition_is_valid_;
A condition that can be waited on in a single wait set and asynchronously triggered.
Pure virtual interface class for the NodeBase part of the Node API.
Implementation of the NodeBase part of the Node API.
RCLCPP_PUBLIC const char * get_name() const override
Return the name of the node.
bool get_enable_topic_statistics_default() const override
Return the default preference for enabling topic statistics collection.
RCLCPP_PUBLIC bool get_use_intra_process_default() const override
Return the default preference for using intra process communication.
RCLCPP_PUBLIC rclcpp::GuardCondition::SharedPtr get_shared_notify_guard_condition() override
Return a guard condition that should be notified when the internal node state changes.
RCLCPP_PUBLIC rclcpp::CallbackGroup::SharedPtr get_default_callback_group() override
Return the default callback group.
RCLCPP_PUBLIC rclcpp::CallbackGroup::SharedPtr create_callback_group(rclcpp::CallbackGroupType group_type, bool automatically_add_to_executor_with_node=true) override
Create and return a callback group.
RCLCPP_PUBLIC rcl_node_t * get_rcl_node_handle() override
Return the rcl_node_t node handle (non-const version).
std::string resolve_topic_or_service_name(const std::string &name, bool is_service, bool only_expand=false) const override
Expand and remap a given topic or service name.
RCLCPP_PUBLIC rclcpp::GuardCondition & get_notify_guard_condition() override
Return a guard condition that should be notified when the internal node state changes.
RCLCPP_PUBLIC const char * get_namespace() const override
Return the namespace of the node.
RCLCPP_PUBLIC std::shared_ptr< rcl_node_t > get_shared_rcl_node_handle() override
Return the rcl_node_t node handle in a std::shared_ptr.
RCLCPP_PUBLIC void trigger_notify_guard_condition() override
Trigger the guard condition that notifies of internal node state changes.
RCLCPP_PUBLIC void for_each_callback_group(const CallbackGroupFunction &func) override
Iterate over the stored callback groups, calling the given function on each valid one.
RCLCPP_PUBLIC rclcpp::Context::SharedPtr get_context() override
Return the context of the node.
RCLCPP_PUBLIC bool callback_group_in_node(rclcpp::CallbackGroup::SharedPtr group) override
Return true if the given callback group is associated with this node.
RCLCPP_PUBLIC NodeBase(const std::string &node_name, const std::string &namespace_, rclcpp::Context::SharedPtr context, const rcl_node_options_t &rcl_node_options, bool use_intra_process_default, bool enable_topic_statistics_default, rclcpp::CallbackGroup::SharedPtr default_callback_group=nullptr)
Constructor.
RCLCPP_PUBLIC std::atomic_bool & get_associated_with_executor_atomic() override
Return the atomic bool which is used to ensure only one executor is used.
RCLCPP_PUBLIC const char * get_fully_qualified_name() const override
Return the fully qualified name of the node.
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.
Structure which encapsulates the options for creating a rcl_node_t.
Structure which encapsulates a ROS Node.