Server
bool add(); == This function provides the service for adding two ints, it takes in the request and response type defined in the srv file and returns a boolean.
res.sum = req.a + req.b; == two ints are added and stored in the response.
Client
srv.request.a = atoll(argv[1]); == we instantiate an autogernerated service calss, and assign values into its request members.
if (client.call (srv)) == This actually calls the service. Since service call are blocking it will return once the call is done. If the service call succeeded, call() will return true an d the value in srv.response will be valid. if the call didn't succeed , call() will return false and the value in srv.response will be invalid.
'자율주행 > ROS tutorial C++' 카테고리의 다른 글
Interactive Markers: Getting Started (0) | 2021.02.07 |
---|---|
Markers:Points and Lines (0) | 2021.02.07 |
Markers: Basic shapes (0) | 2021.01.10 |
Writing a Simple Publisher and Subscriber (0) | 2020.12.30 |