Using Raspberry Pi 4, With Ubuntu , Ros , Rplidar , Arduino

Introduction: Using Raspberry Pi 4, With Ubuntu , Ros , Rplidar , Arduino

Raspberry Pi 4 is the version of the Raspberry Pi single-board computer. 2GB, 4GB, and 8GB RAM version of Raspberry Pi 4. in this project we description

Download 3 different versions of ubuntu (16..04,18.04,20.04) ,Install of ROS and Using (RPlidar & arduino)

Step 1: Components

1- A Raspberry pi 4 (8GB)

2- A 16GB or higher capacity microSD card

3- A keyboard and a mouse

4- A micro-HDMI to HDMI cable

5- wired network for connecting the Raspberry Pi to the internet(Ethernet)

6-A USB Type-C power adapter for Raspberry Pi 4

7- RPlidar

8- Cable

9-Arduino

Step 2: Download Ubuntu 16.04

To Download we chose 2020-11-07-ubiquity-xenial-lxde

Step 3:

Step 4: Start With Ubuntu 16.04

This system has already Ros kinetic. Therefore, we started with Connect to the WiFi

network that starts with ubiquityrobot. Password is robotseverywhere.

Go to Terminal, and connect to your Pi using ssh ubuntu@10.42.0.1. Password

is ubuntu. Then run

sudo systemctl disable magni-base 

to ensure that startup scripts are disabled.

Run roscore to make sure that things are working properly.

roscore

If you get warning/errors, try stopping ROS and starting it again with

  killall -9 roscore

Run

   roscore

Step 5: Cmake Upgrade

So we will start by install the cmake 3.7.2 Installation by a PPA (Upgrade to 3.7)

Open terminal and run:

sudo apt-get install software-properties-common
sudo add-apt-repository
ppa:george-edison55/cmake-3.x
sudo apt-get update

When cmake is not yet installed

sudo apt-get install cmake 3.7.2

When cmake is already installed

sudo apt-get upgrade
sudo apt-get install build-essential
wget http://www.cmake.org/files/v3.7/cmake-3.7.2.tar.gz
tar xf cmake-3.7.2.tar.gz
cd cmake-3.7.2
./configure
make
sudo apt-get install checkinstall
sudo checkinstall
sudo make install

Step 6: Rplidar Kinetic Installation

cd catkin_ws
cd src
git clone  https://github.com/Slamtec/rplidar_ros.git
cd ..
catkin_make

Check the authority of rplidar's serial-port

ls -l /dev |grep ttyUSB

Add the authority of write: (such as /dev/ttyUSB0)

sudo chmod 666 /dev/ttyUSB0

Start a rplidar node and view the scan result in rviz.

roslaunch rplidar_ros view_rplidar.launch  

Step 7: Hector Slam

The hector-mapping nodes depend on Qt4, so you

need to install it first.

sudo apt-get install qt4-qmake qt4-dev-tools

Move into catkin_ws/src, clone the source files and then make them

cd catkin_ws
cd src
git clone  https://github.com/tu-darmstadt-ros-pkg/hector_sl...
cd ..
catkin_make

For a quick test of the hector_mapping two launch files needs to be modified.

Edit the "mapping_default.launch" file

Go to home file > catkin_ws > src >hector_ slam > hector _mapping

>launch > mapping_default.launch

Step 8:

Modify the third line to this

<arg name="base_frame" default="base_link"/> 

And the fourth line to this.

<arg name="odom_frame" default="base_link"/>

The last line to this

<node pkg="tf" type="static_transform_publisher" name="base_to_laser_broadcaster" args="0 0 0 0 0 0 base_link laser 100" />

Step 9: Another File Modify

Go to home file > catkin_ws > src > hector_ slam > hector _ slam_launch >launch > tutorial.launch

<param name="/use_sim_time" value="false"/>

To start the mapping process use

roslaunch hector_slam_launch tutorial.launch  

NOTE: when you want to start the mapping process you should run the Rivs in another terminal.

roslaunch rplidar_ros view_rplidar.launch

Step 10: Ubuntu 18.04 System and Working

ubuntu 18.04 download https://drive.google.com/file/d/1SrAIRisa-3Kgf6duKMk6_3oEisxO-nb8/view?usp=sharing

We started by installing the Ubuntu LTS 18.04 (32bit) Image by balenaEtcher

Application to flash the Ubuntu image on the SD card (16GB).Then we connected

the Ethernet to install the Ubuntu on raspberry pi 4, after finish Installation it's

prompted to log in, we used “ubuntu” for the username , password and current password.

Then It asked to change this default password after log in.

Finally, we used 3 codes to run the Ubuntu:

sudo apt-get update
sudo apt-get install xubuntu-desktop     
sudo reboot

This code for check version

lsb_release –a

Step 11: ROS (Robot Operation System) Installation

There are two types of ROS (ROS1.ROS2). We are using ROS (1) ,another thing the ROS has several versions, It is related to the version of the system you are using , so we chose the ROS melodic which is available on Ubuntu 18.04 version

we sheared the code from

We followed steps of this video

So the code we used will be written below :

Note: you should write the important code in the table before run any code from ros wiki Website.

cd /

The cd (“change directory”) command is used to change the current working directory in Linux and other Unix-like operating systems. It is one of the most basic and frequently used commands when working on the Linux terminal. ... Each time you interact with your command prompt, you are working within a directory.

sudo sh -c 'echo "deb <a href="http://packages.ros.org/ros/ubuntu" rel="nofollow">http://packages.ros.org/ros/ubuntu </a> $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update
sudo apt install ros-melodic-desktop-full
sudo apt-get install python-pip
sudo pip install –U rosdeb
sudo rosdep init
rosdep update
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential

Note: You have successfully installed ROS , if you would like to make sure if the ROS Working open the terminal again and just write

 roscore

Step 12: RPLiDAR Ubuntu 18.04

We Connected our RPLiDAR to Raspberry Pi 4 Model B using Micro USB Cable. Flashing green light indicates normal activity of sensor. Following command line to check the permissions:

Open your terminal and run the following command.

ls -l /dev | grep ttyUSB

Output of the following command must be:

crw-rw---- 1 root dialout 188, 0 Jan 3 14:59 ttyUSB

Run below command to change permission:

sudo chmod 666 /dev/ttyUSB0

Now you are able to read and write with this device using the USB port.

Install the following dependencies. Open a new terminal and type:

sudo apt-get install cmake python-catkin-pkg python-empy python- nose python-setuptools libgtest-dev python-rosinstall python- rosinstall-generator python-wstool build-essential git

Create the catkin root and source folders

mkdir -p ~/catkin_ws/src

This workspace can be compiled even it is empty. Go to the source folder of the catkin workspace that you just created In your terminal, run

cd ~/catkin_ws/src

Clone the github repository of RPLIDAR ROS package.

git clone https://github.com/robopeak/rplidar_ros.git

And then

cd ~/catkin_ws

Then, run catkin_make to compile your catkin workspace.

catkin_make

Then run to source the environment with your current terminal. Don't close the terminal.

source devel/setup.bash

To start ROS, run the following command in a new terminal:

roscore

In the terminal which you sourced the environment, run below command

roslaunch rplidar_ros view_rplidar.launch

An instance of Rviz will then open with a map of the RPLIDAR’s surroundings.

Step 13: Hector Slam Ubuntu 18.04

The hector-mapping nodes depend on Qt4, so you need to install it first.

sudo apt-get install qt4-qmake qt4-dev-tools

Move into catkin_ws/src, clone the source files and then make them

cd ~/catkin_ws/src
git clone  https://github.com/tu-darmstadt-ros-pkg/hector_sl...
cd ~/catkin_ws
catkin_make

You have to go back to step 7 and do same thing to modify the files

Step 14: Arduino With Melodic

Start with Arduino IDE installed, download it from the Arduino website Go to software > download > in the right side choose linux32 ,After finish, extract the file on download.

Open the terminal and write this code :

sudo apt-get install ros-melodic-rosserial-arduino

To Install the IDE :

  cd Downloads
  cd arduino-1.8.13
  sudo ./install.sh

Then

cd catkin_ws 
cd src
git clone  https://github.com/ros-drivers/rosserial.git
cd catkin_ws
catkin_make
catkin_make install

Install ros_lib into the Arduino Environment

cd snap  
cd arduino 
cd current 
cd arduino
cd libraries 
rm -rf ros_lib
rosrun rosserial_arduino make_libraries.py

Step 15: Ubuntu 20.04 Download

Download here

To install Ubuntu 20.04 LTS on Raspberry Pi 4, you need to download the Ubuntu Server 20.04 LTS image for Raspberry Pi. The Ubuntu Server 20.04 LTS Raspberry Pi image is available on the Official website of Ubuntu.

NOTE: If you’re using the 2GB or 4GB version of Raspberry Pi 4, then download the 32-bit Ubuntu 20.04 LTS image. If you’re using the 8GB version of Raspberry Pi 4, then download the 64-bit Ubuntu 20.04 LTS image.

First, connect a
network cable to the Ethernet port of your Raspberry Pi 4

The default username is ubuntu and the password is ubuntu

Once you log in, you will be asked to enter your current password.

Type in ubuntu and press .

Ubuntu 20.04 LTS will ask you to enter a new password.

Type in a new password and press .

Retype the password and press

Step 16: Upgrading Ubuntu 20.04 LTS Packages

First, update the APT package repository cache with the following command

sudo apt update

To update all the existing packages, run the following command:

sudo apt upgrade

For the changes to take effect, reboot the Raspberry Pi 4 with the following command:

sudo systemctl reboot

Step 17: Desktop

Reference

Installing Ubuntu Desktop on the Raspberry Pi 4

sudo apt install ubuntu-desktop

For the changes to take effect, reboot your Raspberry Pi 4 with the following command:

sudo systemctl reboot

Step 18: Installation Ros Ubuntu 20.04

Setup 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'

Set up your keys

sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

First, make sure your package index is update

sudo apt update

Desktop-Full Install:

sudo apt install ros-noetic-desktop-full

You must source this script in every bash terminal you use ROS in.

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

Step 19: Install Build Dependencies on Raspberry Pi 4

Now we are finally ready to install Noetic on your Raspberry Pi 4.

sudo apt update 
apt search ros-noetic

We will first install all dependencies:

sudo apt-get install -y python3-rosdep python3-rosinstall-generator python3-wstool python3-rosinstall build-essential cmake

The dependencies here include ROS specific tools (rosdep, rosintall_generator and ws_tool) and some essential build tools like make and cmake.

Step 20: Set Up ROS Noetic Dependency Sources/repos

First, we initialize rosdep, which is a ROS tool for installing dependencies:

sudo rosdep init

You should see the following output after it’s done:

Wrote /etc/ros/rosdep/sources.list.d/20-default.list

Recommended: please run

     rosdep update

Next we run rosdep update to fetch package information from the repos that are just initialized.

rosdep update

Install ROS Noetic dependencies

mkdir ~/ros_catkin_ws
cd ~/ros_catkin_ws

Desktop Install here

rosinstall_generator desktop --rosdistro noetic --deps --wet-only --tar > noetic-desktop-wet.rosinstall
wstool init src noetic-desktop-wet.rosinstall
wstool update -j8 -t src
rosdep install -y --from-paths src --ignore-src --rosdistro noetic -r --os=debian:buster

Compiling Noetic packages on Raspberry Pi 4

sudo src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/noetic -j2 -DPYTHON_EXECUTABLE=/usr/bin/python3

It takes around 1 hour for compilation process

Step 21: RPLiDAR Ubuntu 20.04

Open your terminal and run the following command.

ls -l /dev | grep ttyUSB

Output of the following command must be:

crw-rw----  1 root   dialout 188,   0 Jan  3 14:59 ttyUSB

Run below command to change permission:

sudo chmod 666 /dev/ttyUSB0

Install RPLIDAR ROS Package

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/

Configure the catkin workspace

catkin_init_workspace

And source it to bashrc:

echo "source $HOME/catkin_ws/devel/setup.bash" >> ~/.bashrc

Okay, we’re ready to start installing RPLIDAR ROS package.

Go to the source folder of the catkin workspace that you just created:

cd src

Clone the ROS node for the Lidar in the catkin workspace.

sudo git clone   https://github.com/Slamtec/rplidar_ros.git

After that build with catkin.

cd ~/catkin_ws/

Run catkin_make to compile your catkin workspace.

catkin_make

Then run to source the environment with your current terminal. Don't close the terminal.

source devel/setup.bash

and launch RPILIDAR launch file

roslaunch rplidar_ros rplidar.launch

Step 22: References:

Be the First to Share

    Recommendations

    • Raspberry Pi Contest

      Raspberry Pi Contest
    • One Board Contest

      One Board Contest
    • Anything Goes Contest 2021

      Anything Goes Contest 2021

    4 Comments

    0
    RonB25
    RonB25

    Question 2 months ago on Step 7

    Hi very good project.
    I cannot download qt4-qmake qt4-dev-tools. error qt4-qmake is not available

    0
    GokudoG
    GokudoG

    3 months ago

    Many thanks. I made it with raspberry pi 3