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

相关推荐
Joyner20186 小时前
ubuntu批量依赖库拷贝(ldd)
linux·运维·ubuntu
Jason_C_6 小时前
【NVIDIA】启动ubuntu后显卡驱动丢失
linux·运维·ubuntu
阑梦清川6 小时前
基于ubuntu的mysql 8.0安装教程
linux·mysql·ubuntu
Snow_Dragon_L7 小时前
【MySQL】表操作
linux·数据库·后端·sql·mysql·ubuntu
wkd_0078 小时前
【C++读写.xlsx文件】OpenXLSX开源库在 Ubuntu 18.04 的编译、交叉编译与使用教程
linux·ubuntu·openxlsx·c++写xlsx·开源库编译
zhy295638 小时前
【LIBS】开源库编译之OSQP
ubuntu·cmake·osqp·libs
轻口味9 小时前
配置TypeScript:tsconfig.json详解
ubuntu·typescript·json
白云千载尽11 小时前
ubuntu初始化与软件安装(持续更新)
linux·chrome·ubuntu
过过过呀Glik12 小时前
在 Ubuntu 上安装与配置 Docker 的完整指南
linux·ubuntu·docker
明 庭14 小时前
在 Ubuntu 下通过 Docker 部署 PSQL 服务器
服务器·ubuntu·docker