ubuntu14.04,ros版本为indigo。
用roslaunch turtlebot_gazebo turtlebot_world.launch打开gazebo,然后rostopic list可以看到gps的话 题:sensor_msgs/NavSatFix
turtlebot2的仿真环境的学习参考:http://learn.turtlebot.com/的仿真部分。
想用GPS做导航,gazebo中没有GPS模块,需要自己添加插件。
第一步:下载插件
http://wiki.ros.org/hector_gazebo下载对应版本的插件。
第二步:编译
将下载下来的文件放入到ros的工作目录里面,然后catkin_make
第三步:在turtlebot2的仿真模型里面添加插件
roscd turtlebot_description,进入turtlebot_description包,进入urdf中,有个turtlebot_gazebo.urdf.xacro的文件,编辑它,加入代码line42-51:
<?xml version="1.0"?>
<robot name="turtlebot_gazebo" xmlns:xacro="http://ros.org/wiki/xacro">
<!-- Microsoft Kinect / ASUS Xtion PRO Live for simulation -->
<xacro:macro name="turtlebot_sim_3dsensor">
<gazebo reference="camera_link">
<sensor type="depth" name="camera">
<always_on>true</always_on>
<update_rate>20.0</update_rate>
<camera>
<horizontal_fov>${60.0*M_PI/180.0}</horizontal_fov>
<image>
<format>B8G8R8</format>
<width>640</width>
<height>480</height>
</image>
<clip>
<near>0.05</near>
<far>8.0</far>
</clip>
</camera>
<plugin name="kinect_camera_controller" filename="libgazebo_ros_openni_kinect.so">
<cameraName>camera</cameraName>
<alwaysOn>true</alwaysOn>
<updateRate>10</updateRate>
<imageTopicName>rgb/image_raw</imageTopicName>
<depthImageTopicName>depth/image_raw</depthImageTopicName>
<pointCloudTopicName>depth/points</pointCloudTopicName>
<cameraInfoTopicName>rgb/camera_info</cameraInfoTopicName>
<depthImageCameraInfoTopicName>depth/camera_info</depthImageCameraInfoTopicName>
<frameName>camera_depth_optical_frame</frameName>
<baseline>0.1</baseline>
<distortion_k1>0.0</distortion_k1>
<distortion_k2>0.0</distortion_k2>
<distortion_k3>0.0</distortion_k3>
<distortion_t1>0.0</distortion_t1>
<distortion_t2>0.0</distortion_t2>
<pointCloudCutoff>0.4</pointCloudCutoff>
</plugin>
</sensor>
</gazebo>
</xacro:macro>
<gazebo>
<plugin name="gps" filename="libhector_gazebo_ros_gps.so">
<updateRate>10.0</updateRate>
<topicName>sensor_msgs/NavSatFix</topicName>
<gaussianNoise>0.0 0.0 0.0</gaussianNoise>
<offset>0 0 0</offset>
<velocityGaussianNoise>0 0 0</velocityGaussianNoise>
<frameId>base_link</frameId>
</plugin>
</gazebo>
</robot>
用roslaunch turtlebot_gazebo turtlebot_world.launch打开gazebo,然后rostopic list可以看到gps的话 题:sensor_msgs/NavSatFix