TX2+rplidar+cartographer

第一步:TX2安装ROS kinetic

http://www.ncnynl.com/archives/201706/1750.html

第二步:安装激光雷达驱动(测试过rplidar、F4)

首先必须给TX2编译内核,才可读取出雷达,编译方法参考 http://m.blog.csdn.net/gzj2013/article/details/77069803 

注意要选择CP210x驱动,而不是例子中的CH341

必须保证TX2中有足够的空间(大于5G)才可正常安装(我不会说试过N遍才知道)

然后安装雷达驱动,参考 http://www.ncnynl.com/archives/201704/1516.html 

第三步:TX2安装cartographer(官方安装方法)

来源:http://www.ncnynl.com/archives/201702/1369.html

# Install wstool and rosdep.
sudo apt-get update
sudo apt-get install -y python-wstool python-rosdep ninja-build

# Create a new workspace in 'catkin_ws'.
mkdir catkin_ws
cd catkin_ws
wstool init src

# Merge the cartographer_turtlebot.rosinstall file and fetch code for dependencies.

wstool merge -t src https://raw.githubusercontent.com/googlecartographer/cartographer_turtlebot/master/cartographer_turtlebot.rosinstall

#vim src/.rosinstall 该文件默认是隐形状态,进入到src文件夹后ctrl+h 即可显示出来
#更改ceres-solver中地址改为下面的地址:
#>>uri: https://github.com/ceres-solver/ceres-solver.git

wstool update -t src

# Install deb dependencies.
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y

# Build and install.
catkin_make_isolated --install --use-ninja
source install_isolated/setup.bash
  • 安装完成即Cartographer, Cartographer ROS, and Cartographer ROS’s TurtleBot都已经安装。可通过下载运行官方的例子来检验安装是否正确
# Download the example bag.(下载例子)
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/turtlebot/cartographer_turtlebot_demo.bag

# Launch the 2D LIDAR demo.(2D雷达DEMO)
roslaunch cartographer_turtlebot demo_lidar_2d.launch bag_filename:=${HOME}/Downloads/cartographer_turtlebot_demo.bag
  • 刚开始使用ROS的同学运行下面两句是无法工作的,可能出现的错误如下。
[demo_backpack_2d.launch] is neither a launch file in package [cartographer_ros] nor is [cartographer_ros] a launch file name
The traceback for the exception was written to the log file
  • 这种错误的主要原因是ros的catkin_ws配置问题,

  • 解决方法:在~bashrc文件最后一行添加 source ~/catkin_ws/install_isolated/setup.bash,

  • 然后在终端运行rospack profile,观察是否包含新包的路径。

TX2+rplidar+cartographer_第1张图片

第四步:cartographer和激光雷达相匹配,构建地图

 

F4激光雷达的配置方法参考创客教程: http://www.ncnynl.com/archives/201702/1371.html

  • 增加turtlebot_lidar.launch
cd ~/carto_ws/install_isolated/share/cartographer_turtlebot/launch
touch turtlebot_lidar.launch 
vim turtlebot_lidar.launch 
  • 代码如下:

  

  

  
    
  

  
    
    
  

  


  • 在turtlebot_navigation包(laser-driver)中增加rplidar雷达启动文件,代码如下(与原启动文件相比添加了TF转换,必不可少)

  
    
    
    
    
    
    
  

  

         
  • 新增启动文件turtlebot_lidar_2d.launch:

cd ~/carto_ws/install_isolated/share/cartographer_turtlebot/launch
touch turtlebot_lidar_2d.launch
vim turtlebot_lidar_2d.launch
  • 代码如下:


  
    
  

  • 新终端,启动雷达:
$ roslaunch turtlebot_navigation rplidar_laser.launch
  • 新终端,启动建图:
$ roslaunch cartographer_turtlebot turtlebot_lidar_2d.launch
  • 会自动打开RViz查看实时情况。
  • 移动建图,移动turtlebot走圈完成建图,也可以远程控制
  • 新终端,完成建图后保存地图,实际路径是:/home/user/map/
$ mkdir -p ~/map
$ rosrun map_server map_saver -f ~/map/lidar_2d_carto
$ ls ~/map   #查看内容,包含lidar_2d_carto.pgm  lidar_2d_carto.yaml

第五步:cartographer和激光雷达相匹配,导航

  • (1)增加rplidar_amcl_demo.launch
cd ~/catkin_ws/src/turtlebot_apps/turtlebot_navigation/launch
mkdir laser_amcl
cd laser_amcl
touch rplidar_amcl_demo.launch
gedit rplidar_amcl_demo.launch
  • 代码如下:

  
  

  
  

  
  
  

  
  
   
   
  
  
    
    
    
  

  
  
  
    
  

(2)增加rplidar_amcl.launch.xml文件

位于turtlebot_navigation / launch / includes /amcl下,直接复制r200_amcl.launch.xml文件并改名即可

(3)增加rplidar_costmap_params.yaml文件

位于turtlebot_navigation / param 下,直接复制r200_costmap_params.yaml文件并改名即可

你可能感兴趣的:(ROS)