launch文件加载urdf到rviz和gazebo中报错 Invalid <param> tag: Cannot load command parameter [robot_description]

        在学习赵虚左老师的ros入门教程urdf一章时,使用 launch文件加载urdf到rviz和gazebo中的时候(命令如下)

 roslaunch learning_gazebo demo2_car.launch 

意外出现报错:

RLException: Invalid  tag: Cannot load command parameter [robot_description]: command [['/opt/ros/noetic/lib/xacro/xacro', '/home/glc/simulation_ws/src/learning_gazebo/urdf/car_urdf.xacro']] returned with code [2]. 

Param xml is 
The traceback for the exception was written to the log file

这是我的launch文件,与老师的除了几个名称其他一样


    
    
    
    
    
    

它一直提示标签无效,我以为是拼写错误,但仔细检查了一遍后没找到问题,去网上查找也没找到解决办法。直到我看了别人的博客中的代码,发现ta的command属性第二个参数用“ ‘’ ”引了起来,然后我也引了起来,发现成功了。

修改后的launch文件


    
    
    
    
    
    

查了官方文档:

command="$(find pkg-name)/exe '$(find pkg-name)/arg.txt'"(optional)

The output of the command will be read and stored as a string. It is strongly recommended that you use the package-relative $(find)/file.txt syntax to specify file arguments. You should also quote file arguments using single quotes due to XML escaping requirements.

大概是说由于xml文件的转义要求,后面的参数需要用单引号括起来

但为什么老师的没用也能正常运行呢?望大佬解答疑惑。

你可能感兴趣的:(赵虚左ros入门教程踩坑,机器人)