Struct ros2_client::Client
source · pub struct Client<S>{ /* private fields */ }
Expand description
Client end of a ROS2 Service
Implementations§
source§impl<S> Client<S>where
S: 'static + Service,
impl<S> Client<S>where
S: 'static + Service,
sourcepub fn send_request(&self, request: S::Request) -> WriteResult<RmwRequestId, ()>
pub fn send_request(&self, request: S::Request) -> WriteResult<RmwRequestId, ()>
Send a request to Service Server.
The returned RmwRequestId
is a token to identify the correct response.
sourcepub fn receive_response(
&self,
) -> ReadResult<Option<(RmwRequestId, S::Response)>>
pub fn receive_response( &self, ) -> ReadResult<Option<(RmwRequestId, S::Response)>>
Receive a response from Server
Returns Ok(None)
if no new responses have arrived.
Note: The response may to someone else’s request. Check received
RmWRequestId
against the one you got when sending request to identify
the correct response. In case you receive someone else’s response,
please do receive again.
sourcepub async fn async_send_request(
&self,
request: S::Request,
) -> WriteResult<RmwRequestId, ()>
pub async fn async_send_request( &self, request: S::Request, ) -> WriteResult<RmwRequestId, ()>
Send a request to Service Server asynchronously.
The returned RmwRequestId
is a token to identify the correct response.
sourcepub async fn async_receive_response(
&self,
request_id: RmwRequestId,
) -> ReadResult<S::Response>
pub async fn async_receive_response( &self, request_id: RmwRequestId, ) -> ReadResult<S::Response>
Receive a response from Server The returned Future does not complete until the response has been received.
pub async fn async_call_service( &self, request: S::Request, ) -> Result<S::Response, CallServiceError<()>>
sourcepub async fn wait_for_service(&self, my_node: &Node)
pub async fn wait_for_service(&self, my_node: &Node)
Wait for a Server to be connected to the Request and Response topics.
This does not distinguish between diagnostinc tools and actual servers. It is enough that someone has subscribed the Requests, and someone is a publisher for Responses.
May panic, if the Node does not havea background Spinner running.