You are on page 1of 7

Path Planning in Mobile Robots

Genetic Algorithm for Path Planning of a Mobile Robot

Objective
To move from starting point to the endpoint on permissible while avoiding collisions with obstacles
and minimizing total distance travelled, time taken or energy consumed.
Problem Statement
 Mobile robots move in environments, which can be static or dynamic.
 In the static environment shown in the Fig., the MR is required to move from the start
point to the endpoint (Goal) on permissible paths while avoiding collisions with the
obstacles and minimizing the total distance travelled, time taken or energy consumed.

Figure 1: Static Environment for Mobile Robot

Methodology
Genetic Algorithms: A stochastic evolutionary technique based on human genetics.
Theory
Stochastic Methods
• Stochastic Methods are based on laws of probability for sampling of random events and have
the advantage that they can handle large problems.
Genetic Algorithms (GA)
• The GA method is applicable to both static and dynamic environments. In static environment
all coordinates (MR, obstacles, goal) are input into the onboard computer system of MR while
in dynamic environment sensors need to be used.
• A brief comparison between genetic algorithms and human genetics is given below:

1|Page
Path Planning in Mobile Robots

Figure 2: Genetic Algorithms vs Human Genetics


GA Program

 A chromosome consists of path points from Start to End


 Each path has an associated length Or “distance”
 Objective is to find the “optimal” path i.e. the shortest path

Figure 3: Genetic Algorithms Flow Chart

2|Page
Path Planning in Mobile Robots

Algorithm Development
Create Environment
The Environment is “created” by defining the workspace i.e. the 2D min and max of the coordinates
(x,y); there are 7 obstacles and path points labeled 0-15 i.e. 16 path points; Starting Position is 0 and
End-Point is 15 (see figure 1).
Input Data

Note that link points in table are 1 through 16 and in adjoining image they are from 0 to 15.
Fitness of each chromosome
The “fitness” of a path is the inverse of the length of the path from starting point to end-point
𝐹𝑖𝑡𝑛𝑒𝑠𝑠(𝑖𝑃𝑎𝑡ℎ) = 1.0/𝐷𝑖𝑠𝑡𝑎𝑛𝑐𝑒𝐼𝑛𝑃𝑎𝑡ℎ(𝑖𝑃𝑎𝑡ℎ)
Chromosome Length
No. of chromosomes: NC=20
For each iteration select 40% of these i.e. 8 chromosomes
No. of Bits NBITS = log NPTS /log 2 = log 16 / log 2 = 4
If there are 1024 points, then NBITS = log 1024/log 2 = 10
Chromosome Length
CHR_LEN=(NOBS+2)*NBITS = (7+2)*4 = 36 for 7 obstacles and 4 bits
CHR_LEN= ... = (7+2)*10=900 for 7 obstacles and 10 bits

3|Page
Path Planning in Mobile Robots

Selection of Path Points (Generating Population)


A Path is generated by selected points from a specified start-point to a specified end-point.
 Starting Point
 Consider each link point
 Find distance from each link point to end-point
 Calculate the Probability of moving to each link point (PDF and CDF)
 Generate a random number in (0,1)
 Select the next point in path (based on the random number generated)
 Continue till end point is reached

Steps for Genetic Algorithm Implementation


1- Generate Population
Following the steps given above for generation of a path, generate population of 20
chromosomes like below, paths may or may not be similar to the ones shown below:

4|Page
Path Planning in Mobile Robots

2- Select Best Chromosomes


From the population generated in step 1, select a sample size of 40%:

Selected paths can differ from the paths shown in above figure, as the generated paths could differ from
the ones shown in figures above. Sample size can be selected based on best chromosomes or random
number generation.
Parent Selection
Two methods are used for selection of parents:
i- Random selection
𝑚𝑎 = 𝑐𝑒𝑖𝑙(𝑁𝐶𝑠𝑒𝑙 ∗ 𝑟𝑎𝑛𝑑(1, 𝑁𝐶𝑠𝑒𝑙)); % 𝑚𝑜𝑡ℎ𝑒𝑟𝑠
𝑝𝑎 = 𝑐𝑒𝑖𝑙(𝑁𝐶𝑠𝑒𝑙 ∗ 𝑟𝑎𝑛𝑑(1, 𝑁𝐶𝑠𝑒𝑙)); % 𝑓𝑎𝑡ℎ𝑒𝑟𝑠
e.g. The command: 𝑚𝑎 = 𝑐𝑒𝑖𝑙(8 ∗ 𝑟𝑎𝑛𝑑(1,8)) 𝑔𝑖𝑣𝑒𝑠
6 4 2 4 2 1 7 5
Ceil is a matlab command 𝑐𝑒𝑖𝑙(0.9) = 1, 𝑐𝑒𝑖𝑙(7.2) = 8
ii- Rank Weighting
Selection probability of a parent is in proportion to the fitness; thus a PDF and a CDF is constructed
and a random number 𝜉 ∈ (0,1) is used to select a parent.
This step is to be performed before crossover and mutation, this step is also called parent selection
step. In this step we select pairs on which crossover and mutation is to be performed to obtain next
generation.

5|Page
Path Planning in Mobile Robots

Crossover

Mutation
Mutation probability should be kept less than 15%. Consider the path point
0000 0100 0101 0111 1001 1111
0 – 4 – 5 – 7 -- 9 – 15
If a bit between the start-point and an end-point is chosen at random e.g. the 10th bit point 1 and it is
mutated to bit 0, then the path reads
0000 0100 0001 0111 1001 1111
And the path has now become
0 – 4 – 1 – 7 – 9 – 15
If this is “feasible” i.e. connected, then it can be selected
Next Generation
Feasible paths obtained after mutation is considered as next generation. Obtaining a finite number of
generations can also be used as a stopping criteria. Above mentioned steps are to be repeated until
stopping criteria, convergence and/ or optimal solution is achieved.
Convergence and Optimal Solution
When the paths are all the same and no further improvement is possible by cross-over or mutation, the
solution is said to have converged
Here, the converged solution which is the “optimal path” with a distance of 17.9749 is:
0 – 4 – 6 – 7 – 9 – 15

6|Page
Path Planning in Mobile Robots

Summary
An optimal solution is obtained by generating an initial population of chromosomes (paths
consisting of path points), computing their “fitness” to select “best” parents for producing the
“next generation” of chromosomes by carrying out evolutionary procedures of cross-over and
mutation. The procedure is continued until no further improvement is possible; this is called
“convergence” which corresponds to an “optimal” solution.
Results
In next lab a proper report needs to be submitted containing introduction, flow chart, code and
conclusion. Results that are required at the end of this lab are:
- Initial population
- Best chromosomes selected before first iteration
- Next generation obtained
- Final best path obtained
- Distance of best path
Save this data in a text file directly from within the MATLAB code. If an iteration is too large to be
printed, print only a portion of it to show.

7|Page

You might also like