For cost reasons, they have selected the Raspberry Pi 3 Model A+; however I have some concerns about whether this has the performance needed for the project. As an early test case, I want to document what steps need to be taken to get ROS (Robot Operating System) running on the R-Pi.
What is ROS?
From www.ros.org:
"The Robot Operating System (ROS) is a set of software libraries and tools that help you build robot applications. From drivers to state-of-the-art algorithms, and with powerful developer tools, ROS has what you need for your next robotics project. And it's all open source."
The latest release of ROS is "Melodic Morenia" and is built for Ubuntu Linux; it is also possible to install ROS onto Raspbian, which we will attempt here.
R-Pi Features and Limitations
The $25 Raspberry Pi 3 Model A+ (https://www.raspberrypi.org/products/raspberry-pi-3-model-a-plus) has the following specs:
- Extends the Raspberry Pi 3 range into the A+ board format.
- Broadcom BCM2837B0, Cortex-A53 (ARMv8) 64-bit SoC @ 1.4GHz
- 512MB LPDDR2 SDRAM
- 2.4GHz and 5GHz IEEE 802.11.b/g/n/ac wireless LAN, Bluetooth 4.2/BLE
- Extended 40-pin GPIO header
- Full-size HDMI
- Single USB 2.0 port
- CSI camera port for connecting a Raspberry Pi Camera Module
- DSI display port for connecting a Raspberry Pi Touch Display
- 4-pole stereo output and composite video port
- Micro SD port for loading your operating system and storing data
- 5V/2.5A DC power input
The biggest limitations are the amount of SDRAM, followed by the ARMv8 performance. Also only having a single USB port will limit the peripherals we can connect without an external hub.
Our initial hardware components are:
- Raspberry Pi 3 Model A+
- 16GB Class 10 micro SD card
- 5V/2.5A micro-USB power supply
- Video monitor
- HDMI input preferred
- If VGA input only, you will need an HDMI to VGA adapter
- Wired USB keyboard
- While it is possible to install using just a keyboard, a mouse makes life easier
- You can use a keyboard with a built-in track pad
- Connect a USB hub to the model A+ to add more ports
- A keyboard with a USB port for a mouse
- A monitor with a USB port to connect a keyboard and a mouse
- A stand-alone hub with ports for more devices
- The Model A+ has built-in WiFi which we will use to connect to the Internet
Installing Raspbian
In an earlier blog post, we walked through how to set up a Raspberry Pi as a headless system; in this article we will have a keyboard and display, and can use the Raspbian keyboard shortcuts instead of a mouse to access the desktop GUI.
Install the operating system image
Rather than downloading an OS image and using a third party app (e.g. Balena Etcher) to burn the image onto the SD card, we will instead use the Raspberry Pi Imager. This is easiest to use if you only want the OS latest release (in this case "buster") and want to overwrite files on the SD card without having to manually delete its existing disk partitions.- Download Raspberry Pi Imager
- Insert the micro-SD card into a card reader on your computer
- Run the executable and under the 'Operating System" selection, choose
- 'Erase' to format the SD card
- 'Raspbian' to get the recommended Raspberry Pi Desktop
- Close the Imager and eject the SD card
Setup the Pi
- Insert the micro SD card that has the OS image on it into the Pi's card slot
- Plug in your devices
- HDMI video cable
- USB keyboard
- Micro-USB power
- Turn on the power
- Once the system boots into the desktop GUI, follow the wizard's prompts to complete setup.
- Select your country/language/timezone/keyboard
- Change the 'pi' user password
- Set up screen size if needed
- Select a WiFi network
- Enter the WiFi password and connect to the network
- Update software
- After updates complete, restart the Raspberry Pi and login to the GUI
- If you did not successfully update the OS during installation, you can do so manually:
- From the GUI, open a CLI terminal session: <CTRL> + <ALT> + t
- Run the commands
$ sudo apt update $ sudo apt dist-upgrade $ sudo apt clean
- Setup remote access for headless operation:
- From the GUI, open a CLI terminal session: <CTRL> + <ALT> + t
- Use 'sudo' to run 'raspi-config'
- Change the user password if needed
- Update network connection options
- Select 'Interfacing Options' to
- Enable SSH
- Enable VNC
- You can find the ip addess for the Raspberry Pi with the command 'hostname -I'
- Since the Model A+ only has 512MB of ram, you will need to increase swap:
- Check swap size by running the CLI command 'free -h'
- Edit the /etc/dphys-swapfile to set CONF_SWAPSIZE=1024
- Reboot the Raspberry Pi for this to take effect.
- Confirm swap change by re-running 'free -h'
Installing ROS
ROS is originally targeted for Ubuntu, so we will need to build from source to run on Raspbian.
We will be working in our default directory "/home/pi" and following the steps detailed here: http://wiki.ros.org/ROSberryPi to install ROS Melodic on Raspbian Buster :
We will be working in our default directory "/home/pi" and following the steps detailed here: http://wiki.ros.org/ROSberryPi to install ROS Melodic on Raspbian Buster :
- From the GUI
- Open a CLI terminal session: <CTRL> + <ALT> + t
- Execute the commands listed in the guide to:
- Configure prerequisites
- Setup ROS Repositories and keys
$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
$ sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
$ sudo apt-get update $ sudo apt-get upgrade
- Install Bootstrap Dependencies
$ sudo apt install -y python-rosdep python-rosinstall-generator python-wstool python-rosinstall build-essential cmake
- Initialize rosdep
$ sudo rosdep init $ rosdep update
- Install ROS
- Create a catkin workspace
$ mkdir -p ~/ros_catkin_ws $ cd ~/ros_catkin_ws
- Fetch the core packages for either
- ROS-Comm (a basic configuration that has been tested)
$ rosinstall_generator ros_comm --rosdistro melodic --deps --wet-only --tar > melodic-ros_comm-wet.rosinstall $ wstool init src melodic-ros_comm-wet.rosinstall
- ROS Desktop (GUI configuration)
$ rosinstall_generator desktop --rosdistro melodic --deps --wet-only --tar > melodic-desktop-wet.rosinstall $ wstool init src melodic-desktop-wet.rosinstall
- Resolve dependencies by running rosdep
$ cd ~/ros_catkin_ws $ rosdep install -y --from-paths src --ignore-src --rosdistro melodic -r --os=debian:buster
- Build the catkin workspace using 'catkin_make_isolated' with the '-j1' option to limit the number of CPU threads used on the ARMv8 core
$ sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/melodic -j1
- Wait a long time for almost 200 packages to compile... :-)
- Once the install is complete, configure your environment
$ source /opt/ros/melodic/setup.bash
- You can also setup your bash shell to always have variables set correctly:
$ echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc