# Install ROS Melodic Morenia on Raspberry pi 4B
According to only Ubuntu 19.10 can be use in Raspberry pi 4 .
but Ros only could install on Ubuntu 18.04 LTS ( ROS will not support NLTS anymore).
To get the method is Twists and turns bCuz information in internet for install ROS on Raspberry pi 4 is rarely that make me write this article.
## Step 1 Update Bootloader Firmware First (using Raspbian)!
If you have multiple SD cards ,Using this method you can periodically swap out the card and install the latest firmware updates to your Pi 4 and then switch right back to Ubuntu.
one Feasible method is
#### 1.Download Raspbian image
download Raspbian Buster Lite from https://www.raspberrypi.org/downloads/raspbian/
#### 2.Write to sd card
Unzip the file you downloaded and burn it to your sd card.
Then insert your SD card into the Pi 4 and start it up!
I'm use Win32DiskImager.
#### 3.Update Bootloader Firmware
install the latest firmware using this command:
```bash
sudo apt-get update && sudo apt-get dist-upgrade -y
sudo rpi-update
```
Next we are going to check for bootloader updates. We do this using the new rpi-eeprom utility. The following command will check for updates:
```bash
sudo rpi-eeprom-update -a
```
## Step 2 Installed Revised Image
if you are not want to use this Preinstalled Image maybe you can get some information on
https://medium.com/@RouYunPan/%E6%A8%B9%E8%8E%93%E6%B4%BE4-%E5%AE%89%E8%A3%9D-ubuntu-mate-18-04-ee50fd2647ea
to make ur ubuntu Revision.
warning : this is UnOfficial.
#### Download Prebuilt Ubuntu 18.04.3 image
download ubuntu-18.04.3-preinstalled-server-arm64+raspi4.img.xz from
https://github.com/TheRemote/Ubuntu-Server-raspi4-unofficial/releases
#### 2.Write to sd card
Unzip the file you downloaded and burn it to your sd card.
( maybe another sd card or overwrite the sd card you burned Raspbian )
I'm use Win32DiskImager.
#### Log in
```bash
Username: ubuntu
Password: ubuntu
```
## Step 3 Installed ROS Melodic Morenia
Just install ,Step description copy from http://wiki.ros.org/melodic/Installation/Ubuntu
#### Setup your sources.list
Setup your computer to accept software from packages.ros.org.
```bash
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
```
#### Set up your keys
```bash
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
```
If you experience issues connecting to the keyserver, you can try substituting hkp://pgp.mit.edu:80 or hkp://keyserver.ubuntu.com:80 in the previous command.
Alternatively, you can use curl instead of the apt-key command, which can be helpful if you are behind a proxy server:
```bash
curl -sSL 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xC1CF6E31E6BADE8868B172B4F42ED6FBAB17C654' | sudo apt-key add -
```
#### Installation
- First, make sure your Debian package index is up-to-date:
```
sudo apt update
```
There are many different libraries and tools in ROS. We provided four default configurations to get you started. You can also install ROS packages individually.
In case of problems with the next step, you can use following repositories instead of the ones mentioned above [ros-shadow-fixed](http://wiki.ros.org/ShadowRepository)
- Desktop-Full Install: (Recommended) : ROS, rqt, rviz, robot-generic libraries, 2D/3D simulators and 2D/3D perception
```bash
sudo apt install ros-melodic-desktop-full
```
or [click here](apt:ros-melodic-desktop-full?refresh=yes)
- Desktop Install: ROS, rqt, rviz, and robot-generic libraries
```bash
sudo apt install ros-melodic-desktop
```
or [click here](apt:ros-melodic-desktop?refresh=yes)
- ROS-Base: (Bare Bones) ROS package, build, and communication libraries. No GUI tools.
```bash
sudo apt install ros-melodic-ros-base
```
or [click here](apt:ros-melodic-ros-base?refresh=yes)
- Individual Package: You can also install a specific ROS package (replace underscores with dashes of the package name):
```bash
sudo apt install ros-melodic-PACKAGE
```
e.g.
```bash
sudo apt install ros-melodic-slam-gmapping
```
To find available packages, use:
```bash
apt search ros-melodic
```
#### Initialize rosdep
Before you can use ROS, you will need to initialize rosdep. rosdep enables you to easily install system dependencies for source you want to compile and is required to run some core components in ROS.
```bash
sudo rosdep init
rosdep update
```
#### Environment setup
- It's convenient if the ROS environment variables are automatically added to your bash session every time a new shell is launched:
```bash
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
```
If you have more than one ROS distribution installed, ~/.bashrc must only source the setup.bash for the version you are currently using.
- If you just want to change the environment of your current shell, instead of the above you can type:
```bash
source /opt/ros/melodic/setup.bash
```
- If you use zsh instead of bash you need to run the following commands to set up your shell:
```bash
echo "source /opt/ros/melodic/setup.zsh" >> ~/.zshrc
source ~/.zshrc
```
#### Dependencies for building packages
Up to now you have installed what you need to run the core ROS packages. To create and manage your own ROS workspaces, there are various tools and requirements that are distributed separately. For example, rosinstall is a frequently used command-line tool that enables you to easily download many source trees for ROS packages with one command.
To install this tool and other dependencies for building ROS packages, run:
```bash
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
```
#### Build farm status
The packages that you installed were built by the [ROS build farm](http://build.ros.org/). You can check the status of individual packages [here](http://repositories.ros.org/status_page/ros_melodic_default.html).
## Step 3 Installed ROS 2 brige Melodic Morenia
---
- Refrence
- https://www.raspberrypi.org/downloads/raspbian/
- http://wiki.ros.org/melodic/Installation/Ubuntu
- https://jamesachambers.com/raspberry-pi-4-ubuntu-server-desktop-18-04-3-image-unofficial/
- https://github.com/TheRemote/Ubuntu-Server-raspi4-unofficial/releases
- https://medium.com/@RouYunPan/%E6%A8%B9%E8%8E%93%E6%B4%BE4-%E5%AE%89%E8%A3%9D-ubuntu-mate-18-04-ee50fd2647ea
- https://index.ros.org/doc/ros2/Installation/Dashing/Linux-Install-Binary/