? ? ? ? 在學習趙虛左老師的ros入門教程urdf一章時,使用?launch文件加載urdf到rviz和gazebo中的時候(命令如下)
roslaunch learning_gazebo demo2_car.launch
意外出現(xiàn)報錯:
RLException: Invalid <param> 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 <param name="robot_description" command="$(find xacro)/xacro $(find learning_gazebo)/urdf/car_urdf.xacro"/>
The traceback for the exception was written to the log file
這是我的launch文件,與老師的除了幾個名稱其他一樣
<launch>
<!-- 在參數(shù)服務器中加載urdf -->
<param name="robot_description" command="$(find xacro)/xacro $(find learning_gazebo)/urdf/car_urdf.xacro" />
<!-- 啟動gazebo 其已經(jīng)有內(nèi)置launch文件啟動gazebo-->
<include file="$(find gazebo_ros)/launch/empty_world.launch" />
<!-- 在gazebo中添加機器人模型 -->
<node pkg="gazebo_ros" type="spawn_model" name="spawn_model" args="-urdf -model car -param robot_description" />
</launch>
它一直提示標簽無效,我以為是拼寫錯誤,但仔細檢查了一遍后沒找到問題,去網(wǎng)上查找也沒找到解決辦法。直到我看了別人的博客中的代碼,發(fā)現(xiàn)ta的command屬性第二個參數(shù)用“ ‘’ ”引了起來,然后我也引了起來,發(fā)現(xiàn)成功了。
修改后的launch文件
<launch>
<!-- 在參數(shù)服務器中加載urdf -->
<param name="robot_description" command="$(find xacro)/xacro '$(find learning_gazebo)/urdf/car_urdf.xacro'" />
<!-- 啟動gazebo 其已經(jīng)有內(nèi)置launch文件啟動gazebo-->
<include file="$(find gazebo_ros)/launch/empty_world.launch" />
<!-- 在gazebo中添加機器人模型 -->
<node pkg="gazebo_ros" type="spawn_model" name="spawn_model" args="-urdf -model car -param robot_description" />
</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文件的轉(zhuǎn)義要求,后面的參數(shù)需要用單引號括起來文章來源:http://www.zghlxwxcb.cn/news/detail-621298.html
但為什么老師的沒用也能正常運行呢?望大佬解答疑惑。文章來源地址http://www.zghlxwxcb.cn/news/detail-621298.html
到了這里,關(guān)于launch文件加載urdf到rviz和gazebo中報錯 Invalid <param> tag: Cannot load command parameter [robot_description]的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!