# Install ROS on RPi ###### tags: `RPi` `ROS` :exclamation: **Remember to mannully update it periodically** :exclamation: [ToC] ## 1. Install OS ### Step 1: Install Raspberry Pi Imager - Download from here: https://www.raspberrypi.org/software/ - Install on your PC ### Step 2: Write to SD card 1. Choose OS: Chose "Raspberry Pi OS" but **be sure to install the right version!!** :star:<font color="#f00">**Check the current OS version is compatable with the current ROS version** ex. This Tutorial Version Pi OS: Debian Buster(10) <-> ROS: Noetic</font> 3. Choose storage 4. Choose setting to setup: 1. Device name 2. enable SSH 3. setup username and password 4. setup wifi (use 2.4GHz not 5GHz) 6. Write and wait till it finished! ### Step 3: Install it onto Rpi - If you set the wifi up in the Imager, you can skip this step and Rpi should automatically connects to wifi. :star:**Be sure to connect all peripheral first** - Connect Power to Rpi and follow the step it told you - If you want to use SSH, turn it on in the *Preferences->Raspberry Pi Configuration->Interface* - If you want to use [tmux](https://andyyou.github.io/2017/11/27/tmux-notes/), just the command ```$ sudo apt install tmux``` ## 2.Install ROS *this hackmd refer to this Official Guide: https://wiki.ros.org/noetic/Installation/Source & http://wiki.ros.org/ROSberryPi/Installing%20ROS%20Melodic%20on%20the%20Raspberry%20Pi this hackmd use noetic for example* ### Step 1: Prerequisites 1. ```$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'``` 3. ```$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654``` 4. ```$ sudo apt-get update``` ```$ sudo apt-get upgrade``` 6. ```$ sudo apt-get install python3-rosdep python3-rosinstall-generator python3-vcstool build-essential``` 7. ```$ sudo rosdep init``` ```$ rosdep update``` ### Step 2: Installation #### 2.1 Create a catkin Workspace :star:<font color="#f00"> This workspace is for install and update ROS only!**DO NOT PUT YOU CODE IN IT!!** Make another workspace!!!</font> 1. ```$ mkdir ~/ros_catkin_ws``` ```$ cd ~/ros_catkin_ws``` - **Name the workspace "ros_catkin_workspace"** so that people know it is for ROS install and update. 2. ```$ rosinstall_generator desktop --rosdistro noetic --deps --tar > noetic-desktop.rosinstall``` ```$ mkdir ./src``` ```$ vcs import --input noetic-desktop.rosinstall ./src``` #### 2.2 Resolving Dependencies ```$ rosdep install --from-paths ./src --ignore-packages-from-source --rosdistro noetic -y``` #### 2.3 Building the catkin Workspace 1. ```$ sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=/usr/bin/python3 --install-space /opt/ros/noetic``` 2. ```$ source /opt/ros/noetic/setup.bash``` 3. ```$ echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc``` - <font color="#f00">Downloading ROS complete!! </font> ## 3. **Maintaining** a Source Checkout - <font color="#f00"> This steps is to update ROS, **NOT TO INSTALL**. If you're trying to install ROS, you don't have to do these steps.</font> ### Step 1: Update your rosinstall file 1. ```$ mv -i noetic-desktop.rosinstall noetic-desktop.rosinstall.old``` 2. Generate New Rosinstall File: ```$ rosinstall_generator desktop --rosdistro noetic --deps --tar > noetic-desktop.rosinstall``` 3. Compare ```$ diff -u noetic-desktop.rosinstall noetic-desktop.rosinstall.old``` ### Step 2: Download the latest sources If you're satisfied with these changes, incorporate the new rosinstall file into the workspace and update your workspace: ```$ vcs import --input noetic-desktop.rosinstall ./src``` ### Step 3: Rebuild your workspace ```$ sudo ./src/catkin/bin/catkin_make_isolated --install -DPYTHON_EXECUTABLE=/usr/bin/python3 --install-space /opt/ros/noetic``` ```$ source /opt/ros/noetic/setup.bash``` ## Setup WIFI on Raspberry Pi There are two ways to setup wifi on raspberry pi: 1. `sudo raspi-config` 2. sudo vim /etc/wpa_supplicant/wpa_supplicant.conf`` ```shell= network-{ ssid="ORCA_FR" psk="nctu-auv" } ``` ### Set static ip 1. `sudo vim /etc/dhcpcd.conf` 2. edit "dhcpcd.conf" file ```shell= interface wlan0 static ip_address=192.168.1.123/24 static routers=192.168.0.1 static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1 ``` >Refernce: https://raspberrytips.com/raspberry-pi-wifi-setup/