Using RPlidar With Robot Navigation

Introduction: Using RPlidar With Robot Navigation

Hi everyone !

we made a project consist of Using RPlidar With Robot Navigation .

we will explain how dose this project work , so we used the RPlidar to build the map that will follow by the robot.

thus, follow our lead to make this project run.

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


10-Robot 4 Weel Car Chassis Kit

11- L298N driver module


13-Baterry 12V 2A

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@ Password is ubuntu.

Note: If you want to use another version of ubuntu follow this link

Then run

sudo systemctl disable magni-base

to ensure that startup scripts are disabled.

Run roscore to make sure that things are working properly.


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

killall -9 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<br>ppa:george-edison55/cmake-3.x
sudo apt-get update

When cmake is already installed

sudo apt-get upgrade
sudo apt-get install build-essential
wget <a href="" rel="nofollow"></a>
tar xf cmake-3.7.2.tar.gz
cd cmake-3.7.2
sudo apt-get install checkinstall
sudo checkinstall
sudo make install

Step 6: Rplidar Kinetic Installation

cd catkin_ws
cd src
git clone  <a href="" rel="nofollow"></a>
cd ..

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 <a href="" rel="nofollow"></a>
cd ..<br>

Step 8: File Modify

For a quick test of the hector_mapping two launch files needs to be modified.
Edit the "mapping_default.launch" file


nano ~/catkin_ws/src/hector_slam/hector_mapping/launch/mapping_default.launch 

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

edit the "tutorial.launch" file

nano ~/catkin_ws/src/hector_slam/hector_slam_launch/launch/tutorial.launch

and replace the third line to look like so

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

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

roslaunch rplidar_ros view_rplidar.launch
roslaunch rplidar_ros view_rplidar.launch

Step 10: Arduino With Kinetic

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-kinetic-rosserial-arduino

To Install the IDE :

cd Downloads
cd arduino-1.8.13
sudo ./

install rosserial

cd catkin_ws
cd src 
git clone <a href="" rel="nofollow"> <a href="" rel="nofollow"> </a> </a>
<a href="" rel="nofollow"></a>cd ..
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

Open a new terminal window and type:

ls - l /dev/ttyACM0

after that run

sudo chmod a+rw /dev/ttyACM0

again run

ls - l /dev/ttyACM0

Step 11: Robot Control

The entirety of the code for this node lives on the Arduino. So we use this sketch, and upload it. This is a very very simple sketch, that only supports forward and stopping motion.

We can control the robot from our raspberry pi now! In separate terminal instances, run the following:

Allow Arduino communication with

rosrun rosserial_python /dev/ttyACM0

Enable keyboard control with:

rosrun teleop_twist_keyboard

Step 12:

Step 13: References

Be the First to Share


    • One Board Contest

      One Board Contest
    • Jewelry Challenge

      Jewelry Challenge
    • New Year, New Skill Student Design Challenge

      New Year, New Skill Student Design Challenge



    2 months ago

    I am currently working on similar project but using hoverboard motors to build a big robot.

    Thank you.