Class NodeGraphInterface

Inheritance Relationships

Derived Type

Class Documentation

class NodeGraphInterface

Pure virtual interface class for the NodeGraph part of the Node API.

Subclassed by rclcpp::node_interfaces::NodeGraph

Public Functions

virtual ~NodeGraphInterface() = default
virtual std::map<std::string, std::vector<std::string>> get_topic_names_and_types(bool no_demangle = false) const = 0

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:

no_demangle[in] if true, topic names and types are not demangled

virtual std::map<std::string, std::vector<std::string>> get_service_names_and_types() const = 0

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.

virtual 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 = 0

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:
  • node_name[in] name of the node

  • namespace_[in] namespace of the node

virtual 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 = 0

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:
  • node_name[in] name of the node

  • namespace_[in] namespace of the node

virtual 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 = 0

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:
  • node_name[in] name of the node

  • namespace_[in] namespace of the node

  • no_demangle[in] if true, topic names and types are not demangled

virtual 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 = 0

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:
  • node_name[in] name of the node

  • namespace_[in] namespace of the node

  • no_demangle[in] if true, topic names and types are not demangled

virtual std::vector<std::string> get_node_names() const = 0

Return a vector of existing node names (string).

virtual std::vector<std::tuple<std::string, std::string, std::string>> get_node_names_with_enclaves() const = 0

Return a vector of existing node names, namespaces and enclaves (tuple of string).

virtual std::vector<std::pair<std::string, std::string>> get_node_names_and_namespaces() const = 0

Return a vector of existing node names and namespaces (pair of string).

virtual size_t count_publishers(const std::string &topic_name) const = 0

Return the number of publishers that are advertised on a given topic.

virtual size_t count_subscribers(const std::string &topic_name) const = 0

Return the number of subscribers who have created a subscription for a given topic.

virtual size_t count_clients(const std::string &service_name) const = 0

Return the number of clients created for a given service.

virtual size_t count_services(const std::string &service_name) const = 0

Return the number of services created for a given service.

virtual const rcl_guard_condition_t *get_graph_guard_condition() const = 0

Return the rcl guard condition which is triggered when the ROS graph changes.

virtual void notify_graph_change() = 0

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.

Throws:

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

virtual void notify_shutdown() = 0

Notify any and all blocking node actions that shutdown has occurred.

virtual rclcpp::Event::SharedPtr get_graph_event() = 0

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.

virtual void wait_for_graph_change(rclcpp::Event::SharedPtr event, std::chrono::nanoseconds timeout) = 0

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.

Throws:
  • InvalidEventError – if the given event is nullptr

  • EventNotRegisteredError – if the given event was not acquired with get_graph_event().

virtual size_t count_graph_users() const = 0

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

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

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

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

Parameters:
  • topic_name[in] the actual topic name used; it will not be automatically remapped.

  • no_mangle[in] if true, topic_name needs to be a valid middleware topic name, otherwise it should be a valid ROS topic name.

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

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

Parameters:
  • topic_name[in] the actual topic name used; it will not be automatically remapped.

  • no_mangle[in] if true, topic_name needs to be a valid middleware topic name, otherwise it should be a valid ROS topic name.