一文安装配置cartographer,gazebo中跑cartographer建图 & 导航

解决问题思维

  1. 明确自己想要的(编译安装cartographer);准备号基本的依赖环境确认版本直接编译即可(出错时,根据报错,缺什么解决什么即可)
  2. (github加速,非必须)如果有梯子,在终端运行该命令可以让终端走代理,使得github拉项目十倍速以上(最后的ip端口填写自己代理的ip端口即可,此处是在本机开的代理):git config --global http.proxy http://domain.local\vsilva:Passw0rd@127.0.0.1:7890

最简单方式——直接使用该脚本安装即可,想要看看详细的可以看后续的配置安装过程

#!/bin/bash
echo "delete cartographer_ws..."
sudo rm -rf ~/cartographer_ws/
mkdir -p ~/cartographer_ws/src 
echo "add git proxy..."
read -p "please enter http_proxy addr and its port(eg. 127.0.0.1:7890):" HTTP_PROXY
git config --global http.proxy http://domain.local\vsilva:Passw0rd@$HTTP_PROXY

cd ~/cartographer_ws/src && git clone https://github.com/googlecartographer/cartographer_ros.git && git clone https://github.com/googlecartographer/cartographer.git

echo "install deps..."
sudo apt install -y  libgflags-dev libgoogle-glog-dev liblua5.2-dev libsuitesparse-dev ninja-build stow 

echo "install ceres-1.14.0..."
cd ~/cartographer_ws/ && git clone https://github.com/ceres-solver/ceres-solver.git && cd ceres-solver/ && git checkout 1.14.0 && mkdir build && cd build && cmake .. && make -j$proc && sudo make install


echo "install abseil.."
bash ~/cartographer_ws/src/cartographer/scripts/install_abseil.sh 

echo "make cartographer.." 
cd  ~/cartographer_ws/ && catkin_make_isolated --install --use-ninja 
source install_isolated/setup.bash

一. 配置安装Cartographer

  1. 安装基本依赖库(默认大家均已安装ROS、Cmake)

sudo apt-get update &&
sudo apt-get install -y libgflags-dev libgoogle-glog-dev liblua5.2-dev libsuitesparse-dev

  1. 创建catkin_ws拉取相关项目功能包(以下工作空间可以自己选,此处是code/ws/slam下创建)

cd ~/code/ws && mkdir -p slam/cartographer_ws/src && cd ~/code/ws/slam/cartographer_ws/src
git clone https://github.com/googlecartographer/cartographer.git && git clone https://github.com/googlecartographer/cartographer_ros.git

  1. 安装ceres-1.14.0

cd ~/code/ws/slam/ && git clone https://github.com/ceres-solver/ceres-solver.git
cd ceres-solver && git checkout 1.14.0
mkdir build && cd build && cmake … && make -j$proc && sudo make install

  1. 安装absl(使用cartographer下的脚本安装即可)

sudo apt-get install stow -y
cd ~/code/ws/slam/cartographer_ws/src/cartographer/scripts && ./install_abseil.sh

  1. 安装protobuf-3.6.1(版本过高会报错)
  2. 直接编译即可,遇到错再说(只要依赖库版本没有问题就不会出错)

cd ~/code/ws/slam/cartographer_ws/
catkin_make_isolated -DPYTHON_EXECUTABLE=/usr/bin/python3
ps.上面这句指定python3编译只在装了conda时候用即可,未装则可不指定

  1. 成功安装(核心:找对依赖库版本)

  2. 使用官方数据包测试

source devel_isolated/setup.bash
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/cartographer_paper_deutsches_museum.bag
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/Downloads/cartographer_paper_deutsches_museum.bag

二. 在gazebo仿真环境中使用cartographer算法建图并在建好的地图导航

  1. 编译cartographer(见教程一)

  2. 下载turtlebot并编译:

  • cd ~/code/ws/slam/cartographer_ws/src
  • git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
  • git clone https://github.com/ROBOTIS-GIT/turtlebot3.git
  • git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
  • cd …
  • catkin_make_isolated -DPYTHON_EXECUTABLE=/usr/bin/python3
  1. 设置环境变量:
  • echo “export TURTLEBOT3_MODEL=burger” >> ~/.bashrc
  • source ~/.bashrc
  • source /devel_isolated/setup.bash
  1. 修改launch文件
  • catkin_ws/src/turtlebot3/turtlebot3_slam/launch/turtlebot3_cartographer.launch文件,把$(arg configuration_basename)更改为turtlebot3_lds_2d_gazebo.lua
  1. 打开仿真gazebo仿真环境:
  • source devel_isolated/setup.bash
  • roslaunch turtlebot3_gazebo turtlebot3_world.launch
  1. 使用cartographer算法建图
  • roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=cartographer
  1. 使用键盘控制Turtlebot3运动
  • source devel_isolated/setup.bash
  • roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
  1. 保存地图
  • rosrun map_server map_saver -f ~/map
  1. 点击2D Nav Goal,设置目标点,导航

参考教程

SUM:

  1. 遇到一些版本不符,只是API名称的一个改变什么的,切换版本不行的话,最简答的办法是直接修改源代码和当前版本契合即可。
  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值