Function rcl_get_clients_info_by_service
Defined in File graph.h
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
nodeparameter must point to a valid node.The
service_nameparameter must not beNULL.When the
no_mangleparameter istrue, the providedservice_nameshould be a valid name for the middleware (useful when combining ROS with native middleware apps). When theno_mangleparameter isfalse, the providedservice_nameshould follow ROS service name conventions. In DDS-based RMWs, services are implemented as topics with mangled names (e.g.,rq/my_serviceRequestandrp/my_serviceReply), sono_mangle = trueis not supported and will result in an error. Usercl_get_publishers_info_by_topicorrcl_get_subscriptions_info_by_topicfor unmangled topic queries in such cases. Other RMWs (e.g., Zenoh) may supportno_mangle = trueif they natively handle services without topic-based mangling. In either case, the service name should always be fully qualified.Each element in the
clients_infoarray 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 thatclients_infoparameter points to a valid struct of type rcl_service_endpoint_info_array_t. Thecountfield inside the struct must be set to 0 and theinfo_arrayfield inside the struct must be set to null.
The
allocatorwill be used to allocate memory to theinfo_arraymember inside ofclients_info. Moreover, every const char * member inside of rmw_service_endpoint_info_t will be assigned a copied value on allocated memory.
[1] implementation may need to protect the data structure with a lockAttribute
Adherence
Allocates Memory
Yes
Thread-Safe
No
Uses Atomics
No
Lock-Free
Maybe [1]
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_infoto 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_nameneeds to be a valid middleware service name, otherwise it should be a valid ROS service nameclients_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.