Is there a way to publish service::request/response
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);
...
pub.publish(ex_req);
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?