-
Notifications
You must be signed in to change notification settings - Fork 149
Description
Generated by Generative AI
No response
Operating System:
Linux huan-ROG-Zephyrus-G16-GU605MI-GU605MI 6.8.0-94-generic #96-Ubuntu SMP PREEMPT_DYNAMIC Fri Jan 9 20:36:55 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
ROS version or commit hash:
jazzy
RMW implementation (if applicable):
rmw_fastrtps_cpp
RMW Configuration (if applicable):
No response
Client library (if applicable):
No response
'ros2 doctor --report' output
platform info : Linux-6.8.0-94-generic-x86_64-with-glibc2.39
release : 6.8.0-94-generic
processor : x86_64
RMW MIDDLEWARE
middleware name : rmw_fastrtps_cpp
ROS 2 INFORMATION
distribution name : jazzy
distribution type : ros2
distribution status : active
release platforms : {'ubuntu': ['noble']}
PACKAGE VERSIONS
ros-jazzy-rosidl-cmake : 4.6.7-1noble.20260121.190524
Steps to reproduce issue
- using sub folders like "srv/my_category/Foo.srv"
Expected behavior
service_msgs dependencies would be added to build section
Actual behavior
could lead to service_msgs dependencies not added
Additional information
Steps to reproduce issue:
1. Create a minimal interfaces package with srv files in subdirectories
mkdir -p my_interfaces/srv/my_category
cat > my_interfaces/srv/my_category/MyService.srv << 'EOF'
string input
string output
EOF
cat > my_interfaces/CMakeLists.txt << 'EOF'
cmake_minimum_required(VERSION 3.22)
project(my_interfaces)
find_package(ament_cmake REQUIRED)
find_package(rosidl_default_generators REQUIRED)
rosidl_generate_interfaces(${PROJECT_NAME}
"srv/my_category/MyService.srv"
)
ament_package()
EOF
cat > my_interfaces/package.xml << 'EOF'
my_interfaces 0.0.1 Test package Test Apache-2.0 ament_cmake rosidl_default_generators rosidl_interface_packages EOF2. Build - this will FAIL
colcon build --packages-select my_interfaces
Expected behavior:
Build succeeds. The service_msgs dependency should be automatically detected and added for .srv files regardless of directory structure, just like it works for srv/MyService.srv.
Actual behavior:
Build fails with:
KeyError: 'service_msgs'
Additional information:
Root cause is in rosidl_generate_interfaces.cmake lines 148-184. The code detects service files by checking if the parent directory name equals srv:
get_filename_component(_parent_dir "${_tuple_file}" DIRECTORY)
get_filename_component(_parent_dir ${_parent_dir} NAME)
...
elseif("${_parent_dir}" STREQUAL "srv")
- srv/MyService.srv → parent dir = srv ✅ works
- srv/my_category/MyService.srv → parent dir = my_category ❌ fails
Workaround: Manually add service_msgs dependency:
find_package(service_msgs REQUIRED)
rosidl_generate_interfaces(${PROJECT_NAME}
"srv/my_category/MyService.srv"
DEPENDENCIES service_msgs
)
Suggested fix: Check file extension instead of parent directory name, or check if path contains /srv/ or starts with srv/.