Install Ubuntu20.04+ROS-noetic on Raspberry Pi 4b (also applicable to historical versions)


foreword

This article introduces the installation steps of Raspberry Pi to install Ubuntu, and supports various versions of Ubuntu


The following is the text of this article for reference

1. Mirror download

The latest version of Ubuntu (Ubuntu20.04) for Raspberry Pi can be downloaded from the Ubuntu official website
insert image description here

For historical versions of Ubuntu, it is recommended to use the mirror website to download http://cdimage.ubuntu.com/releases/

insert image description here


2. Burning system

1. Insert the TF card, first format the TF card

Just choose a method:

2. Burn image

Method 1. Official burning software Raspberry Pi Imager

Connect to Raspberry Pi Imager
insert image description here
Download and install and open
insert image description here
Select the image to burn in CHOOSE OS Select
insert image description here
the Raspberry Pi Ubuntu image to burn
Select the TF card to burn and burn
insert image description here

Method 2. Win32DiskImager


3. After burning, the system will prompt that the U disk needs to be formatted, and it must not be formatted at this time! ! ! , eject the TF card, insert the Raspberry Pi, and initialize the system


3. System initialization

It is recommended to use a monitor, mouse and keyboard, which will be much simpler

1. Initial login

After the system is initialized, you will be prompted to enter the user name and password. The user name and password here are both ubuntu

2. Change password

After logging in for the first time, the system will prompt to change the password

提示输入当前用户名current user,输入ubuntu
接下来输入两次新密码,完成密码修改

3. Change domestic sources

If you change your country, you can download software and dependencies faster

1. Search commonly used domestic sources, such as Tsinghua source, Ali source, Zhongke University source

Aliyuan Aliyuan is selected here

2. Change source.listthe file

First of all source.list, the backup is used for source.listfile restoration,

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

If you want to source.listrestore

sudo cp /etc/apt/sources.list.bak /etc/apt/sources.list

Terminal input, open source.listfile

sudo nano /etc/apt/sources.list

Replace all URLs in it with http://mirrors.aliyun.com/ubuntu-ports/
the final effect

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiv>

deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe m>
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted univer>

deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe mu>
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted univers>

deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe m>
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted univer>

deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe >
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted unive>

implement

sudo apt-get updata
sudo apt-get upgrade

If no error is reported, the source change is successful


Fourth, install the desktop environment

sudo apt-get install ubuntu-desktop

Restart the system to see the Ubuntu classic desktop

roboot

5. Install the ROS environment

1. Add ROS software source and import Key

It is recommended to use domestic software sources here. The ROS download file is large and takes a long time. Using domestic ROS software sources can reduce the ROS download time.
How to use the domestic ROS software source can be queried on the official website of the software source:


Take the software source of University of Science and Technology of China as an example:
在web中搜索中科大源

insert image description here

找到ros,点击右侧Help

insert image description here

#按照提示安装即可
#添加软件源
sudo sh -c 'echo "deb https://mirrors.ustc.edu.cn/ros/ubuntu $(lsb_release -sc) 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 update

insert image description here

2. Install the desktop full version

sudo apt install ros-noetic-desktop-full

The installation process takes a long time, so be patient.

3. Set environment variables

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

4. ROS initialization

It is not recommended to use the official rosdepinitialization tutorial here, as it is prone to problems such as failure to connect, and the success rate of using domestic sources is higher. Here I use Xiaoyu ROS to solve the initialization method, and the success rate is higher.

sudo apt-get install python3-pip

insert image description here

sudo pip install rosdepc
sudo rosdepc init

insert image description here

rosdepc update

insert image description here

5. ROS test (roscore and little turtle)

(1) roscore test

roscore

insert image description here

(2)rosrun turtlesim turtlesim_node

rosrun turtlesim turtlesim_node
打开小海龟仿真界面

(3)rosrun turtlesim turtle_teleop_key

rosrun turtlesim turtle_teleop_key
通过键盘控制小海龟运动

insert image description here
Seeing the movement of the little turtle means that the ROS installation is successful.

Guess you like

Origin blog.csdn.net/m0_52064995/article/details/121043079