第一步: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
# 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
[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,观察是否包含新包的路径。
第四步:cartographer和激光雷达相匹配,构建地图
F4激光雷达的配置方法参考创客教程: http://www.ncnynl.com/archives/201702/1371.html
cd ~/carto_ws/install_isolated/share/cartographer_turtlebot/launch
touch turtlebot_lidar.launch
vim turtlebot_lidar.launch
新增启动文件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
$ mkdir -p ~/map
$ rosrun map_server map_saver -f ~/map/lidar_2d_carto
$ ls ~/map #查看内容,包含lidar_2d_carto.pgm lidar_2d_carto.yaml
第五步:cartographer和激光雷达相匹配,导航
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文件并改名即可