cartographer-(0)-ubuntu(20.04)-环境安装

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.list
  vim /etc/apt/sources.list

  apt-get  update
  apt-get upgrade

  apt install vim

1. 2.安装对应版本的ros

2.安装 cartographer

2.1先安装FTP服务器

复制代码
#1.安装ftp服务器
  apt install vsftpd
  systemctl status vsftpd
  cd /etc/vsftpd.conf
  
  vim /etc/vsftpd.conf
     local_enables=YES
     write_enable=YES
     anonymous_enable=YES
     anon_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" >> ~/.bashrc
        source ~/.bashrc
#4.安装rosinstall
   apt install python3-rosdep2
   apt 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 verbose

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


#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不行,会报错

相关推荐
明王明王7 小时前
Ubuntu 26.04 使用 Windows Spotlight:给 Bing Wallpaper 加上 Spotlight 支持
linux·windows·ubuntu
江湖有缘8 小时前
Docker开源项目: 基于Ubuntu系统部署ExpenseOwl自托管记账工具实战教程
ubuntu·docker·开源
一直C8 小时前
【数据结构】哈希表+算法复杂度与经典排序查找(C语言)
java·linux·开发语言·数据结构·算法·ubuntu·散列表
kobe_OKOK_11 小时前
ubuntu server 打包成一个压缩文件,并且在另一台电脑中解压缩
服务器·数据库·ubuntu
敲代码还房贷11 小时前
安装wsl报错:HCS_E_HYPERV_NOT_INSTALLED
linux·python·ubuntu
一直C12 小时前
【Linux应用编程】深入理解Linux多任务机制:进程原理、状态转换与进程控制实战
linux·开发语言·算法·ubuntu·vim·visual studio code
智者向内寻求力量13 小时前
【记录】ubuntu 24.04 安装在levnoval PC上之后,蓝牙设备找不到解决方法
linux·服务器·ubuntu
敲代码还房贷1 天前
VMware17 + Ubuntu22.04 共享 完整步骤
linux·python·ubuntu
好果不榨汁1 天前
网络安全攻防实战:基于 Ubuntu 的攻击机与防守机搭建与演练
安全·web安全·ubuntu
w01_02_032 天前
虚拟机, ubuntu , samba
linux·运维·ubuntu