树莓派3+安装Ubuntu Mate 18.04+ROS
下载、烧录镜像
下载地址:ubuntu mate 18.04 for raspi (32位)
烧录镜像工具:rufus
下载地址:rufus 3.12
烧录完镜像,将SD卡插入树莓派,接入电源启动,按照提示设置好用户名和密码,进入桌面。CTRL+ALT+T 可以打开终端。
换源
打开apt源文件
sudo nano /etc/apt/sources.list
删去原有的内容,粘贴下面的文本,替换为阿里源。arm架构收录在ubuntu-ports源中。
deb http://mirrors.aliyun.com/ubuntu-ports/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu-ports/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu-ports/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu-ports/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu-ports/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ bionic-backports main restricted universe multiverse
保存退出
更新软件列表
sudo apt update
更新全部软件
sudo apt upgrade
更新如遇到问题:
Errors were encountered while processing:
/var/cache/apt/archives/linux-firmware-raspi2_1.20190215-0ubuntu0.18.04.1_armhf.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
是ubuntu蓝牙模块bluez与树莓派固件冲突所致,可以强制安装:
sudo dpkg -i --force-all /var/cache/apt/archives/linux-firmware-raspi2_1.20190215-0ubuntu0.18.04.1_armhf.deb
之后重新执行更新
sudo apt upgrade
如果遇到某个地址无法访问导致的报错,多是网络原因所致,尝试重新开始更新就可以。
安装ROS
添加下载源
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
设置密钥
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654
更新软件源
sudo apt update
安装
sudo apt install ros-melodic-desktop-full
sudo apt install python-rosdep2
sudo apt install python-rosinstall
若有错误,多为网络原因所致,尝试重新开始安装就可以。
初始化rosdep
sudo rosdep init
若出现错误:
ERROR cannot download default sources list from:
https://raw.githubusercontent.c...
可编辑/etc/hosts文件解决
sudo nano /etc/hosts
在文件末尾加上
151.101.84.133 raw.githubusercontent.com
保存退出
再次执行
sudo rosdep init
稍等片刻,依据提示继续运行
rosdep update
等待完成后,设置环境变量
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
安装完成
测试
roscore
显示 started core service [/rosout]表示ros已经正常运行在树莓派上了。