Gazebo中的turtlebot2中加入GPS模块

    ubuntu14.04,ros版本为indigo。

    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





  • 0
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值