移动机器人gazebo仿真(1)—导入激光雷达

参考文章:

http://blog.csdn.net/qq_36355662/article/details/61413860

http://blog.csdn.net/qq_36355662/article/details/61616513

http://www.ncnynl.com/archives/201610/914.html

http://www.yaoguangkeji.com/a_d3O8YpEk.html

http://blog.csdn.net/changer_sun/article/details/79264388#t2

http://blog.csdn.net/zyh821351004/article/details/48846179

1、准备源码、模型

首先建立工作空间并下载源码

mkdir -p ~/gmapping_ws/src  
cd ~/gmapping/src 
git clone https://github.com/robopeak/rplidar_ros.git  
git clone https://github.com/turtlebot/turtlebot_simulator.git  
git clone https://github.com/turtlebot/turtlebot_apps.git 
git clone https://github.com/turtlebot/turtlebot.git  

turtlebot_interactions

下载模型并放在~/.gazebo/models 路径下

cd ~/.gazebo/models
wget -q -R *index.html*,*.tar.gz --no-parent -r -x -nH http://models.gazebosim.org/hokuyo/

也可下载全部模型,放到隐藏目录.gazebo下(ctrl+H显示隐藏目录)

地址:

2、修改turtlebot_world.launch

修改 STACKS 申明 :

修改TURTLEBOT_3D_SENSOR:

修改后如下:


  
  
   
    
    
  

    
   
  

  
    
    
    
    
  

  
    
    
    
    
    
  

  
    
  

  
  
  

3、分析turtlebot_world.launch

turtlebot_world.launch 功能:

1、找到 gazebo_ros包下的empty_world.launch文件 ,作为gazebo的地图,该文件可以自行替换为自建地图

2、找到 turtlebot_gazebo包下的kobuki.launch.xml文件

3、运行

4、添加 假的激光

4、修改kobuki.launch.xml文件

找到turtlebot_gazebo包

roscd turtlebot_gazebo/

找到xml文件,地址:

/home/jk/gmapping_ws/src/turtlebot_simulator/turtlebot_gazebo/launch/includes

修改xml文件如下:


  
  
  
  

  

  
  

  
  
  
    
    
  

  
  


3.修改kobuki_hexagons_hokuyo.urdf.xacro

新建文件:

roscd turtlebot_description/robots/
sudo vi kobuki_hexagons_hokuyo.urdf.xacro

内容:





  
  
  
  
  

  
  
  
  

注意这两处有修改(删除了原先的turtlebot_common_library,加入了以下内容)




4.修改turtlebot_library.urdf.xacro

找到路径:
roscd turtlebot_description/urdf/
gedit turtlebot_library.urdf.xacro
新建/修改文件如下:



  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
hokuyo.urdf.xacro是新加入的传感器urdf文件,因此需要新建;

5.添加hokuyo的.urdf.xacro文件

roscd turtlebot_description/urdf/sensors/
gedit hokuyo.urdf.xacro

编辑文件内容如下:


    
    
      
      

      
      
        
          
          
            
        

        
       
         
           
           
         
           
         

       
           
         
        
         
       

       
           
         
        
        
       

        
        
      

这里有一步:

需要将路径:/home/jk/.gazebo/models/hokuyo/meshes  中的hokuyo_convex.stl 和 hokuyo.dae复制到

 /home/jk/gmapping_ws/src/turtlebot/turtlebot_description/meshes/sensors    下

6.配置turtlebot_gazebo.urdf.xacro添加laser

roscd turtlebot_description/urdf/
gedit turtlebot_gazebo.urdf.xacro 
  
  
    
    
        
        
        true  
        20.0  
          
          ${60.0*M_PI/180.0}  
            
            R8G8B8  
            640  
            480  
            
            
            0.05  
            8.0  
            
          
          
          camera  
          true  
          10  
          rgb/image_raw  
          depth/image_raw  
          depth/points  
          rgb/camera_info  
          depth/camera_info  
          camera_depth_optical_frame  
          0.1  
          0.0  
          0.0  
          0.0  
          0.0  
          0.0  
          0.4  
          
        
      
    
  
  
  
    
  
  
 
        
          0 0 0 0 0 0
          false
          40
          
            
              
                720
                1
                -1.570796
                1.570796
              

            
              0.10
              30.0
              0.01
            
            
              gaussian

               0.0
              0.01
            
          
            
            
            scan
            hokuyo_link
        
        
      
  
  

此处注意hokuyo_link部件名称和前边的hokuyo_link对应,才能仿真处实际传感器数据。此处数据发布在/turtlebot/laser/scan中的/turtlebot/laser/scan主题上。

7、修改环境变量

sudo gedit .bashrc
#在最后添加以下内容
#For gazebo 
export  TURTLEBOT_BASE=kobuki
export  TURTLEBOT_STACKS=hexagons
export  TURTLEBOT_3D_SENSOR=hokuyo

之后运行,正常,激光有数据,话题/scan正常

roslaunch turtlebot_gazebo explorer.launch
roslaunch turtlebot_teleop keyboard_teleop.launch
roslaunch turtlebot_gazebo gmapping_demo.launch
roslaunch turtlebot_rviz_launchers view_navigation.launch



你可能感兴趣的:(移动机器人/ROS)