Is there a way to publish service::request/response

asked 2021-07-09 08:57:29 -0500

Hyunbin Park gravatar image

I have generated An example.srv file and got ExampleRequest.h and ExampleResponse.h in the devel/include folder.
I tried to publish based on the files, for instance

example::ExampleRequest ex_req;
ex_req.content1 = 1;
ex_req.content2 = 2;
ros::Publisher pub = n.advertise<example::ExampleRequest>("/service_request", 1);

I was able to see the topic in the terminal like rostopic echo /service_request.
However, I got this error

ERROR: Cannot load message class for [example/ExampleRequest]. Are your messages built?

Sourcing was done before echoing. How could the service messages generated by srv files be published?

edit retag flag offensive close merge delete