colcon编译报错
-
lyt@lyt-virtual-machine:~/test$ colcon build
Starting >>> custom_interfaces
--- stderr: custom_interfaces
CMake Error at /opt/ros/foxy[表情]/rosidl_adapter/cmake/rosidl_adapt_interfaces.cmake:60 (message):
execute_process(/usr/bin/python3 -m rosidl_adapter --package-name
custom_interfaces --arguments-file
/home/lyt/test[表情]ild/custom_interfaces/rosidl_adapter__arguments__custom_interfaces.json
--output-dir
/home/lyt/test[表情]ild/custom_interfaces/rosidl_adapter/custom_interfaces
--output-file
/home/lyt/test[表情]ild/custom_interfaces/rosidl_adapter/custom_interfaces.idls)
returned error code 1:Error processing 'custom_interfaces/Shelf[] shelfs_list //货架列表' of
'custom_interfaces/Layout': 'parsing string values into type
'custom_interfaces/Shelf[]' is not supported'Traceback (most recent call last):
File "/usrb/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/usrb/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/opt/ros/foxyb/python3.8/site-packages/rosidl_adapter/__main__.py", line 19, in <module> sys.exit(main()) File "/opt/ros/foxyb/python3.8/site-packages/rosidl_adapter/main.py", line 53, in main abs_idl_file = convert_to_idl( File "/opt/ros/foxyb/python3.8/site-packages/rosidl_adapter/__init__.py", line 19, in convert_to_idl return convert_msg_to_idl( File "/opt/ros/foxyb/python3.8/site-packages/rosidl_adapter/msg/__init__.py", line 28, in convert_msg_to_idl msg = parse_message_string(package_name, input_file.stem, content) File "/opt/ros/foxyb/python3.8/site-packages/rosidl_adapter/parser.py", line 515, in parse_message_string fields.append(Field( File "/opt/ros/foxyb/python3.8/site-packages/rosidl_adapter/parser.py", line 360, in __init__ self.default_value = parse_value_string( File "/opt/ros/foxyb/python3.8/site-packages/rosidl_adapter/parser.py", line 631, in parse_value_string raise NotImplementedError(
NotImplementedError: parsing string values into type
'custom_interfaces/Shelf[]' is not supportedCall Stack (most recent call first):
/opt/ros/foxy[表情]/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:130 (rosidl_adapt_interfaces)
CMakeLists.txt:23 (rosidl_generate_interfaces)
Failed <<< custom_interfaces [2.01s, exited with code 1]
Summary: 0 packages finished [2.87s]
1 package failed: custom_interfaces
1 package had stderr output: custom_interfaces
1 package not processed -
从你提供的错误信息来看,问题出现在
custom_interfaces
包中,特别是在处理消息类型定义时遇到了问题。错误指出rosidl_adapter
无法解析类型为custom_interfaces/Shelf[]
的数组字段,具体是在解析custom_interfaces/Layout
消息中的shelfs_list
字段时发生的。这里的错误
NotImplementedError: parsing string values into type 'custom_interfaces/Shelf[]' is not supported
表明rosidl_adapter
尚不支持将字符串直接解析为复杂类型(如自定义消息类型的数组)。这通常意味着在消息定义文件中可能错误地尝试将一个字符串直接声明为Shelf[]
类型,或者在处理该类型时存在某种语法或逻辑错误。解决步骤
-
检查消息定义文件:
- 打开
custom_interfaces
包中的消息定义文件(通常是.msg
文件)。 - 查找
Layout
消息定义,特别是shelfs_list
字段。 - 确保
shelfs_list
字段的类型声明正确。如果Shelf
是另一个消息类型,确保shelfs_list
被正确声明为Shelf[]
而不是一个字符串或其他不兼容类型。
- 打开
-
检查是否有语法错误:
- 确保所有的消息字段都正确声明,没有遗漏的分号、括号或其他语法错误。
-
重新生成消息接口:
- 修改完消息定义后,确保重新运行
colcon build
以重新生成接口。
- 修改完消息定义后,确保重新运行
-
查看
rosidl_adapter
的限制:- 如果问题依旧存在,可能需要检查
rosidl_adapter
的文档或源代码,了解是否有关于复杂类型数组处理的特定限制或要求。
- 如果问题依旧存在,可能需要检查
-
寻求帮助:
- 如果以上步骤无法解决问题,可以考虑在 ROS 社区论坛或相关 GitHub 仓库中寻求帮助。
注意事项
- 确保所有路径和文件名都没有包含特殊字符或表情符号,这些可能导致解析错误。从错误信息来看,路径中似乎包含了一些异常字符(如
[表情]
),这可能是复制错误或路径中的实际字符问题。 - 仔细检查环境设置,确保 ROS 安装和依赖关系正确无误。
希望这些信息能帮助你解决问题!
以上为生成回答,仅供参考~
-