Why do we store the service file in example_interface in ROS2 ?
Like in ROS1, the service file needs to be stored in srv folder(not compulsary but convention). In ROS2 as well we store them in a srv folder which is located in the example_interfaces
folder. And then we always give it as a scope in the .cpp
file for e.g.
auto handle_add_two_ints =
[this](const std::shared_ptr<rmw_request_id_t> request_header,
const std::shared_ptr<example_interfaces::srv::AddTwoInts::Request> request,
std::shared_ptr<example_interfaces::srv::AddTwoInts::Response> response).
Here we use <example_interface::srv::AddTwoInts::Request> request
as a parameter. Why ?
Afaik there is no requirement to store your service definitions specifically in that package. You could use any package, just as in ROS1.
The examples just use that package because it is a package that stores the defs for the examples. So
example_interfaces
seems like an apt name.But if I try to rename it for instance
dummy_interface
and then change the name accordingly in the CMAKELISTS, then it gives an error `CMake Error at CMakeLists.txt:15 (find_package): No package configuration file found. How can i create that ?You'd have to create a new package called
dummy_interface
move the definition into the new package and add a dependency upon thedummy_interface
package to any packages that use the service.I already mentioned that i did that :)