Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

CHAPTER 4

SOFTWARE IMPLEMENTATION OF THE SYSTEM

In this chapter, consideration of software of the system is described step by


step. The corresponding implementation algorithm and software are considered.

4.1 Software Implementation of the system


Robot is drive based on the ROS (Robot Operation System). This System is
work with nodes communication system. C++, python and XML program languages
for the computer base ROS system and Arduino C language for arduino driver are
use in this system.

4.1.1 Overall Flowchart of the Proposed System


When the system starts, initializes the motor and microcontrollers to be
refreshed. In the First open the terminal and run the “driver.lunch” to start the
connection with arduino and ROS system. In this step need a connection with arduino
and computer because the serial communication is start with arduino and ROS. If
there is a problem at the connection the program is stop. After that open the Second
terminal and run “twist.lunch” to send a command to arduino and run the laser
scanner. Now get the laser data to produce a map. Now you can run RVIZ application
by the command of “rosrun rviz rviz”. In this application you can see the map and
consider moving the robot to the target or wanted location. When robot get the goal
location the robot start moving and ROS and SLAM are calculate path to the target
use the data of laser scanner and encoder data. AMCL check to reach goal or not by
using encoder data.If the reach goal declare the “Goal Reach”. Figure 4.1 is the whole
system flowchart of the system, figure 4.2 is the “driver.lunch” program flowchart
and figure 4.3 is the “twist.lunch” program.
31

START

Run
Driver.lunch

NO
Check
Arduino
Connection

YES

Run
Twist.lunch

NO
Check Rplidar
Connection

YES

Start Rplidar Start RVIZ Start motor

Wait and Get


Target Goal

Send Laser Start to Go Send Encoder


Scan Data Target Goal Data

Start to Go
Target Goal

STOP
.
Figure 4.1. Overall Flowchart of the Proposed System
32

START

Run driver. Launch

Check
arduino
Connection
NO

YES

Create Robot State Create Arduino


Public Node Communication
node

Publish Robot Communicate with

State Arduino

END

Figure 4.2. Flow Chart of “driver.lunch” Program


33

Start

Check
Rplidar
Connection
NO

YES

Create Start laser Create


Gmapping Scan Arduino
Node Node

Send laser Create


Calculate
data for AMCL
Coast map
Gmapping Node

Start motor
Send laser Calculate and scans
Open Rviz data for Localization Encoder
and Wait to Gmapping for Robot Data
Calculate
get Target Path for
Target
Goal
Calculate
for PID
Tuning

NO Check Public
target Robot
goal
Location

YES

Public Goal
Reach

Stop

Figure 4.3. Flow Chart of “twist.lunch” Program


34

4.1.2 Flow Chart of “drier.lunch” Program


To driver the robot, we need to run drier.lunch file by using roslaunch
command at the terminal. After run this command the serial communication with
arduino and ROS system are start. But the connection of usb cable are not, the
program cannot start.So check the connection and run the program. After the
connection start ROS produce arduino nodes to communicate with arduino. And the
ROS create Robot state publisher node to check request RPM and actual RPM and
other status of robot.

Figure 4.4. Program of “driver.lunch”

4.1.3 Flow Chart of “twist.lunch” program


When driver.lunch is run completely, we need to run twsit.lunch by
“roslaunch’ command and run at the second terminal. In this program node for
SLAM, AMCL, Gmapping, joystick control and face detection program are write and
can be control open and closed function in this program. Now we use only SLAM,
AMCL and Gampping. When program start RPLIDAR Laser scanner start work and
it read environment and send back to the computer.Now u can see he map in the Rviz
application and can give a target goal in it. After get the target Gmapping and Slam
calculate path and go to the Goal and check the reach it by AMCL.
35

Figure 4.5. Program of “twist.lunch”

4.2 Software Description of the Proposed System


Arduino sketches (programs) are written by C Programming language. The
sketch is uploaded to the Arduino board via Arduino IDE software.

Figure 4.6. Arduino IDE software

C++, Python and XML code for ROS are written by using a test editor Sub-
lime text and compile and run with ROS command “rosrun’ and “roslaunch”.

Figure 4.7. Sublime text software


36

4.2.1 Declaration of the Sketch


Library files are defined at the beginning of the sketch with ‘#include’
statement. It is used to include outside libraries in the sketch. This gives the
programmer access to a large group of standard C libraries (groups of pre-made
functions), and also libraries written especially for Arduino.
Arduino.h to use as lib for ROS system to know use a arduino as driver for the
motor.
WProgram.h for the motor default pin and serial port communication.
Cmdmessener.h for data transfer between ROS system and Arduino.

Figure 4.8. Declaration of the Sketch

Since the ADC is 10-bit, special header file has been provided with the code.
Arduino’s microcontroller reads all three axes data from the accelerometer and stores
in the EEPROM. It also stores the default threshold value of 25 in the EEPROM.

Figure 4.9. Pin Declarations for Encoder


The encoder counts are rad at when encoder is HIGH and encoder B is LOW
status or when encoder is LOW and encoder is HIGH means change status.
The setup () function is called when a sketch starts. Use it to initialize
variables, pin modes, start using libraries, etc. The setup () function will only run
once, after each powerup or reset of the Arduino board. .
37

Figure 4.10. Motor Drive Function of the Sketch


‘cmdMessenger’ function is used to set the data rate in bits per second (baud)
for serial data transmission. For communicating with the computer, use one of these
rates: 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, or
115200, and in this sketch 115200 is chosen

Figure 4.11. Send Message Function of the Sketch

You might also like