ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Can not build ROS2 service with sensor_msgs

asked 2020-09-07 04:35:32 -0500

macieksz gravatar image

updated 2020-09-07 04:37:40 -0500

I defined my interface to include sensor_msgs as following:

sensor_msgs/Image rgb

int64[] classes

but got that error fatal error: sensor_msgs/msg/detail/image__struct.hpp: No such file or directory 19 | #include "sensor_msgs/msg/detail/image__struct.hpp"

edit retag flag offensive close merge delete

Comments

I had a similar error and my guess is that your CMakeLists.txt file or package.xml file is incorrect, but it's hard to tell without more information.

siliconlad gravatar image siliconlad  ( 2020-09-07 20:25:08 -0500 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2020-09-07 21:22:48 -0500

dhood gravatar image

You may need to declare a build dependency on sensor_msgs, so that CMake will locate the headers from the sensor_msgs package when building yours.

Check the package.xml of the package you're trying to build and add the following if it's not already there:

<depend>sensor_msgs</depend>

You can copy the example_interfaces package as an example.

If that is not your issue, please update your original question to show the package.xml you are using and we can take a look at that!

edit flag offensive delete link more

Comments

1

I added DEPENDENCIES sensor_msgs rosidl_generate_interfaces(${PROJECT_NAME} ${srv_files} DEPENDENCIES sensor_msgs ) and cleaned the workspace with the same package xml and now it works. It looks like it is recommened to clean the workspace before new compilation

macieksz gravatar image macieksz  ( 2020-09-08 01:48:36 -0500 )edit
0

answered 2020-09-08 05:11:48 -0500

macieksz gravatar image

updated 2020-09-08 05:14:12 -0500

Here is my CMakeLists.txt and package.xml

cmake_minimum_required(VERSION 3.5) project(detectron_interface)

if(NOT CMAKE_C_STANDARD) set(CMAKE_C_STANDARD 99) endif()

if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 14) endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic) endif()

find_package(ament_cmake REQUIRED)

find_package(sensor_msgs REQUIRED) find_package(rosidl_default_generators REQUIRED) set(srv_files "srv/Detectron.srv" ) rosidl_generate_interfaces(${PROJECT_NAME} ${srv_files} DEPENDENCIES sensor_msgs ) ament_export_dependencies(rosidl_default_runtime) ament_package()

` <package format="3"> <name>detectron_interface</name> <version>0.0.0</version> <description>TODO: Package description</description> <maintainer <a="" href="mailto:email="macziek@aol.com"&gt;ros&lt;/maintainer">email="macziek@aol.com">ros> <license>TODO: License declaration</license></maintainer></package>

<buildtool_depend>ament_cmake</buildtool_depend>

<build_depend>sensor_msgs</build_depend> <build_depend>rosidl_default_generators</build_depend>

<exec_depend>rosidl_default_runtime</exec_depend>

<member_of_group>rosidl_interface_packages</member_of_group>

<test_depend>ament_lint_auto</test_depend> <test_depend>ament_lint_common</test_depend>

<export> <build_type>ament_cmake</build_type> </export> </package>`

The problem still persists! Can you guide me on that

edit flag offensive delete link more

Comments

try replacing

 <build_depend>rosidl_default_generators</build_depend>

with

<buildtool_depend>rosidl_default_generators</buildtool_depend>

you may also need to add

<exec_depend>sensor_msgs</exec_depend>
siliconlad gravatar image siliconlad  ( 2020-09-08 05:33:14 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2020-09-07 04:35:32 -0500

Seen: 2,654 times

Last updated: Sep 08 '20