在Ubuntu 16.04+ROS kinetic环境学习《Learning_ROS_for_Robotics_Programming_2nd_edition》的chapter 9 The Navigation Stack –Beyond Setups时候出现如下警告导致无法成功运行本章案例。
1 错误记录
(1)执行如下命令:
roslaunch chapter9_tutorials chapter9_configuration_gazebo.launch
roslaunch chapter9_tutorials move_base.launch
(2)错误信息
1)Warning
第一条:
[ WARN] [1480983367.577704599]: The root link base_footprint has an inertia specified in the URDF, but KDL does not support a root link with an inertia. As a workaround, you can add an extra dummy link to your URDF
【分析】:现象看是URDF问题,从URDF入手解决
第二条:
[ WARN] [1480981421.815460738, 6.221000000]: Timed out waiting for transform from base_footprint to map to become available before running costmap, tf error: . canTransform returned after 6.221 timeout was 0.1
【分析】:从现象看是tf问题,使用常见分析命令roswtf,rosrun tf tf_monitor,rosrun tf tf_eco src des等看看;
同时看看各个node的输入是否都正常获取,没有的话分析下是订阅主题名称不对,还是主题上根本就无消息出来。
2) Rviz界面左侧显示红色失败
2 解决措施
2.1 修改文件chapter7_tutorials/robot1_description/urdf/robot1_base_04.xacro
注释掉如下红色,解决上面第一条警告:
<link name="base_footprint">
<visual>
<geometry>
<box size="0.001 0.001 0.001"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 0"/>
</visual>
<!-- <xacro:default_inertial mass="0.0001"/> -->
</link>
修改如下红色用于解决第二条警告,以及rviz失败问题
<!-- Drive controller -->
<gazebo>
<plugin name="skid_steer_drive_controller" filename="libgazebo_ros_skid_steer_drive.so">
<updateRate>100.0</updateRate>
<robotNamespace>/</robotNamespace>
<leftFrontJoint>base_to_wheel1</leftFrontJoint>
<rightFrontJoint>base_to_wheel3</rightFrontJoint>
<leftRearJoint>base_to_wheel2</leftRearJoint>
<rightRearJoint>base_to_wheel4</rightRearJoint>
<wheelSeparation>4</wheelSeparation>
<wheelDiameter>0.1</wheelDiameter>
<robotBaseFrame>base_footprint</robotBaseFrame> //原来是base_link
<torque>1</torque>
<commandTopic>cmd_vel</commandTopic> //原来没有新添加
<odometryTopic>odom</odometryTopic> //原来没有新添加
<odometryFrame>odom</odometryFrame> //原来没有新添加
<broadcastTF>true</broadcastTF> //原来是0,意味着为false,很关键决定了TF发送
</plugin>
</gazebo>
2.2 修改文件chapter7_tutorials/robot1_description/urdf/robot.gazebo
修改如下红色用于解决第二条警告,以及rviz失败问题
<plugin name="gazebo_ros_head_hokuyo_controller" filename="libgazebo_ros_laser.so">
<topicName>/scan</topicName> 原来为/robot/laser/scan,虽然在chapter9_configuration_gazebo.launch中remap到/scan但是好像映射无效,所以其它相关订阅node无法使用
<frameName>hokuyo_link</frameName>
</plugin>
2.3 修改了文件chapter9_tutorials/launch/chapter9_configuration_gazebo.launch
注释掉如下红色并将其加入到了chapter9_tutorials/launch/move_base.launch,为了调整使一切ready后再启动rviz
<!-- <node name="rviz" pkg="rviz" type="rviz" args="-d $(find chapter9_tutorials)/launch/navigation.rviz"/> -->
2.4 修改了文件chapter9_tutorials/launch/move_base.launch
添加如下到启动文件末尾
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find chapter9_tutorials)/launch/navigation.rviz"/>
3 运行结果显示
3.1 Rviz显示界面
3.2 rqt_graph显示
从图中分析知道:
Node AMCL: input了robot_state_publisher的tf_static, gazebo仿真底座控制器的/tf(odom->base_footprint),gazebo的 laser sensor的/scan, /initialpose
output了/tf(map->odom),/particlecloud
Node move_base: input了map_server的/map, gazebo仿真底座控制器odom,gazebo仿真sensor的/scan, robot_state_publisher的tf_static,gazebo仿真底座控制器的tf,amcl的tf,move_base_simple的goal
output了:cmd_vel给gazebo仿真的底座控制器