天天看点

已 树莓派4b ros 系统 网盘_无限可能:树莓派4B 安装Ubuntu18.04+ROS1(melodic)

已 树莓派4b ros 系统 网盘_无限可能:树莓派4B 安装Ubuntu18.04+ROS1(melodic)

一、安装Ubuntu18.04

  1. 从Ubuntu官网(Install Ubuntu Server on a Raspberry Pi 2, 3 or 4 | Ubuntu)下载64bit镜像,Ubuntu server版本(不含桌面),如下图红色圈所示。
已 树莓派4b ros 系统 网盘_无限可能:树莓派4B 安装Ubuntu18.04+ROS1(melodic)

2. 使用Win32DiskImager工具烧录镜像到TF卡(32GB)。

3. TF卡插入树莓派,启动树莓派;系统提示修改密码,按照提示修改密码。

4. 安装Ubuntu桌面

安装之前,请确保树莓派插入网线,可以上网,安装桌面后,只需启动一次,后续再次重启树莓派,默认进入桌面系统。

已 树莓派4b ros 系统 网盘_无限可能:树莓派4B 安装Ubuntu18.04+ROS1(melodic)
$sudo apt install ubuntu-desktop 
           

期间会出现提示,输入Y

已 树莓派4b ros 系统 网盘_无限可能:树莓派4B 安装Ubuntu18.04+ROS1(melodic)

如果很快就结束,并提示很多error(如下图所示),说明网络不行,需要设置下数据源

已 树莓派4b ros 系统 网盘_无限可能:树莓派4B 安装Ubuntu18.04+ROS1(melodic)

提前把更新后的source.list文件拷贝到u盘中,把u盘插到树莓派上,把文件拷贝到树莓派。

source.list文件下载链接:https://pan.baidu.com/s/1tj7gPsWC0YN_TdEvMPu-Bw

提取码:5w9k

首先找到u盘的位置

$sudo fdisk -l
           

把u盘mount到mnt目录下

$sudo mount /dev/sda1 /mnt
           

用U盘的文件覆盖默认的/etc/apt/source.list,为了安全期间,也可以先把source.list备份。

$sudo cp /mnt/source.list /etc/apt/
           
已 树莓派4b ros 系统 网盘_无限可能:树莓派4B 安装Ubuntu18.04+ROS1(melodic)

继续执行

$sudo apt install ubuntu-desktop
           

如果出现如下的问题,

已 树莓派4b ros 系统 网盘_无限可能:树莓派4B 安装Ubuntu18.04+ROS1(melodic)

可以参考如下的解决方式

$sudo rm /var/lib/dpkg/lock
$sudo dpkg --configure -a
$sudo apt update
           

继续执行

$sudo apt install ubuntu-desktop
           

执行完之后,启动图形界面

$startx
           
已 树莓派4b ros 系统 网盘_无限可能:树莓派4B 安装Ubuntu18.04+ROS1(melodic)

根据提示设置完之后

已 树莓派4b ros 系统 网盘_无限可能:树莓派4B 安装Ubuntu18.04+ROS1(melodic)

二、安装ROS1 Melodic

安装源

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'
           

设置key

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

更新

$sudo apt-get update
           

如果更新的过程中出现锁的错误,类似如下

已 树莓派4b ros 系统 网盘_无限可能:树莓派4B 安装Ubuntu18.04+ROS1(melodic)

可以尝试如下方式解决,然后继续执行更新

$sudo rm /var/lib/apt/lists/lock
$sudo apt-get update
           

桌面完整安装(推荐),ROS,rqt,rviz,机器人通用库,2D/3D模拟器,导航和2D/3D感知

$sudo apt-get install ros-melodic-desktop-full 
           

初始化rosdep

$sudo rosdep init
           

如果出现错误:rosdep command not found, 可以参考如下解决方法。

$sudo apt install python-rosdep
           

继续执行

$sudo rosdep init
           

如果出现如下错误:

ERROR: cannot download default sources list from:

https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list

Website may be down.

可以参考如下解决方法。

$sudo gedit /etc/hosts
           

在文件末尾添加(ip地址从https://site.ip138.com/raw.githubusercontent.com/中查询,推荐日本东京的ip)

151.101.108.133 raw.githubusercontent.com

151.101.228.133 raw.githubusercontent.com

继续执行

$sudo rosdep init
$rosdep update
           

环境设置

如果ROS环境变量在每次启动新shell时自动添加到bash会话中,则很方便:

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

如果安装了多个ROS分发版,~/.bashrc只能为当前使用的版本提供setup.bash。

如果只是想改变当前shell的环境,而不是上面的,可以输入:

source /opt/ros/melodic/setup.bash
           

构建软件包的依赖关系

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

测试

打开一个终端

$roscore
           

第二个终端

$rosrun turtlesim turtlesim_node
           

再开起一个终端控制,使用键盘上下左右键控制小乌龟移动

$rosrun turtlesim turtle_teleop_key
           
已 树莓派4b ros 系统 网盘_无限可能:树莓派4B 安装Ubuntu18.04+ROS1(melodic)

此时,使用top命令可以参考系统资源占用情况。从数据看,DDR至少需要2GB,考虑到后续的算法,建议8GB版本。

已 树莓派4b ros 系统 网盘_无限可能:树莓派4B 安装Ubuntu18.04+ROS1(melodic)

至此,树莓派4B上,Ubuntu18.04和ROS1 Melodic安装完成。

可以尽情的在树莓派4B上尝试各种基于ROS的算法了!

继续阅读