Function rcl_count_services

Function Documentation

rcl_ret_t rcl_count_services(const rcl_node_t *node, const char *service_name, size_t *count)

Return the number of servers on a given service.

The node parameter must point to a valid node.

The service_name parameter must not be NULL, and must not be an empty string. It should also follow the service name rules.

See: https://design.ros2.org/articles/topic_and_service_names.html

The count parameter must point to a valid size_t. The count parameter is the output for this function and will be set.

In the event that error handling needs to allocate memory, this function will try to use the node’s allocator.

The service name is not automatically remapped by this function. If there is a server created with service name foo and remap rule foo:=bar then calling this with service_name set to bar will return a count of 1, and with service_name set to foo will return a count of 0. /sa rcl_remap_service_name()

Attribute

Adherence

Allocates Memory

Yes

Thread-Safe

No

Uses Atomics

No

Lock-Free

Maybe [1]

[1] implementation may need to protect the data structure with a lock

Parameters:
  • node[in] the handle to the node being used to query the ROS graph

  • service_name[in] the name of the service in question

  • count[out] number of services on the given service

Returns:

RCL_RET_OK if the query was successful, or

Returns:

RCL_RET_NODE_INVALID if the node is invalid, or

Returns:

RCL_RET_INVALID_ARGUMENT if any arguments are invalid, or

Returns:

RCL_RET_ERROR if an unspecified error occurs.