ubuntu 配置安装Cartographer
作为记录使用
我的系统配置
:
- ubuntu: 18.04
- ROS1: melodic
- VMware: 15.5.7 build-17171714
1. 更新和安装编译工具
sudo apt-get update
sudo apt-get install -y python-wstool python-rosdep ninja-build
2. 创建工作空间
mkdir catkin_ws_google && cd catkin_ws_google
wstool init src
wstool merge -t src https://ghproxy.com/https://raw.githubusercontent.com/googlecartographer/cartographer_ros/master/cartographer_ros.rosinstall
3. 修改.rosinstall,将码云上的代码地址对应的更改过来,三处都改
vim src/.rosinstall
修改成如下:
# THIS IS AN AUTOGENERATED FILE, LAST GENERATED USING wstool ON 2020-07-30
- git:
local-name: cartographer
uri: https://ghproxy.com/https://github.com/cartographer-project/cartographer.git
version: 1.0.0
- git:
local-name: cartographer_ros
uri: https://ghproxy.com/https://gitee.com/zhaokexue/cartographer_ros.git
version: 1.0.0
- git:
local-name: ceres-solver
uri: https://ghproxy.com/https://github.com/ceres-solver/ceres-solver.git
version: 1.13.0
4. 更新src
wstool update -t src
下来是修改install_proto3.sh和install_abseil.sh,这两个文件在cartographer/scripts/这个文件夹下。
主要在他们的github链接加上了代理,添加后确保百分比克隆下来,不会出错。
5. 修改install_proto3.sh
VERSION="v3.4.1"
# Build and install proto3.
git clone https://ghproxy.com/https://github.com/protocolbuffers/protobuf.git
cd protobuf
git checkout tags/${VERSION}
mkdir build
cd build
cmake -G Ninja \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DCMAKE_BUILD_TYPE=Release \
-Dprotobuf_BUILD_TESTS=OFF \
../cmake
ninja
sudo ninja install
6. 修改install_abseil.sh
#!/bin/sh
# Copyright 2019 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit
set -o verbose
git clone https://ghproxy.com/https://github.com/abseil/abseil-cpp.git
cd abseil-cpp
git checkout d902eb869bcfacc1bad14933ed9af4bed006d481
mkdir build
cd build
cmake -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DCMAKE_INSTALL_PREFIX=/usr/local/stow/absl \
..
ninja
sudo ninja install
cd /usr/local/stow
sudo stow absl
7. 安装protobuf3和abeil
src/cartographer/scripts/install_proto3.sh
src/cartographer/scripts/install_abseil.sh
8. 最后执行下面的命令。一般来说,如果初始安装了ros,执行sudo rosdep init时会出现错误,
这里我放个链接,修改完成百分比通过。通过修改rosdep update肯定会通过
sudo rosdep init #这里报错很正常,不用在意
rosdep update #这里超时报错,就重新执行几次改命令就好
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
catkin_make_isolated --install --use-ninja
# 编译时间较长,可以静等编译成功,
# 如果编译不成功,多数是系统被更该过于严重,不建议使用网上教程更改,因为多说情况下,还是会有问题,建议重装系统,
# 在纯净的系统下,按照该教程安装完全没有问题,而且安装十分迅速。
参考链接
[https://zhuanlan.zhihu.com/p/392082731]
[https://zhuanlan.zhihu.com/p/165398798]