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

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

#include <rclcpp/node_interfaces/node_graph.hpp>

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

Public Member Functions

RCLCPP_PUBLIC NodeGraph (rclcpp::node_interfaces::NodeBaseInterface *node_base)
 
RCLCPP_PUBLIC std::map< std::string, std::vector< std::string > > get_topic_names_and_types (bool no_demangle=false) const override
 Return a map of existing topic names to list of topic types. More...
 
RCLCPP_PUBLIC std::map< std::string, std::vector< std::string > > get_service_names_and_types () const override
 Return a map of existing service names to list of service types. More...
 
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 override
 Return a map of existing service names to list of service types for a specific node. More...
 
RCLCPP_PUBLIC std::map< std::string, std::vector< std::string > > get_client_names_and_types_by_node (const std::string &node_name, const std::string &namespace_) const override
 Return a map of existing service names and types with a specific node. More...
 
RCLCPP_PUBLIC std::map< std::string, std::vector< std::string > > get_publisher_names_and_types_by_node (const std::string &node_name, const std::string &namespace_, bool no_demangle=false) const override
 Return a map of existing topic names to list of topic types for a specific node. More...
 
RCLCPP_PUBLIC std::map< std::string, std::vector< std::string > > get_subscriber_names_and_types_by_node (const std::string &node_name, const std::string &namespace_, bool no_demangle=false) const override
 Return a map of existing topic names to list of topic types for a specific node. More...
 
RCLCPP_PUBLIC std::vector< std::string > get_node_names () const override
 Return a vector of existing node names (string).
 
RCLCPP_PUBLIC std::vector< std::tuple< std::string, std::string, std::string > > get_node_names_with_enclaves () const override
 Return a vector of existing node names, namespaces and enclaves (tuple of string).
 
RCLCPP_PUBLIC std::vector< std::pair< std::string, std::string > > get_node_names_and_namespaces () const override
 Return a vector of existing node names and namespaces (pair of string).
 
RCLCPP_PUBLIC size_t count_publishers (const std::string &topic_name) const override
 Return the number of publishers that are advertised on a given topic.
 
RCLCPP_PUBLIC size_t count_subscribers (const std::string &topic_name) const override
 Return the number of subscribers who have created a subscription for a given topic.
 
RCLCPP_PUBLIC const rcl_guard_condition_tget_graph_guard_condition () const override
 Return the rcl guard condition which is triggered when the ROS graph changes.
 
RCLCPP_PUBLIC void notify_graph_change () override
 Notify threads waiting on graph changes. More...
 
RCLCPP_PUBLIC void notify_shutdown () override
 Notify any and all blocking node actions that shutdown has occurred.
 
RCLCPP_PUBLIC rclcpp::Event::SharedPtr get_graph_event () override
 Return a graph event, which will be set anytime a graph change occurs. More...
 
RCLCPP_PUBLIC void wait_for_graph_change (rclcpp::Event::SharedPtr event, std::chrono::nanoseconds timeout) override
 Wait for a graph event to occur by waiting on an Event to become set. More...
 
RCLCPP_PUBLIC size_t count_graph_users () const override
 Return the number of on loan graph events, see get_graph_event(). More...
 
RCLCPP_PUBLIC std::vector< rclcpp::TopicEndpointInfoget_publishers_info_by_topic (const std::string &topic_name, bool no_mangle=false) const override
 Return the topic endpoint information about publishers on a given topic. More...
 
RCLCPP_PUBLIC std::vector< rclcpp::TopicEndpointInfoget_subscriptions_info_by_topic (const std::string &topic_name, bool no_mangle=false) const override
 Return the topic endpoint information about subscriptions on a given topic. More...
 

Detailed Description

Implementation the NodeGraph part of the Node API.

Definition at line 48 of file node_graph.hpp.

Member Function Documentation

◆ count_graph_users()

size_t NodeGraph::count_graph_users ( ) const
overridevirtual

Return the number of on loan graph events, see get_graph_event().

This is typically only used by the rclcpp::graph_listener::GraphListener.

Implements rclcpp::node_interfaces::NodeGraphInterface.

Definition at line 602 of file node_graph.cpp.

◆ get_client_names_and_types_by_node()

std::map< std::string, std::vector< std::string > > NodeGraph::get_client_names_and_types_by_node ( const std::string &  node_name,
const std::string &  namespace_ 
) const
overridevirtual

Return a map of existing service names and types with a specific node.

This function only considers clients - not service servers. The returned names are the actual names after remap rules applied. Attempting to create service servers using names returned by this function may not result in the desired service name being used depending on the remap rules in use.

Parameters
[in]node_namename of the node
[in]namespace_namespace of the node

Implements rclcpp::node_interfaces::NodeGraphInterface.

Definition at line 184 of file node_graph.cpp.

References rclcpp::get_logger(), rclcpp::node_interfaces::NodeBaseInterface::get_rcl_node_handle(), rcl_get_client_names_and_types_by_node(), rcl_get_default_allocator, rcl_get_zero_initialized_names_and_types, rcl_names_and_types_fini(), and RCL_RET_OK.

Here is the call graph for this function:

◆ get_graph_event()

rclcpp::Event::SharedPtr NodeGraph::get_graph_event ( )
overridevirtual

Return a graph event, which will be set anytime a graph change occurs.

The graph Event object is a loan which must be returned. The Event object is scoped and therefore to return the load just let it go out of scope.

Implements rclcpp::node_interfaces::NodeGraphInterface.

Definition at line 553 of file node_graph.cpp.

◆ get_publisher_names_and_types_by_node()

std::map< std::string, std::vector< std::string > > NodeGraph::get_publisher_names_and_types_by_node ( const std::string &  node_name,
const std::string &  namespace_,
bool  no_demangle = false 
) const
overridevirtual

Return a map of existing topic names to list of topic types for a specific node.

This function only considers publishers - not subscribers. The returned names are the actual names after remap rules applied. Attempting to create publishers or subscribers using names returned by this function may not result in the desired topic name being used depending on the remap rules in use.

Parameters
[in]node_namename of the node
[in]namespace_namespace of the node
[in]no_demangleif true, topic names and types are not demangled

Implements rclcpp::node_interfaces::NodeGraphInterface.

Definition at line 219 of file node_graph.cpp.

References rclcpp::get_logger(), rclcpp::node_interfaces::NodeBaseInterface::get_rcl_node_handle(), rcl_get_default_allocator, rcl_get_publisher_names_and_types_by_node(), rcl_get_zero_initialized_names_and_types, rcl_names_and_types_fini(), and RCL_RET_OK.

Here is the call graph for this function:

◆ get_publishers_info_by_topic()

std::vector< rclcpp::TopicEndpointInfo > NodeGraph::get_publishers_info_by_topic ( const std::string &  topic_name,
bool  no_mangle = false 
) const
overridevirtual

Return the topic endpoint information about publishers on a given topic.

Parameters
[in]topic_namethe actual topic name used; it will not be automatically remapped.
[in]no_mangleif true, topic_name needs to be a valid middleware topic name, otherwise it should be a valid ROS topic name.
See also
rclcpp::Node::get_publishers_info_by_topic

Implements rclcpp::node_interfaces::NodeGraphInterface.

Definition at line 697 of file node_graph.cpp.

References rcl_get_publishers_info_by_topic().

Here is the call graph for this function:

◆ get_service_names_and_types()

std::map< std::string, std::vector< std::string > > NodeGraph::get_service_names_and_types ( ) const
overridevirtual

Return a map of existing service names to list of service types.

A service is considered to exist when at least one service server or service client exists for it, whether they be local or remote to this process. The returned names are the actual names of the services, either announced by another nodes or by this one. Attempting to create clients or services using names returned by this function may not result in the desired service name being used depending on the remap rules in use.

Implements rclcpp::node_interfaces::NodeGraphInterface.

Definition at line 100 of file node_graph.cpp.

References rclcpp::node_interfaces::NodeBaseInterface::get_rcl_node_handle(), rcl_get_default_allocator, rcl_get_service_names_and_types(), rcl_get_zero_initialized_names_and_types, rcl_names_and_types_fini(), and RCL_RET_OK.

Here is the call graph for this function:

◆ get_service_names_and_types_by_node()

std::map< std::string, std::vector< std::string > > NodeGraph::get_service_names_and_types_by_node ( const std::string &  node_name,
const std::string &  namespace_ 
) const
overridevirtual

Return a map of existing service names to list of service types for a specific node.

This function only considers services - not clients. The returned names are the actual names after remap rules applied. Attempting to create service clients using names returned by this function may not result in the desired service name being used depending on the remap rules in use.

Parameters
[in]node_namename of the node
[in]namespace_namespace of the node

Implements rclcpp::node_interfaces::NodeGraphInterface.

Definition at line 142 of file node_graph.cpp.

References rclcpp::node_interfaces::NodeBaseInterface::get_rcl_node_handle(), rcl_get_default_allocator, rcl_get_service_names_and_types_by_node(), rcl_get_zero_initialized_names_and_types, rcl_names_and_types_fini(), and RCL_RET_OK.

Here is the call graph for this function:

◆ get_subscriber_names_and_types_by_node()

std::map< std::string, std::vector< std::string > > NodeGraph::get_subscriber_names_and_types_by_node ( const std::string &  node_name,
const std::string &  namespace_,
bool  no_demangle = false 
) const
overridevirtual

Return a map of existing topic names to list of topic types for a specific node.

This function only considers subscribers - not publishers. The returned names are the actual names after remap rules applied. Attempting to create publishers or subscribers using names returned by this function may not result in the desired topic name being used depending on the remap rules in use.

Parameters
[in]node_namename of the node
[in]namespace_namespace of the node
[in]no_demangleif true, topic names and types are not demangled

Implements rclcpp::node_interfaces::NodeGraphInterface.

Definition at line 256 of file node_graph.cpp.

References rclcpp::get_logger(), rclcpp::node_interfaces::NodeBaseInterface::get_rcl_node_handle(), rcl_get_default_allocator, rcl_get_subscriber_names_and_types_by_node(), rcl_get_zero_initialized_names_and_types, rcl_names_and_types_fini(), and RCL_RET_OK.

Here is the call graph for this function:

◆ get_subscriptions_info_by_topic()

std::vector< rclcpp::TopicEndpointInfo > NodeGraph::get_subscriptions_info_by_topic ( const std::string &  topic_name,
bool  no_mangle = false 
) const
overridevirtual

Return the topic endpoint information about subscriptions on a given topic.

Parameters
[in]topic_namethe actual topic name used; it will not be automatically remapped.
[in]no_mangleif true, topic_name needs to be a valid middleware topic name, otherwise it should be a valid ROS topic name.
See also
rclcpp::Node::get_subscriptions_info_by_topic

Implements rclcpp::node_interfaces::NodeGraphInterface.

Definition at line 710 of file node_graph.cpp.

References rcl_get_subscriptions_info_by_topic().

Here is the call graph for this function:

◆ get_topic_names_and_types()

std::map< std::string, std::vector< std::string > > NodeGraph::get_topic_names_and_types ( bool  no_demangle = false) const
overridevirtual

Return a map of existing topic names to list of topic types.

A topic is considered to exist when at least one publisher or subscriber exists for it, whether they be local or remote to this process. The returned names are the actual names of the topics, either announced by another nodes or by this one. Attempting to create publishers or subscribers using names returned by this function may not result in the desired topic name being used depending on the remap rules in use.

Parameters
[in]no_demangleif true, topic names and types are not demangled

Implements rclcpp::node_interfaces::NodeGraphInterface.

Definition at line 58 of file node_graph.cpp.

References rclcpp::node_interfaces::NodeBaseInterface::get_rcl_node_handle(), rcl_get_default_allocator, rcl_get_topic_names_and_types(), rcl_get_zero_initialized_names_and_types, rcl_names_and_types_fini(), and RCL_RET_OK.

Here is the call graph for this function:

◆ notify_graph_change()

void NodeGraph::notify_graph_change ( )
overridevirtual

Notify threads waiting on graph changes.

Affects threads waiting on the notify guard condition, see: get_notify_guard_condition(), as well as the threads waiting on graph changes using a graph Event, see: wait_for_graph_change().

This is typically only used by the rclcpp::graph_listener::GraphListener.

Exceptions
RCLBaseError(a child of that exception) when an rcl error occurs

Implements rclcpp::node_interfaces::NodeGraphInterface.

Definition at line 508 of file node_graph.cpp.

References rclcpp::node_interfaces::NodeBaseInterface::get_notify_guard_condition(), and rclcpp::GuardCondition::trigger().

Here is the call graph for this function:

◆ wait_for_graph_change()

void NodeGraph::wait_for_graph_change ( rclcpp::Event::SharedPtr  event,
std::chrono::nanoseconds  timeout 
)
overridevirtual

Wait for a graph event to occur by waiting on an Event to become set.

The given Event must be acquire through the get_graph_event() method.

Exceptions
InvalidEventErrorif the given event is nullptr
EventNotRegisteredErrorif the given event was not acquired with get_graph_event().

Implements rclcpp::node_interfaces::NodeGraphInterface.

Definition at line 570 of file node_graph.cpp.

References rclcpp::node_interfaces::NodeBaseInterface::get_context(), and rclcpp::ok().

Here is the call graph for this function:

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