Receive Service Request
Libraries:
ROS Toolbox /
ROS 2
Description
Use the Receive Service Request and Send Service Response blocks in the same model to implement a ROS 2 service server in Simulink®. The Receive Service Request block enables you to receive a ROS 2 service request message from a service client, process it in the model to construct an appropriate response, and then send the response to the client using a Send Service Response block. The service server is associated with the ROS 2 node of the Simulink model.
Depending on the parameter, the block can either check for new requests at each simulation step, outputting the request if available or repeating the last request if none arrives, or process requests immediately upon arrival, triggering an event signal to execute a Function-Call Subsystem asynchronously.
Depending on the Process Service Request parameter setting, the block either check for new requests at each simulation step or processes them immediately upon arrival. In the latter case, it triggers an event to handle the request asynchronously. This asynchronous mode is supported only for code generation.
Specify the name for your ROS 2 service, the service type, and the quality of service (QoS) parameters in the block mask. QoS parameters for this block must be compatible with the service clients to receive requests and send responses.
Note
For each Receive Service Request you add to a model, you must click Paired Send Response Block in the block mask to create a paired Send Service Response block. Adding a Send Service Response block from the library is not recommended.

