1、 ,把系统烧录至SD卡后进入系统中依次完成:语言选择、键盘布局选择、WIFI连接、地区选择、用户设置、内存设置(0或者留空)。
2、 进入系统设置完成语言的完整下载以及等待系统完成更新、设置系统休眠为从不,最后重启系统。
3、 安装中文输入法:
输入:
sudo apt-get install ibus-pinyin 下载输入法
重启
ibus-setup 进入配置界面
选择Intelligent Pinyin
ibus restart 重启ibus

4、 更新源和软件:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak 备份原本的源
sudo gedit /etc/apt/sources.list 打开文件

删除所有文件,复制以下内容:

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main multiverse restricted universe

输入:

sudo apt-get update
sudo apt-get full-upgrade

5、 增加交换空间
检查当前系统的效换空间:sudo swapon –show 检查内存: free -h

创建用于swap的文件:sudo fallocate -l 2G /swapfile

如果fallocate没有安装,将得到fallocate failed:Operation not supported的报错信息。可以用以下命令创建:
sudo dd if=/dev/zero of=/swapfile bs=2048 count=1048576 所有用户都可以读写swap file,设置正确的权限:sudo chmod 666 /swapfile 设置交换空间:sudo mkswap /swapfile 激活交换空间:sudo swapon /swapfile 打开文件:sudo vi /etc/fstab 在文件中按i进入插入模式最后一行添加:/swapfile swap swap defaults 0 0 按esc退出再按:wq!保存。
验证增加空间是否有效:

sudo swapon --show
sudo free -h

6、 切换功率

sudo nvpmodel -m 0
sudo jetson_clocks

切换到高功率模式运行且把CPU频率固定。
7、 删除无用软件
删除office:

sudo apt-get purge libreoffice*
sudo apt-get clean

8、 配置CUDA环境
打开文件:

sudo gedit .bashrc

在文件最后一行插入:

export PATH=/usr/local/cuda-10.2/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export CUDA_ROOT=/usr/local/cuda

保存后输入:source ~/.bashrc 然后用命令查看cuda版本:nvcc -V 9、 安装系统级安装包

sudo apt-get install build-essential make cmake cmake-curses-gui
sudo apt-get install git g++ pkg-config curl
sudo apt-get install libatlas-base-dev gfortran libcanberra-gtk-module libcanberra-gtk3-module
sudo apt-get install libhdf5-serial-dev hdf5-tools 
sudo apt-get install nano locate screen

接着安装scipy的依赖和系统级别的cython:

sudo apt-get install libfreetype6-dev 
sudo apt-get install protobuf-compiler libprotobuf-dev openssl
sudo apt-get install libssl-dev libcurl4-openssl-dev
sudo apt-get install cython3

如果要装TensorFlow Object Detection (TFOD) API ,还要装xml的工具:

sudo apt-get install libxml2-dev libxslt1-dev

接着安装opencv的系统级依赖,一些编解码的库:

sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install libxvidcore-dev libavresample-dev
sudo apt-get install libtiff-dev libjpeg-dev libpng-dev
sudo apt-get install build-essential -y
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev -y
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff5-dev libdc1394-22-dev -y
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev liblapacke-dev -y
sudo apt-get install libxvidcore-dev libx264-dev -y
sudo apt-get install libatlas-base-dev gfortran -y
sudo apt-get install ffmpeg -y

更新CMake:

wget http://www.cmake.org/files/v3.22/cmake-3.22.0.tar.gz  #下载,版本号可到官网上查
tar xpvf cmake-3.22.0.tar.gz cmake-3.22.0/  #解压
cd cmake-3.22.0/
./bootstrap --system-curl
make -j4 #编译
echo 'export PATH=~/cmake-3.22.0/bin/:$PATH' >> ~/.bashrc
source ~/.bashrc #更新.bashrc

配置PIP

sudo apt-get install -y python3-dev python3-testresources python3-setuptools 
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
rm get-pip.py
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U
python3 -m pip install –upgrade pip

利用pip安装一些包

sudo apt-get install python3-scipy
sudo apt-get install python3-pandas
sudo apt-get install python3-sklearn

10、 安装vscode
Visual Studio Code官网:https://code.visualstudio.com/
点击Download for Windows
点击Other downloads
选择.deb中的ARM64
进入到下载目录打开终端输入:sudo dpkg -i code_1.62.0-1635953028_arm64.deb 继续运行:

sudo apt-get install -f # Install dependencies
sudo apt install apt-transport-https
sudo apt update
sudo apt install code # or code-insiders

之后输入code进入。
11、 U盘兼容

sudo apt-get install exfat-utils

12、 安装pytorch
pytorch下载链接:
https://pan.baidu.com/s/1Nfm9w1DfE2k_cZQ1zTykMQ 提取码:zpsa

在文件目录输入:sudo pip3 install 文件名
1.提前打上我们需要的依赖

sudo apt-get install libopenmpi2
sudo apt-get install libopenblas-dev
sudo apt-get install libjpeg-dev zlib1g-dev
cd torchvision	# 进入到这个包的目录下
export BUILD_VERSION=0.9.0
sudo python3 setup.py install		# 安装(估计要20分钟不止吧)

检验一下是否成功安装

python3
import torch
import torchvision
print(torch.cuda.is_available())	# 这一步如果输出True那么就成功了!
quit()	# 最后退出python编译

13、 安装ROS
添加ROS 软件源

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main">/etc/apt/sources.list.d/ros-latest.list'

添加密钥

sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

安装ROS

sudo apt update
sudo apt install ros-melodic-desktop-full(重复输入几次,确保完全安装)

初始化rosdep

sudo rosdep init
rosdep update

如果出现rosdep未找到命令输入:sudo apt install python-rosdep

rosdep update报错解决办法:
把相关文件下载到本地:git clone https://github.com/ros/rosdistro.git 改ROS去获取文件的地址:
(1)、查找文件/usr/lib/python2/dist-packages/rosdep2/rep3.py 中的raw.githubusercontent.com,将 https://raw.githubusercontent.com/ros/rosdistro/master 替换成file:///home/用户名/rosdistro(即文件路径)
(2)查找文件/usr/lib/python2/dist-packages/rosdistro/init.py中的raw.githubusercontent.com,将 https://raw.githubusercontent.com/ros/rosdistro/master 替换成file:///home/用户名/rosdistro(即文件路径)
3. 修改/etc/ros/rosdep/sources.list.d/20-default.list
继续改地址,将该文件中的所有 https://raw.githubusercontent.com/ros/rosdistro/master 替换成file:///home/用户名/rosdistro(即文件路径)

上述步骤结束后继续执行:rosdep update 设置环境变量:

echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc

安装rosinstall

sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential

验证安装是否成功

Roscore

打开另一个窗口:rosrun turtlesim turtlesim_node 再打开另一个窗口:rosrun turtlesim turtle_teleop_key 小海龟动起来就成功了。

11、安装cartographer
1.安装工具wstool,nijia,rosdep

sudo apt-get update
sudo apt-get install -y python-wstool python-rosdep ninja-build stow

2.加Google服务器域名提高下载速度

sudo gedit /etc/resolv.conf

注释掉之前那一行,并添加以下内容:

nameserver 8.8.8.8 
nameserver 8.8.4.4

注意:安装完成后恢复成原来的。
3.打开终端ctrl+alt+t创建工作空间

mkdir cartographer_ws

4.三个pkg,cartographer,cartographer_ros,ceres-slover,

cd cartographer_ws
wstool init src
cd src
git clone https://github.com/googlecartographer/cartographer_ros.git
git clone https://github.com/googlecartographer/cartographer.git
git clone https://github.com/ceres-solver/ceres-solver.git

5.安装依赖

cd cartographer_ws
sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
src/cartographer/scripts/install_abseil.sh
sudo apt-get remove ros-${ROS_DISTRO}-abseil-cpp

6.编译

catkin_make_isolated --install --use-ninja

7.跑demo
Demo下载地址:

https://google-cartographer-ros.readthedocs.io/en/latest/data.html#d-cartographer-backpack-deutsches-museum

刷新一下环境变量:source install_isolated/setup.bash

2D的:roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=//你的数据的路径