Installing Ubuntu 20.04 + ROS noetic on Raspberry Pi 4 (without monitor)

Installing Ubuntu 20.04 + ROS noetic on Raspberry Pi 4 (without monitor)

1. Required equipment

Equipment required:

  • Raspberry Pi 4 Model B

  • wifi

  • microSD card: minimum 32GB

  • MicroSD to SD adapter

  • (Optional) Monitor, mouse, etc.

2. Raspberry Pi image burner

If you don’t have a monitor, you need to use the Raspberry Pi image burner, which can be downloaded from the official website.

Insert image description here

First select the operating system, and then find the Ubuntu Server 20.04.5 version.

Insert image description here
Next, configure the system initialization options:

  • "Turn on SSH service" to enable SSH
  • "Set username"
  • "Configure wifi" (Important): This will enable Wi-Fi and automatically connect to the network + password provided. Of course, this Wi-Fi network should be the same one that your computer is currently connected to, otherwise the rest of this tutorial won't work.

Insert image description here

Then burn and wait.

3. Find the IP address of Raspberry Pi 4

Eject and remove the SD card from the computer. Make sure the Raspberry Pi is powered off (unplug the power cord), place the micro SD card into the appropriate slot, and then power on the Raspberry Pi 4. You should see the green LED on the Pi flash randomly. This means the Pi is booting and working from the SD card. If the green LED does not flash randomly, it may be because the programming operation was unsuccessful and needs to be reprogrammed.

The Pi 4 will attempt to connect to the current Wi-Fi network using the name and password provided.

The next step is to find out what the Raspberry Pi's IP address is within the network.

Notice: If you do not see the Pi address at the beginning of the following steps, wait at least 2 minutes before powering off/on the Raspberry Pi again.

3.1 Windows

Advanced IP Scanner is available for Windows .

All you have to do is click "Scan" and wait.
Insert image description here
You can see that the address of my Raspberry Pi is 192.168.178.40.

3.2 Linux/Freeware

This is usually achieved using nmap (nmap needs to be installed first: sudo apt install nmap).

Start by finding the network IP address and subnet mask. Run the ifconfig command:

$ ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.43.138  netmask 255.255.255.0  broadcast 192.168.43.255
        inet6 fe80::4024:2554:eea4:f97b  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:28:65:38  txqueuelen 1000  (Ethernet)
        RX packets 36560  bytes 42335654 (42.3 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8763  bytes 671459 (671.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 947  bytes 82515 (82.5 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 947  bytes 82515 (82.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

In this example, my Ubuntu host's IP address is 192.168.43.138 and the subnet mask is 255.255.255.0 (24 bits).

Now, use nmap and the data you just fetched:

$ sudo nmap -sP 192.168.43.0/24
Starting Nmap 7.80 ( https://nmap.org ) at 2023-04-26 13:50 CEST
Nmap scan report for _gateway (192.168.43.1)
Host is up (0.015s latency).
MAC Address: 8E:F5:A3:DB:03:27 (Unknown)
Nmap scan report for ubuntu (192.168.43.56)
Host is up (0.049s latency).
MAC Address: DC:A6:32:02:46:50 (Raspberry Pi Trading)
Nmap scan report for LAPTOP-27UBLNO7 (192.168.43.234)
Host is up (0.00057s latency).
MAC Address: 7C:B2:7D:9E:95:DA (Intel Corporate)
Nmap scan report for ed-vm (192.168.43.138)
Host is up.
Nmap done: 256 IP addresses (4 hosts up) scanned in 2.07 seconds

Then we found the Raspberry Pi’s IP address: 192.168.43.56.

3.3 There is a screen

Direct input

$ ip addr 

The output is similar to:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether e4:5f:01:49:a8:b6 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether e4:5f:01:49:a8:b7 brd ff:ff:ff:ff:ff:ff
    inet 192.168.178.40/24 brd 192.168.178.255 scope global dynamic wlan0
       valid_lft 863983sec preferred_lft 863983sec

4. Connect to Raspberry Pi

Open Terminal on Windows, just type "cmd" in the Windows search bar and launch Command Prompt. I used vscode here because it is very suitable for future development and is highly recommended here.

Type the following command:

$ ssh [email protected]

Replace "pi" with any other username entered in the advanced settings of the Raspberry Pi Image Burner. Also, use the IP address you just found in the previous step instead of 192.168.178.40.

You will then see something similar to the following:

The authenticity of host '192.168.178.40 (192.168.178.40)' can't be established.
ED25519 key fingerprint is SHA256:WI67l/jru1i2vEnrHWLbzoV+1s71Dt0AJtg6JBP8faI.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.178.40' (ED25519) to the list of known hosts.
[email protected]'s password:

You need to enter "yes" in the first question and then use the password set in the advanced settings of the burner.

You will then see something similar to the following:

Welcome to Ubuntu 20.04.6 LTS (GNU/Linux 5.4.0-1090-raspi aarch64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Sun Aug  6 10:11:16 UTC 2023

  System load:  0.47               Temperature:            55.0 C 
  Usage of /:   31.3% of 28.94GB   Processes:              168    
  Memory usage: 4%                 Users logged in:        0      
  Swap usage:   0%                 IPv4 address for wlan0: 192.168.178.40    

 * Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
   just raised the bar for easy, resilient and secure K8s cluster deployment.

   https://ubuntu.com/engage/secure-kubernetes-at-the-edge

Expanded Security Maintenance for Applications is not enabled.

183 updates can be applied immediately.
To see these additional updates run: apt list --upgradable

29 additional security updates can be applied with ESM Apps.
Learn more about enabling ESM Apps service at https://ubuntu.com/esm

New release '22.04.2 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


Last login: Thu Jul 20 12:13:32 2023 from 192.168.163.155
pi@ubuntu:~$ 

5. Install ROS noetic

Set sources.list

Set up your computer to accept software from packages.ros.org.

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

This line of command adds the ROS package source to the sources.list file.

sudo apt install curl # if you haven't already installed curl
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -

These two lines of commands install curl (if it is not already installed) and import the public key of the ROS package.

sudo apt update

This line of command updates the list of available packages.

Install desktop version

Everything in ROS-Base and tools like rqt and rviz.

sudo apt install ros-noetic-desktop

This line of command is used to install the ROS desktop version, which includes everything in ROS-Base as well as some tools (such as rqt and rviz).

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

These two lines of commands are used to add ROS environment variables to the bashrc file and load these variables immediately in the current session.

Install packages such as python3-rosdep, python3-rosinstall, python3-rosinstall-generator, python3-wstool and build-essential.

sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential

This line of command is used to install some commonly used ROS dependency tools and basic software packages required for compilation.

Initialize rosdep

Before using many ROS tools, rosdep needs to be initialized. rosdep can easily install system dependencies for source code to be compiled, and some core ROS components require it to run. If rosdep is not installed yet, please install it as follows.

sudo apt install python3-rosdep

This line of command is used to install rosdep.

Execute the following command to initialize rosdep.

sudo rosdep init
rosdep update

These two lines of commands are used to initialize rosdep and obtain the latest rosdep rules.

test

Next, you can run roscore to check the installation of ros.

roscore

Guess you like

Origin blog.csdn.net/qq_37266917/article/details/132133191