Function rcl_get_clients_info_by_service

Function Documentation

rcl_ret_t rcl_get_clients_info_by_service(const rcl_node_t *node, rcutils_allocator_t *allocator, const char *service_name, bool no_mangle, rcl_service_endpoint_info_array_t *clients_info)

Return a list of all clients to a service.

The node parameter must point to a valid node.

The service_name parameter must not be NULL.

When the no_mangle parameter is true, the provided service_name should be a valid name for the middleware (useful when combining ROS with native middleware apps). When the no_mangle parameter is false, the provided service_name should follow ROS service name conventions. In DDS-based RMWs, services are implemented as topics with mangled names (e.g., rq/my_serviceRequest and rp/my_serviceReply), so no_mangle = true is not supported and will result in an error. Use rcl_get_publishers_info_by_topic or rcl_get_subscriptions_info_by_topic for unmangled topic queries in such cases. Other RMWs (e.g., Zenoh) may support no_mangle = true if they natively handle services without topic-based mangling. In either case, the service name should always be fully qualified.

Each element in the clients_info array will contain the node name, node namespace, service type, endpoint_count, gids and the qos profiles of the client. It is the responsibility of the caller to ensure that clients_info parameter points to a valid struct of type rcl_service_endpoint_info_array_t. The count field inside the struct must be set to 0 and the info_array

field inside the struct must be set to null.

The

allocator will be used to allocate memory to the info_array member inside of clients_info. Moreover, every const char * member inside of rmw_service_endpoint_info_t will be assigned a copied value on allocated memory.

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

See also

rmw_get_zero_initialized_service_endpoint_info_array

See also

rmw_service_endpoint_info_set_node_name and the likes. However, it is the responsibility of the caller to reclaim any allocated resources to clients_info to avoid leaking memory.

See also

rmw_service_endpoint_info_array_fini

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

  • allocator[in] allocator to be used when allocating space for the array inside clients_info

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

  • no_mangle[in] if true, service_name needs to be a valid middleware service name, otherwise it should be a valid ROS service name

  • clients_info[out] a struct representing a list of client information

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_BAD_ALLOC if memory allocation fails, or

Returns:

RCL_RET_ERROR if an unspecified error occurs.