Class NodeBase

Inheritance Relationships

Base Types

  • public rclcpp::node_interfaces::NodeBaseInterface (Class NodeBaseInterface)

  • public std::enable_shared_from_this< NodeBase >

Class Documentation

class NodeBase : public rclcpp::node_interfaces::NodeBaseInterface, public std::enable_shared_from_this<NodeBase>

Implementation of the NodeBase part of the Node API.

Public Functions

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.

virtual ~NodeBase()
virtual const char *get_name() const override

Return the name of the node.

Returns:

The name of the node.

virtual const char *get_namespace() const override

Return the namespace of the node.

Returns:

The namespace of the node.

virtual const char *get_fully_qualified_name() const override

Return the fully qualified name of the node.

Returns:

The fully qualified name of the node.

virtual rclcpp::Context::SharedPtr get_context() override

Return the context of the node.

Returns:

SharedPtr to the node’s context.

virtual rcl_node_t *get_rcl_node_handle() override

Return the rcl_node_t node handle (non-const version).

virtual const rcl_node_t *get_rcl_node_handle() const override

Return the rcl_node_t node handle (const version).

virtual std::shared_ptr<rcl_node_t> get_shared_rcl_node_handle() override

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.

virtual std::shared_ptr<const rcl_node_t> get_shared_rcl_node_handle() const override

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.

virtual 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.

virtual rclcpp::CallbackGroup::SharedPtr get_default_callback_group() override

Return the default callback group.

virtual bool callback_group_in_node(rclcpp::CallbackGroup::SharedPtr group) override

Return true if the given callback group is associated with this node.

virtual void for_each_callback_group(const CallbackGroupFunction &func) override

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:

func[in] The callback function to call on each valid callback group.

virtual std::atomic_bool &get_associated_with_executor_atomic() override

Return the atomic bool which is used to ensure only one executor is used.

virtual rclcpp::GuardCondition &get_notify_guard_condition() override

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

virtual rclcpp::GuardCondition::SharedPtr get_shared_notify_guard_condition() override

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

virtual void trigger_notify_guard_condition() override

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

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

virtual bool get_use_intra_process_default() const override

Return the default preference for using intra process communication.

virtual bool get_enable_topic_statistics_default() const override

Return the default preference for enabling topic statistics collection.

virtual 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.