ROS 2 rclcpp + rcl - kilted  kilted
ROS 2 C++ Client Library with ROS Client Library
Public Member Functions | List of all members
rclcpp::node_interfaces::NodeBase Class Reference

Implementation of the NodeBase part of the Node API. More...

#include <rclcpp/node_interfaces/node_base.hpp>

Inheritance diagram for rclcpp::node_interfaces::NodeBase:
Inheritance graph
[legend]
Collaboration diagram for rclcpp::node_interfaces::NodeBase:
Collaboration graph
[legend]

Public Member Functions

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. More...
 
RCLCPP_PUBLIC const char * get_name () const override
 Return the name of the node. More...
 
RCLCPP_PUBLIC const char * get_namespace () const override
 Return the namespace of the node. More...
 
RCLCPP_PUBLIC const char * get_fully_qualified_name () const override
 Return the fully qualified name of the node. More...
 
RCLCPP_PUBLIC rclcpp::Context::SharedPtr get_context () override
 Return the context of the node. More...
 
RCLCPP_PUBLIC rcl_node_tget_rcl_node_handle () override
 Return the rcl_node_t node handle (non-const version).
 
RCLCPP_PUBLIC const rcl_node_tget_rcl_node_handle () const override
 Return the rcl_node_t node handle (const version).
 
RCLCPP_PUBLIC std::shared_ptr< rcl_node_tget_shared_rcl_node_handle () override
 Return the rcl_node_t node handle in a std::shared_ptr. More...
 
RCLCPP_PUBLIC std::shared_ptr< const rcl_node_tget_shared_rcl_node_handle () const override
 Return the rcl_node_t node handle in a std::shared_ptr. More...
 
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 rclcpp::CallbackGroup::SharedPtr get_default_callback_group () override
 Return the default callback group.
 
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 void for_each_callback_group (const CallbackGroupFunction &func) override
 Iterate over the stored callback groups, calling the given function on each valid one. More...
 
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 rclcpp::GuardConditionget_notify_guard_condition () override
 Return a guard condition that should be notified when the internal node state changes. More...
 
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. More...
 
RCLCPP_PUBLIC void trigger_notify_guard_condition () override
 Trigger the guard condition that notifies of internal node state changes. More...
 
RCLCPP_PUBLIC bool get_use_intra_process_default () const override
 Return the default preference for using intra process communication.
 
bool get_enable_topic_statistics_default () const override
 Return the default preference for enabling topic statistics collection.
 
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.
 

Additional Inherited Members

- Public Types inherited from rclcpp::node_interfaces::NodeBaseInterface
using CallbackGroupFunction = std::function< void(rclcpp::CallbackGroup::SharedPtr)>
 

Detailed Description

Implementation of the NodeBase part of the Node API.

Definition at line 37 of file node_base.hpp.

Constructor & Destructor Documentation

◆ NodeBase()

NodeBase::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.

If nullptr (default) is given for the default_callback_group, one will be created by the constructor using the create_callback_group() method, but virtual dispatch will not occur so overrides of that method will not be used.

Definition at line 37 of file node_base.cpp.

References rcl_node_options_s::enable_rosout, rcl_get_zero_initialized_node(), rcl_logging_rosout_enabled(), rcl_logging_rosout_init_publisher_for_node(), rcl_node_fini(), rcl_node_init(), RCL_RET_ERROR, RCL_RET_INVALID_ARGUMENT, RCL_RET_NODE_INVALID_NAME, RCL_RET_NODE_INVALID_NAMESPACE, and RCL_RET_OK.

Here is the call graph for this function:

Member Function Documentation

◆ for_each_callback_group()

void NodeBase::for_each_callback_group ( const CallbackGroupFunction &  func)
overridevirtual

Iterate over the stored callback groups, calling the given function on each valid one.

This method is called in a thread-safe way, and also makes sure to only call the given function on those items that are still valid.

Parameters
[in]funcThe callback function to call on each valid callback group.

Implements rclcpp::node_interfaces::NodeBaseInterface.

Definition at line 261 of file node_base.cpp.

◆ get_context()

rclcpp::Context::SharedPtr NodeBase::get_context ( )
overridevirtual

Return the context of the node.

Returns
SharedPtr to the node's context.

Implements rclcpp::node_interfaces::NodeBaseInterface.

Definition at line 189 of file node_base.cpp.

◆ get_fully_qualified_name()

const char * NodeBase::get_fully_qualified_name ( ) const
overridevirtual

Return the fully qualified name of the node.

Returns
The fully qualified name of the node.

Implements rclcpp::node_interfaces::NodeBaseInterface.

Definition at line 183 of file node_base.cpp.

References rcl_node_get_fully_qualified_name().

Here is the call graph for this function:

◆ get_name()

const char * NodeBase::get_name ( ) const
overridevirtual

Return the name of the node.

Returns
The name of the node.

Implements rclcpp::node_interfaces::NodeBaseInterface.

Definition at line 171 of file node_base.cpp.

References rcl_node_get_name().

Here is the call graph for this function:

◆ get_namespace()

const char * NodeBase::get_namespace ( ) const
overridevirtual

Return the namespace of the node.

Returns
The namespace of the node.

Implements rclcpp::node_interfaces::NodeBaseInterface.

Definition at line 177 of file node_base.cpp.

References rcl_node_get_namespace().

Here is the call graph for this function:

◆ get_notify_guard_condition()

rclcpp::GuardCondition & NodeBase::get_notify_guard_condition ( )
overridevirtual

Return a guard condition that should be notified when the internal node state changes.

For example, this should be notified when a publisher is added or removed.

Returns
the GuardCondition if it is valid, else throw runtime error

Implements rclcpp::node_interfaces::NodeBaseInterface.

Definition at line 279 of file node_base.cpp.

◆ get_shared_notify_guard_condition()

rclcpp::GuardCondition::SharedPtr NodeBase::get_shared_notify_guard_condition ( )
overridevirtual

Return a guard condition that should be notified when the internal node state changes.

For example, this should be notified when a publisher is added or removed.

Returns
the GuardCondition if it is valid, else nullptr

Implements rclcpp::node_interfaces::NodeBaseInterface.

Definition at line 289 of file node_base.cpp.

◆ get_shared_rcl_node_handle() [1/2]

std::shared_ptr< const rcl_node_t > NodeBase::get_shared_rcl_node_handle ( ) const
overridevirtual

Return the rcl_node_t node handle in a std::shared_ptr.

This handle remains valid after the Node is destroyed. The actual rcl node is not finalized until it is out of scope everywhere.

Implements rclcpp::node_interfaces::NodeBaseInterface.

Definition at line 213 of file node_base.cpp.

◆ get_shared_rcl_node_handle() [2/2]

std::shared_ptr< rcl_node_t > NodeBase::get_shared_rcl_node_handle ( )
overridevirtual

Return the rcl_node_t node handle in a std::shared_ptr.

This handle remains valid after the Node is destroyed. The actual rcl node is not finalized until it is out of scope everywhere.

Implements rclcpp::node_interfaces::NodeBaseInterface.

Definition at line 207 of file node_base.cpp.

◆ trigger_notify_guard_condition()

void NodeBase::trigger_notify_guard_condition ( )
overridevirtual

Trigger the guard condition that notifies of internal node state changes.

For example, this should be notified when a publisher is added or removed.

Implements rclcpp::node_interfaces::NodeBaseInterface.

Definition at line 299 of file node_base.cpp.

Referenced by create_callback_group().

Here is the caller graph for this function:

The documentation for this class was generated from the following files: