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

9-Arduino

10-Robot 4 Weel Car Chassis Kit

11- L298N driver module

12-Wires

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

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

https://www.instructables.com/Using-Raspberry-Pi-4-With-Ubuntu-Ros-Rplidar-Ardui/

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<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="http://www.cmake.org/files/v3.7/cmake-3.7.2.tar.gz" rel="nofollow"> http://www.cmake.org/files/v3.7/cmake-3.7.2.tar.g...</a>
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  <a href="https://github.com/Slamtec/rplidar_ros.git" rel="nofollow"> https://github.com/Slamtec/rplidar_ros.git</a>
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 <a href="https://github.com/tu-darmstadt-ros-pkg/hector_slam.git" rel="nofollow">https://github.com/tu-darmstadt-ros-pkg/hector_sla...</a>
cd ..<br>
catkin_make

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

Run

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.sh

install rosserial

cd catkin_ws
cd src 
git clone <a href="https://github.com/ros-drivers/rosserial.git" rel="nofollow"> <a href="https://github.com/ros-drivers/rosserial.git" rel="nofollow"> https://github.com/ros-drivers/rosserial.git </a> </a>
<a href="https://github.com/ros-drivers/rosserial.git" rel="nofollow"></a>cd ..
 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

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 serial_node.py /dev/ttyACM0

Enable keyboard control with:

rosrun teleop_twist_keyboard teleop_twist_keyboard.py

Step 12:

Step 13: References