You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行catkin_make与rosdep install时遇ROS相关错误求助

ROS Melodic编译与依赖安装错误解决

一、catkin_make时出现AttributeError错误

错误信息:

Traceback (most recent call last):
  File "/opt/ros/melodic/share/gencpp/cmake/../../../lib/gencpp/gen_cpp.py", line 50, in <module>
    sys.argv, msg_template_map, srv_template_map)
  File "/opt/ros/melodic/lib/python2.7/dist-packages/genmsg/template_tools.py", line 213, in generate_from_command_line_options
    generate_from_file(argv[1], options.package, options.outdir, options.emdir, options.includepath, msg_template_dict, srv_template_dict)
  File "/opt/ros/melodic/lib/python2.7/dist-packages/genmsg/template_tools.py", line 154, in generate_from_file
    _generate_msg_from_file(input_file, output_dir, template_dir, search_path, package_name, msg_template_dict)
  File "/opt/ros/melodic/lib/python2.7/dist-packages/genmsg/template_tools.py", line 99, in _generate_msg_from_file
    search_path)
  File "/opt/ros/melodic/lib/python2.7/dist-packages/genmsg/template_tools.py", line 77, in _generate_from_spec
    interpreter = em.Interpreter(output=ofile, globals=g, options={em.RAW_OPT:True,em.BUFFERED_OPT:True})
AttributeError: 'module' object has no attribute 'RAW_OPT'
...
CMakeFiles/Makefile2:3016: recipe for target 'autorally/autorally_msgs/CMakeFiles/autorally_msgs_generate_messages_cpp.dir/all' failed
make[1]: *** [autorally/autorally_msgs/CMakeFiles/autorally_msgs_generate_messages_cpp.dir/all] Error 2

解决方法:

该错误源于empy模块版本不兼容,ROS Melodic需要特定版本的empy支持代码生成模板:

  • 卸载当前版本的empy:
    pip uninstall empy
    
  • 安装兼容的旧版本(适配Python2环境):
    pip install empy==3.3.4
    
  • 清理编译缓存后重新编译:
    catkin clean
    catkin_make
    

二、rosdep install时无法解析effort_controllers依赖

错误信息:

ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
autorally_gazebo: Cannot locate rosdep definition for [effort_controllers]

解决方法:

effort_controllers属于ros_controllers功能包集,可通过以下步骤解决:

  • 更新rosdep数据库:
    rosdep update
    
  • 若更新后仍无法解析,手动安装对应ROS包:
    sudo apt-get install ros-melodic-effort-controllers
    
  • 重新执行rosdep安装命令:
    rosdep install --from-paths src --ignore-src -r -y
    

内容的提问来源于stack exchange,提问作者Tanmay Desai

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.04 08:00:30