血与泪的教训
报错很抽风,记得多试几次!!!
准备工作
- Ubuntu已经成功安装了ROS
- 最好有一个相对干净的系统避免无关的报错
- 最好有科学手段,不然下载功能包会很忙
更新软件包
sudo apt-get update
安装依赖
sudo apt-get install -y \
cmake \
g++ \
git \
google-mock \
libboost-all-dev \
libcairo2-dev \
libeigen3-dev \
libgflags-dev \
libgoogle-glog-dev \
liblua5.2-dev \
libsuitesparse-dev \
libwebp-dev \
ninja-build \
protobuf-compiler \
python-sphinx
如果后面报错,可以试试安装下面这些依赖。本人只安装上面的依赖就可以成功安装了。
sudo apt-get install -y python-wstool python-rosdep ninja-build stow
sudo apt-get install -y google-mock libboost-all-dev libeigen3-dev libgflags-dev libgoogle-glog-dev liblua5.2-dev libprotobuf-dev libsuitesparse-dev libwebp-dev ninja-build protobuf-compiler python-sphinx ros-melodic-tf2-eigen libatlas-base-dev libsuitesparse-dev liblapack-dev
检查protoc版本
查找资料发现有博主说编译cartographer需要proto版本为3,但是ROS自带的版本为2。我的proto版本就是3,不需要卸载重新安装。如果你使用proto2报错的话,可以试试升级版本为3。不需要升级的话直接跳转到安装cartographer步骤
//查看版本
protoc --version
升级proto版本
//卸载原本的proto
sudo apt-get remove libprotobuf-dev
//查看proto所在路径,输入命令后会出现一个路径
which protoc
//一般都是默认路径 /usr/bin/protoc
sudo rm 路径
eg:sudo rm /usr/bin/protoc
//开始安装proto
cd ~/Downloads
//下载源码
git clone https://github.com/google/protobuf.git
cd protobuf
git checkout v3.6.1
mkdir build
cd build
cmake \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DCMAKE_BUILD_TYPE=Release \
-Dprotobuf_BUILD_TESTS=OFF \
../cmake
make -j4
sudo make install
//检查是否成功安装 输出路径则说明安装成功
protoc --version
//查看一下安装路径,由于carto的搜索路径为/usr/bin/protoc,所以我们需要改一下路径
which protoc
//简单一点,直接复制过去
sudo cp /usr/local/bin/protoc /usr/bin
安装cartographer
准备工作
sudo apt-get update
sudo apt-get install -y python-wstool python-rosdep ninja-build
创建工作空间
//创建工作空间
mkdir -p cartographer_install
//进入工作空间
cd cartographer_install
//初始化 会在路径下出现src文件夹
wstool init src
修改 .rosinstall
//进入src文件夹
cd src
//修改配置文件
sudo gedit .rosinstall
//改为下面的代码
-----------------------
- git:
local-name: cartographer
uri: https://github.com/googlecartographer/cartographer.git
version: 1.0.0
- git:
local-name: cartographer_ros
uri: https://github.com/googlecartographer/cartographer_ros.git
version: 1.0.0
- git:
local-name: ceres-solver
uri: https://github.com/ceres-solver/ceres-solver.git
version: 1.13.0
下载功能包
//回到工作空间
cd cd cartographer_install
//输入命令进行克隆,成功后工作空间内就会多出三个文件
wstool update -t src
更新文件
rosdep update
安装cartographer
//安装版本修改 18.04对应melodic
rosdep install --from-paths src --ignore-src --rosdistro=melodic -y
编译
catkin_make_isolated --install --use-ninja
测试cartographer
下载数据包测试
//2D数据包测试
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/cartographer_paper_deutsches_museum.bag
//3D数据包测试
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_3d/with_intensities/b3-2016-04-05-14-14-00.bag
配置环境变量
source install_isolated/setup.bash
运行测试文件
//2D数据包测试
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/Downloads/cartographer_paper_deutsches_museum.bag
//3D数据包测试
roslaunch cartographer_ros demo_backpack_3d.launch bag_filename:=${HOME}/Downloads/b3-2016-04-05-14-14-00.bag
此处评论已关闭