紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
4.2.1章节构建消息功能包错误string index out of range
-
sensor_msgs/Image image --- int16 number # 人脸个数 float32 use_time # 识别耗时 int32[] top # 人脸在图像中的位置 int32[] right int32[] bottom int32[] left
cmakelists.txt
cmake_minimum_required(VERSION 3.8) project(chapt4_interfaces) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic) endif() # find dependencies find_package(ament_cmake REQUIRED) find_package(rosidl_default_generators REQUIRED) find_package(sensor_msgs REQUIRED) rosidl_generate_interfaces(${PROJECT_NAME} "srv/FaceDetector.srv" DEPENDENCIES sensor_msgs ) if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) # the following line skips the linter which checks for copyrights # comment the line when a copyright and license is added to all source files set(ament_cmake_copyright_FOUND TRUE) # the following line skips cpplint (only works in a git repo) # comment the line when this package is in a git repo and when # a copyright and license is added to all source files set(ament_cmake_cpplint_FOUND TRUE) ament_lint_auto_find_test_dependencies() endif() ament_package()
构建错误
CMake Error at /opt/ros/humble/share/rosidl_adapter/cmake/rosidl_adapt_interfaces.cmake:59 (message): execute_process(/usr/bin/python3 -m rosidl_adapter --package-name chapt4_interfaces --arguments-file /home/tingbo/chapt4/chapt4_ws/src/build/chapt4_interfaces/rosidl_adapter__arguments__chapt4_interfaces.json --output-dir /home/tingbo/chapt4/chapt4_ws/src/build/chapt4_interfaces/rosidl_adapter/chapt4_interfaces --output-file /home/tingbo/chapt4/chapt4_ws/src/build/chapt4_interfaces/rosidl_adapter/chapt4_interfaces.idls) returned error code 1: Error processing ' sensor_msgs/Image image' of 'chapt4_interfaces/FaceDetector_Request': 'string index out of range' Traceback (most recent call last): File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/opt/ros/humble/local/lib/python3.10/dist-packages/rosidl_adapter/__main__.py", line 19, in <module> sys.exit(main()) File "/opt/ros/humble/local/lib/python3.10/dist-packages/rosidl_adapter/main.py", line 53, in main abs_idl_file = convert_to_idl( File "/opt/ros/humble/local/lib/python3.10/dist-packages/rosidl_adapter/__init__.py", line 24, in convert_to_idl return convert_srv_to_idl( File "/opt/ros/humble/local/lib/python3.10/dist-packages/rosidl_adapter/srv/__init__.py", line 28, in convert_srv_to_idl srv = parse_service_string(package_name, input_file.stem, content) File "/opt/ros/humble/local/lib/python3.10/dist-packages/rosidl_adapter/parser.py", line 859, in parse_service_string request_message = parse_message_string( File "/opt/ros/humble/local/lib/python3.10/dist-packages/rosidl_adapter/parser.py", line 520, in parse_message_string Type(type_string, context_package_name=pkg_name), File "/opt/ros/humble/local/lib/python3.10/dist-packages/rosidl_adapter/parser.py", line 241, in __init__ self.is_array = type_string[-1] == ']' IndexError: string index out of range Call Stack (most recent call first): /opt/ros/humble/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:130 (rosidl_adapt_interfaces) CMakeLists.txt:13 (rosidl_generate_interfaces)
-
-
@43996173 在 4.2.1章节构建消息功能包错误string index out of range 中说:
' sensor_msgs/Image image'
前面多了个空格,书籍是代码格式有部分出现缩进错误,我给你的不是终审稿子,还没修复
-
@小鱼 好了谢谢