树莓派配置
1. 树莓派配置
1.1. 系统安装
1.1.1. MAC下烧写树莓派系统
方法一:命令行方法
***
sudo dd bs=4m if=2017-11-29-raspbian-stretch.img of=/dev/rdisk4
其中if参数为镜像文件,of参数为设备名称。但是烧写系统进sd卡前需要一个准备工作,其一是将sd卡抹掉格式化一下,然后卸载sd卡分区,最后将系统烧进指定sdk位置。
抹掉sd卡很简单,mac的磁盘工具,选中sd卡,点抹掉,格式选择MS-DOS(FAT)。
- sdk格式化之后,Mac命令行输入
df -h
得到挂载的SD卡位置(卷),比如/dev/disk4s1
。
然后使用卸载这个分区
diskutil unmount /dev/disk4s1
获得我们要安装系统的设备
diskutil list
- 注意:此处我们看到的是 /dev/disk4,但是写核心指令的时候要加一个字母r,即/dev/rdisk4。
最终得到的就是
sudo dd bs=4m if=2017-11-29-raspbian-stretch.img of=/dev/rdisk4
最后安全退出sd卡
diskutil unmountDisk /dev/disk4
方法二:使用烧录软件balenaEtcher
1.1.2. 开启ssh和vnc
1.1.2.1. ssh连接
- 开启树莓派
ssh
安装raspi-config
sudo apt install raspi-config
打开raspi-config
sudo raspi-config
设置ssh
开启如下图
选择Interfacing options
选择ssh
选择ok
:::alert-success
至此树莓派SSH开启成功
:::
ssh
连接树莓派
首先通过网线或者wifi连接树莓派
然后查看树莓派ipifconfig
在终端连接树莓派ssh
1.1.3. 扩展磁盘空间
查看磁盘空间
df -h
使用系统工具扩容
sudo raspi-config
然后在选择Advancd Options -> Expand Filesystem
重启后空间即为整个SD卡空间
1.1.4. 扩展交换空间
安装dphys-swapfile
sudo apt install dphys-swapfile
编辑dphys-swapfile
扩展空间
sudo nano /etc/dphys-swapfile
1.2. 树莓派工作系统搭建
1.2.1. 换源
- 打开source.list
nano /etc/apt/sources.list
- 删除原有源替换为下列源
原有源
deb http://ports.ubuntu.com/ xenial main restricted universe multiverse deb-src http://ports.ubuntu.com/ xenial main restricted universe multiverse deb http://ports.ubuntu.com/ xenial-updates main restricted universe multiverse deb-src http://ports.ubuntu.com/ xenial-updates main restricted universe multiverse deb http://ports.ubuntu.com/ xenial-security main restricted universe multiverse deb-src http://ports.ubuntu.com/ xenial-security main restricted universe multiverse deb http://ports.ubuntu.com/ xenial-backports main restricted universe multiverse deb-src http://ports.ubuntu.com/ xenial-backports main restricted universe multiverse新源:```deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main restricted universe multiversedeb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main restricted universe multiversedeb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiversedeb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiversedeb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiversedeb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiversedeb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main restricted universe multiversedeb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main restricted universe multiverse```
- 更新源
sudo apt update
1.2.2. 安装gcc编译器
sudo apt-get update && sudo apt-get install build-essential software-properties-common -y && sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && sudo apt-get update && sudo apt-get install gcc-snapshot -y && sudo apt-get update && sudo apt-get install gcc-6 g++-6 -y && sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6
1.2.3. 安装依赖
sudo apt install git libssl-dev libusb-1.0-0-dev pkg-config -y sudo apt install cmake python3-dev raspberrypi-kernel-headers -y
sudo apt install libglu-dev
1.2.4. 克隆仓库
cd ~ git clone https://github.com/IntelRealSense/librealsense.git cd librealsense
1.2.5. Install udev rules
sudo cp config/99-realsense-libusb.rules /etc/udev/rules.d/ sudo udevadm control --reload-rules && udevadm trigger
1.2.6. install apriltag
1.2.7. 创建编译目录
mkdir build cd build
1.2.8. 编译准备
rm CMakeCache.txt export CC=/usr/bin/gcc-6 export CXX=/usr/bin/g++-6
1.2.9. 编译cmake
cmake -D CMAKE_BUILD_TYPE="Release"-D FORCE_LIBUVC=ON -D BUILD_PYTHON_BINDINGS=ON -D BUILD_EXAMPLES=ON ..
问题解决
安装libx11-dev
sudo apt-get install libx11-dev libxext-dev libxrender-dev libxtst-dev libxt-dev
如果报错 “The RandR library and headers were not found”
则需要在terminal
里执行
sudo apt-get install libxrandr-dev
如果报错 The XInput library and headers were not found
则需要在terminal
里执行
sudo apt-get install libxi-dev
如果报错 The Xinerama library and headers were not found
sudo apt-get install libxinerama-dev
如果报错The Xcursor libraries and headers were not found
sudo apt-get install libxcursor-dev
如果报错 Could NOT find OpenGL
sudo apt install libgl1-mesa-dev
sudo apt install libglu-dev
报警告找不到apriltap
1.2.10. 安装Ros
1.3. 打开vnc
vncserver