How is the service.hpp file generated from service.srv file in ROS2 ?
While using services in ROS2, we include example_interfaces/srv/add_two_ints.hpp
in the server.cpp and client.cpp files. How is this file generated.
In my case, i created a new service file heatFlow.srv
and changed the CMakeLists.txt file and the cpp files accordingly. But when i try to build the package, it gives a fatal error : fatal error: example_interfaces/srv/heatFlow.hpp: No such file or directory
compilation terminated.
How are these .hpp
files basically generated ?
EDIT :
I created a new folder "example_interface" (note: without S in the end) and created a new service file called heatFlow.srv
. Now the CMakeLists is as follows :
cmake_minimum_required(VERSION 3.5) project(example_interface) # Default to C++14 if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 14) endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") # we dont use add_compile_options with pedantic in message packages # because the Python C extensions dont comply with it set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic") endif() find_package(ament_cmake REQUIRED) find_package(rosidl_default_generators REQUIRED) rosidl_generate_interfaces(${PROJECT_NAME} "srv/heatFlow.srv" ) ament_export_dependencies(rosidl_default_runtime) install(FILES mapping_rules.yaml DESTINATION share/${PROJECT_NAME}) ament_package()
and the package.xml as follows:
> <?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org /2001/XMLSchema"?>
<package format="3">
<name>example_interface</name>
<version>0.4.0</version>
<description>Contains message and service definitions used by the examples.</description>
<maintainer email="dthomas@osrfoundation.org">Dirk Thomas</maintainer>
<license>Apache License 2.0</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>rosidl_default_generators</buildtool_depend>
<exec_depend>rosidl_default_runtime</exec_depend>
<member_of_group>rosidl_interface_packages</member_of_group>
<export>
<build_type>ament_cmake</build_type>
<ros1_bridge mapping_rules="mapping_rules.yaml"/>
</export>
</package>
When I compile it using : ament build --symlink-install --only-package heatflow_cpp
, it gives an error `CMake Error at CMakeLists.txt:15 (find_package):
By not providing "Findexample_interface.cmake" in CMAKE_MODULE_PATH this
project has asked CMake to find a package configuration file provided by
"example_interface", but CMake did not find one.
Could not find a package configuration file provided by "example_interface" with any of the following names:
example_interfaceConfig.cmake
example_interface-config.cmake
Add the installation prefix of "example_interface" to CMAKE_PREFIX_PATH or set "example_interface_DIR" to a directory containing one of the above files. If "example_interface" provides a separate development package or SDK, be sure it has been installed.`