[ROS2 Humble] Unable to compile custom srv which depends on msg
Problem: Custom srv file will not compile if using a fieldtype that is a msg from a package on ROS2 Humble. It seems the __struct C/C++ dependencies are not properly being detected by colcon. The same srv file / package was able to compile on ROS2 Foxy without any errors.
OS: Ubuntu 22.04 x86
The custom srv file (TurnCamera.srv)
float32 deg_turn
---
sensor_msgs/Image camera_image
The error received when running colcon build:
In file included from /home/ray/Workspaces/ros2_cpp_ws/build/udemy_ros2_pkg/rosidl_generator_c/udemy_ros2_pkg/srv/detail/turn_camera__functions.h:19,
from /home/ray/Workspaces/ros2_cpp_ws/build/udemy_ros2_pkg/rosidl_generator_c/udemy_ros2_pkg/srv/detail/turn_camera__functions.c:4:
/home/ray/Workspaces/ros2_cpp_ws/build/udemy_ros2_pkg/rosidl_generator_c/udemy_ros2_pkg/srv/detail/turn_camera__struct.h:41:10: fatal error: sensor_msgs/msg/detail/image__struct.h: No such file or directory
41 | #include "sensor_msgs/msg/detail/image__struct.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
gmake[2]: *** [CMakeFiles/udemy_ros2_pkg__rosidl_generator_c.dir/build.make:135: CMakeFiles/udemy_ros2_pkg__rosidl_generator_c.dir/rosidl_generator_c/udemy_ros2_pkg/srv/detail/turn_camera__functions.c.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:225: CMakeFiles/udemy_ros2_pkg__rosidl_generator_c.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
gmake: *** [Makefile:146: all] Error 2
I tried compilation from the Debian installation of Humble as well as Rolling built from source.
At first glance I assumed it was a sensor_msgs dependency issue within either my CMakeLists.txt file or package.xml file. But the compilation on ROS2 Foxy (on a separate Ubuntu 20 x86 machine) worked fine with the same config, so I am wondering if extra commands are needed within the CMakeLists.txt file for the Humble distro for compilation?
For reference, the following SRV can compile successfully if not using a package message type as a field type such as:
float32 deg_turn
---
int64 camera_image
But I receive the same type of error for any other package / msg combo, including that of std_msgs. The following config fails to compile with the same issue:
float32 deg_turn
---
std_msgs/Int64 camera_image
Which returns this error:
/home/ray/Workspaces/ros2_cpp_ws/build/udemy_ros2_pkg/rosidl_generator_c/udemy_ros2_pkg/srv/detail/turn_camera__struct.h:41:10: fatal error: std_msgs/msg/detail/int64__struct.h: No such file or directory
41 | #include "std_msgs/msg/detail/int64__struct.h"
/home/ray/Workspaces/ros2_cpp_ws/build/udemy_ros2_pkg/rosidl_generator_cpp/udemy_ros2_pkg/srv/detail/turn_camera__struct.hpp:134:10: fatal error: std_msgs/msg/detail/int64__struct.hpp: No such file or directory
134 | #include "std_msgs/msg/detail/int64__struct.hpp"
But compiles just fine on Foxy. So has the way which msgs from other packages are included in custom SRV files from Humble forward changed? I had removed all nodes from compiling for the purposes of these tests, just to try and test the compilation of the custom srv. Basically any msg you try to use results in the C (and sometimes the C++) struct not being built for that msg.
Here are my other package files for reference:
package.xml
<?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>udemy_ros2_pkg</name>
<version>0.0.0< ...