ROS机器人高效编程(原书第3版)封面

第五章 导航功能包集入门 使用ROS创建地图出错:(特别注意第一条命令中的不是单引号,而是反引号)
$ roslaunch chapter5_tutorials gazebo_mapping_robot.launch model:="`rospack find robot1_description`/urdf/robot1_base_04.xacro"
$ rosrun teleop_twist_keyboard teleop_twist_keyboard.py
只有警告,并没有错误,但是rviz打不开:
[ 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
[ WARN] [1547737729.256634231, 0.001000000]: GazeboRosSkidSteerDrive Plugin (ns = //) missing <commandTopic>, defaults to "cmd_vel"
[ WARN] [1547737729.256738572, 0.001000000]: GazeboRosSkidSteerDrive Plugin (ns = //) missing <odometryTopic>, defaults to "odom"
[ WARN] [1547737729.256809889, 0.001000000]: GazeboRosSkidSteerDrive Plugin (ns = //) missing <odometryFrame>, defaults to "odom"
[ WARN] [1547737729.256899636, 0.001000000]: GazeboRosSkidSteerDrive Plugin (ns = //) missing <covariance_x>, defaults to 0.000100
[ WARN] [1547737729.257022841, 0.001000000]: GazeboRosSkidSteerDrive Plugin (ns = //) missing <covariance_y>, defaults to 0.000100
[ WARN] [1547737729.257077473, 0.001000000]: GazeboRosSkidSteerDrive Plugin (ns = //) missing <covariance_yaw>, defaults to 0.010000

解决办法:
修改文件:/home/caigen001/catkin_hm/src/chapter4_tutorials/robot1_description/urdf/robot1_base_04.xacro
文件的最后<gazebo>...</gazebo>模块
<!-- 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>
<!-- <commandTopic>cmd_vel</commandTopic> -->
<!-- <odometryTopic>odom</odometryTopic> -->
<robotBaseFrame>base_footprint</robotBaseFrame>
<!-- <odometryFrame>odom</odometryFrame> -->
<torque>1</torque>
<topicName>cmd_vel</topicName>
<broadcastTF>1</broadcastTF>
</plugin>
</gazebo>
对比一下原版:
1.修改前:
<robotBaseFrame>base_link</robotBaseFrame>
修改后:
<robotBaseFrame>base_footprint</robotBaseFrame>
2.修改前:
<broadcastTF>0</broadcastTF>
修改后:
<broadcastTF>1</broadcastTF>
大功告成!!!
输入命令:
$ roslaunch chapter5_tutorials gazebo_mapping_robot.launch model:="`rospack find robot1_description`/urdf/robot1_base_04.xacro"
$ rosrun teleop_twist_keyboard teleop_twist_keyboard.py
运行结果:


$ rqt_graph

结语:本实验还有一些不影响结果的警告,也可以修改相应的代码消除警告。
参考资料:
https://blog.youkuaiyun.com/x_r_su/article/details/53504784
本文详细介绍了在ROS环境中创建机器人地图并实现导航功能的过程。针对在使用gazebo_mapping_robot.launch文件创建地图时遇到的问题,如rviz无法打开及一系列警告信息,文章提供了具体的解决方案,包括修改robot1_base_04.xacro文件中的配置,调整robotBaseFrame和broadcastTF参数,最终成功解决了问题。
1621

被折叠的 条评论
为什么被折叠?



