本人Ubuntu版本:20.04
在运行基于gazebo的仿真的时候出现了这样的报错:
跟着报错去检查对应的xml文件时发现没有问题,然后参考
Problem with xacro invalid <param> - ROS Answers: Open Source Q&A Forum 时发现了我要的答案,网页截图如下:
简言之问题在于launch文件中涉及的版本问题,本人的launch文件代码具体如下:
<?xml version="1.0"?>
<launch>
<!-- these are the arguments you can pass this launch file, for example paused:=true -->
<arg name="paused" default="true"/>
<arg name="use_sim_time" default="false"/>
<arg name="gui" default="true"/>
<arg name="headless" default="false"/>
<arg name="debug" default="true"/>
<!-- We resume the logic in empty_world.launch, changing only the name of the world to be launched -->
<include file="$(find gazebo_ros)/launch/empty_world.launch">
<arg name="world_name" value="$(find gazebotest)/worlds/robot.world"/>
<arg name="debug" value="$(arg debug)" />
<arg name="gui" value="$(arg gui)" />
<arg name="paused" value="$(arg paused)"/>
<arg name="use_sim_time" value="$(arg use_sim_time)"/>
<arg name="headless" value="$(arg headless)"/>
</include>
<!-- Load the URDF into the ROS Parameter Server -->
<arg name="model" />
<param name="robot_description"
command="$(find xacro)/xacro.py $(arg model)" />
<!-- Run a python script to the send a service call to gazebo_ros to spawn a URDF robot -->
<node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
args="-urdf -model robot1 -param robot_description -z 0.05"/>
</launch>
具体代码段
<param name="robot_description"
command="$(find xacro)/xacro.py $(arg model)" />
中的xacro.py应该修改为xacro,因为在20.04 noetic对应的ROS中识别的是xacro
修改后如下
<param name="robot_description"
command="$(find xacro)/xacro $(arg model)" />
再编译,配置环境,运行后,成功得到预期效果
所以事实上很多问题都是版本的锅,版本之间差距太大真的难受,一路上从跟着教程到做实例依样画葫芦都是坐牢过来的 ((((