instructables
Using Raspberry Pi 4, With Ubuntu , Ros , Rplidar , Arduino
by s.a.alghamdi94
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 di erent 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
Using Raspberry Pi 4, With Ubuntu , Ros , Rplidar , Arduino: Page 1
7- RPlidar
8- Cable
9-Arduino
Step 2: Download Ubuntu 16.04
To Download we chose 2020-11-07-ubiquity-xenial-lxde
Step 3:
Using Raspberry Pi 4, With Ubuntu , Ros , Rplidar , Arduino: Page 2
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@[Link]. 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:
Using Raspberry Pi 4, With Ubuntu , Ros , Rplidar , Arduino: Page 3
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 [Link]
tar xf [Link]
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 [Link]
cd ..
catkin_make
Check the authority of rplidar's serial-port
Using Raspberry Pi 4, With Ubuntu , Ros , Rplidar , Arduino: Page 4
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
Using Raspberry Pi 4, With Ubuntu , Ros , Rplidar , Arduino: Page 5
Step 7: Hector Slam
The hector-mapping nodes depend on Qt4, so you
need to install it rst.
Using Raspberry Pi 4, With Ubuntu , Ros , Rplidar , Arduino: Page 6
sudo apt-get install qt4-qmake qt4-dev-tools
Move into catkin_ws/src, clone the source les and then make them
cd catkin_ws
cd src
git clone [Link]
cd ..
catkin_make
For a quick test of the hector_mapping two launch les needs to be modi ed.
Edit the "mapping_default.launch" le
Go to home le > 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"/>
Using Raspberry Pi 4, With Ubuntu , Ros , Rplidar , Arduino: Page 7
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 le > catkin_ws > src > hector_ slam > hector _ slam_launch >launch > [Link]
<param name="/use_sim_time" value="false"/>
To start the mapping process use
roslaunch hector_slam_launch [Link]
NOTE: when you want to start the mapping process you should run the Rivs in another terminal.
roslaunch rplidar_ros view_rplidar.launch
Using Raspberry Pi 4, With Ubuntu , Ros , Rplidar , Arduino: Page 8
Step 10: Ubuntu 18.04 System and Working
ubuntu 18.04 download [Link] le/d/1SrAIRisa-3Kgf6duKMk6_3oEisxO-nb8/view?usp=sharing
We started by installing the Ubuntu LTS 18.04 (32bit) Image by balenaEtcher
Application to ash the Ubuntu image on the SD card (16GB).Then we connected
the Ethernet to install the Ubuntu on raspberry pi 4, after nish 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
Using Raspberry Pi 4, With Ubuntu , Ros , Rplidar , Arduino: Page 9
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="[Link] rel="nofollow">[Link] </a> $(lsb_release -sc) main" > /etc/apt/[Link].d/ro
[Link]'
sudo apt-key adv --keyserver 'hkp://[Link]' --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/[Link]" >> ~/.bashrc
Using Raspberry Pi 4, With Ubuntu , Ros , Rplidar , Arduino: Page 10
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-ess
ential 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 [Link]
And then
Using Raspberry Pi 4, With Ubuntu , Ros , Rplidar , Arduino: Page 11
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/[Link]
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 rst.
sudo apt-get install qt4-qmake qt4-dev-tools
Move into catkin_ws/src, clone the source les and then make them
cd ~/catkin_ws/src
git clone [Link]
cd ~/catkin_ws
catkin_make
You have to go back to step 7 and do same thing to modify the les
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 nish, extract the le on download.
Using Raspberry Pi 4, With Ubuntu , Ros , Rplidar , Arduino: Page 12
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 ./[Link]
Then
cd catkin_ws
cd src
git clone [Link]
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
Using Raspberry Pi 4, With Ubuntu , Ros , Rplidar , Arduino: Page 13
Download here The default username is ubuntu and the password is
ubuntu
To install Ubuntu 20.04 LTS on Raspberry Pi 4, you need
to download the Ubuntu Server 20.04 LTS image for Once you log in, you will be asked to enter your current
Raspberry Pi. The Ubuntu Server 20.04 LTS Raspberry Pi password.
image is available on the O cial website of Ubuntu.
Type in ubuntu and press .
NOTE: If you’re using the 2GB or 4GB version of
Raspberry Pi 4, then download the 32-bit Ubuntu 20.04 Ubuntu 20.04 LTS will ask you to enter a new password.
LTS image. If you’re using the 8GB version of Raspberry
Pi 4, then download the 64-bit Ubuntu 20.04 LTS image. Type in a new password and press .
First, connect a Retype the password and press
network cable to the Ethernet port of your Raspberry Pi
4
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
Using Raspberry Pi 4, With Ubuntu , Ros , Rplidar , Arduino: Page 14
For the changes to take e ect, 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 e ect, 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 [Link].
sudo sh -c 'echo "deb [Link] $(lsb_release -sc) main" > /etc/apt/[Link].d/[Link]'
Set up your keys
sudo apt-key adv --keyserver 'hkp://[Link]' --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/[Link]
echo "source /opt/ros/noetic/[Link]" >> ~/.bashrc·
source ~/.bashrc
Using Raspberry Pi 4, With Ubuntu , Ros , Rplidar , Arduino: Page 15
Step 19: Install Build Dependencies on Raspberry Pi 4
Now we are nally ready to install Noetic on your Raspberry Pi 4.
sudo apt update
apt search ros-noetic
We will rst 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 speci c 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/[Link].d/[Link]
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 > [Link]
wstool init src [Link]
wstool update -j8 -t src
Using Raspberry Pi 4, With Ubuntu , Ros , Rplidar , Arduino: Page 16
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/
Con gure the catkin workspace
catkin_init_workspace
And source it to bashrc:
echo "source $HOME/catkin_ws/devel/[Link]" >> ~/.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 [Link]
After that build with catkin.
Using Raspberry Pi 4, With Ubuntu , Ros , Rplidar , Arduino: Page 17
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/[Link]
and launch RPILIDAR launch le
roslaunch rplidar_ros [Link]
Step 22: References:
[Link]
//[Link]/embed/Cao1ZRjb2E0
//[Link]/embed/vfqN-RRt84Q
[Link]
//[Link]/embed/Ac9UXXnSCDM
[Link]
[Link]
[Link]
knowle...
[Link]
[Link]
//[Link]/embed/Qrtz0a7HaQ4
[Link]
[Link]
[Link]
[Link]
[Link]
//[Link]/embed/Y6oo_2qHJII
[Link]
Using Raspberry Pi 4, With Ubuntu , Ros , Rplidar , Arduino: Page 18
Thanks for sharing :)
Using Raspberry Pi 4, With Ubuntu , Ros , Rplidar , Arduino: Page 19