问题描述-1
在gazebo下仿真cartographer建图算法的时候,出现以下TF变换异常报错:
[ERROR] [1584194344.911065094]: Ignoring transform for child_frame_id “left_wheel_link” from authority “unknown_publisher”
分析之后可以发现该问题主要是由于robot_state_publisher和gazebo中都发布了关于轮子的坐标变换,导致cartograoppher工作异常。
解决办法-1
将机器人的gazebo插件配置改为以下内容:
<gazebo>
<plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so">
<rosDebugLevel>Debug</rosDebugLevel>
<publishWheelTF>false</publishWheelTF> <!-- 此处将gazebo的发布关闭 -->
<robotNamespace>/</robotNamespace>
<publishTf>1</publishTf>
<publishWheelJointState>true</publishWheelJointState>
<alwaysOn>true</alwaysOn>
<updateRate>100.0</updateRate>
<legacyMode>true</legacyMode>
<leftJoint>left_wheel2base_link</leftJoint>
<rightJoint>right_wheel2base_link</rightJoint>
<wheelSeparation>${base_link_radius * 2}</wheelSeparation>
<wheelDiameter>${wheel_radius * 2}</wheelDiameter>
<broadcastTF>1</broadcastTF>
<wheelTorque>30</wheelTorque>
<wheelAcceleration>1.8</wheelAcceleration>
<commandTopic>cmd_vel</commandTopic>
<odometryFrame>odom</odometryFrame>
<odometryTopic>odom</odometryTopic>
<odometrySource>world</odometrySource>
<publishOdomTF>true</publishOdomTF>
<robotBaseFrame>base_footprint</robotBaseFrame>
</plugin>
</gazebo>
问题描述-2
在noetic 的ros版本, 如果使用gazebo工具进行cartographer机器人建图仿真, 可能会出现机器人未发布odom话题, 也无法接收cmd_vel的话题, 但是从启动时的加载log来看, 又可以知道libgazebo_ros_diff_drive.so
插件加载正常。
而有时候,还会出现机器人的颜色不对,或者模型丢失。
解决办法-2
这时候很有可能是机器人的惯性矩阵没有正确配置,也很有可能是xacro文件没有正确编写, 而这其中很大一部分可能是因为使用xacro中宏定义函数, 在调用该函数的时候, 务必在使用前加上 xacro:
, 才能保证gazebo加载正常, 举例如下:
<xacro:macro name="foo" params="x">
<in_foo the_x="${x}" />
</xacro:macro>
<xacro:macro name="foo" params="x:=0"/>