1.安装 ROS wiki.ros.org
1.1修改镜像源:
到网站上找与操作系统相匹配的镜像源
ubuntu | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-security main restricted universe multiverse# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-proposed main restricted universe multiverse
#1.root 用户
sudo passwd root
su - root#2.root 用户 修改下载源cd /etc/apt/cp sources.list sources-ini.listvim /etc/apt/sources.listapt-get updateapt-get upgradeapt install vim
1. 2.安装对应版本的ros
2.安装 cartographer
2.1先安装FTP服务器
#1.安装ftp服务器apt install vsftpdsystemctl status vsftpdcd /etc/vsftpd.confvim /etc/vsftpd.conflocal_enables=YESwrite_enable=YESanonymous_enable=YESanon_mkdir_write_enable=YES //允许匿名用户在FTP上创建目录anon_upload_enable=YES //允许匿名用户在FTP服务器上上传文件anon_other_write_enable=YES //开启匿名用户的其他写权限
2.2 安装 cartographer依赖库
#1.安装ROS
sudo apt install ros-melodic-desktop-full
#2.初始化rosdep
sudo rosdep init
apt install python3-rosdep2
rosdep update
#3.设置环境变量echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrcsource ~/.bashrc
#4.安装rosinstallapt install python3-rosdep2apt install python-rosinstall python-rosinstall-generator python-wstool build-essential复制文件到目录: cartographer_install
chmod +x auto-carto-build.sh
./auto-carto-build.sh
2.3 安装编写的运行脚本 ceres-solver ,protobuf,cartographer
2.3.1 运行环境
/home/tang/cartographer/cartographer_install
安装脚本的编写参考:
Cartographer — Cartographer documentation
#!/bin/bash#1 Install the required libraries that are available as debs.
# sudo apt-get update
sudo apt-get install \clang \cmake \g++ \git \google-mock \libboost-all-dev \libcairo2-dev \libcurl4-openssl-dev \libeigen3-dev \libgflags-dev \libgoogle-glog-dev \liblua5.2-dev \libsuitesparse-dev \lsb-release \ninja-build \stow \python3-wstool \python3-rosdep \python3-sphinx \libatlas-base-dev#2 Build and install abseil-cpp
set -o errexit
set -o verbosecd 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#3 Build and install Ceres.
cd -
cd ../../ceres-solver
mkdir build
cd build
cmake .. -G Ninja -DCXX11=ON
ninja
#CTEST_OUTPUT_ON_FAILURE=1 ninja test
sudo ninja install#4 Build and install proto3.
cd ../../protobuf
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#5 Build and install Cartographer.
cd ../../cartographer
mkdir build
cd build
cmake .. -G Ninja
ninja
#CTEST_OUTPUT_ON_FAILURE=1 ninja test
sudo ninja install
出现:
fatal: detected dubious ownership in repository
原因:权限的问题。
解决方法:
git config --global --add safe.directory /home/tang/cartographer/cartographer_install/abseil-cpp
2.3.2源码编译
目录:/home/tang/carto_ws/cartographer_detailed_comments_ws/
下载注释的代码:
https://github.com/xiangli0608/cartographer_detailed_comments_ws
git clone https://github.com/xiangli0608/cartographer_detailed_comments_ws.git
#1.编译源码 git 下在
cd /home/tang/
mkdir carto_ws
cd carto_ws
git clone https://github.com/xiangli0608/cartographer_detailed_comments_ws.git#更新git
git pull origin master#2.编译源码
./catkin_make.sh#3.vim ~/.bashrc
source /home/tang/carto_ws/cartographer_detailed_comments_ws/install_isolated/setup.bash#4. 4个包
/home/tang/carto_ws/cartographer_detailed_comments_ws/src/cartographer
/home/tang/carto_ws/cartographer_detailed_comments_ws/src/cartographer_ros/cartographer_ros
/home/tang/carto_ws/cartographer_detailed_comments_ws/src/cartographer_ros/cartographer_ros_msgs
/home/tang/carto_ws/cartographer_detailed_comments_ws/src/cartographer_ros/cartographer_rviz
error,当出现找不到rosbag等包时,不要修改cmake文件,安装各种包即可。
sudo apt install ros-noetic-ros-rosbag sudo apt install ros-noetic-turtle-tf2 sudo apt install ros-noetic-tf2-tools sudo apt install ros-noetic-urdf-tutorial
2.到目录下执行脚本编译
到目录下直接执行catkin_make不行,会报错