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

ROS 2 Humble运行.launch文件报错:Entity node未找到exec属性

解决ROS 2 Humble中XML Launch文件执行错误的问题

错误原因分析

你遇到的Attribute exec of type <class 'str'> not found in Entity node错误,核心是ROS 2的XML Launch语法与ROS 1存在差异,你的launch文件沿用了ROS 1的写法,导致解析失败。具体问题点:

  1. <param>标签的textfile属性是ROS 1专属用法,ROS 2不支持该属性
  2. ROS 2中已用$(find-pkg-share)替代ROS 1的$(find)命令
  3. spawn_entity.py的参数逻辑错误:$(arg)用于读取launch的输入参数,而非参数服务器中的值;且从参数服务器加载URDF需用-param参数,而非指定文件路径的-file

修正后的Launch文件

<!-- Load the URDF model into parameter server -->
<param name="robot_description" 
       value="$(command cat $(find-pkg-share mower_sim)/urdf/mower.urdf)"/>

<!-- Spawn the URDF model in Gazebo -->
<node name="spawn_urdf" pkg="gazebo_ros" executable="spawn_entity.py" output="screen"
    args="-entity mower -param robot_description -x 0 -y 0 -z 0"/>

<!-- Start your BCD node -->
<node name="bcd_node" pkg="mower_sim" executable="bcd_node" output="screen"/>

额外检查项

  • 确认mower_sim包已正确编译安装:执行colcon build --packages-select mower_sim后,source安装目录下的setup.bash
  • 检查bcd_node的可执行配置:如果是Python节点,确保setup.py中正确配置了entry_points;若为直接运行的脚本,可尝试executable="bcd_node.py"(需确保脚本在包的scripts目录下,且setup.py已声明)
  • 验证URDF路径有效性:执行$(find-pkg-share mower_sim)/urdf/mower.urdf命令,确认路径存在且文件可读

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.25 13:27:45