Many
research in robotics area to find path using different bio-inspired
algorithms are conducted recently. Despite many researches are
limited to the simulation result. This project tries to verify the
robustness of Particle Swarm Optimization (PSO) algorithm in the
real-world implementation. PSO optimizes a problem by having a
population of candidate solutions, and moving these particles around
in the search-space according to simple mathematical formula over the
particle's position and velocity. In this project we are implementing
PSO algorithm with some modification in robotics. We conducted many
experiments with different number of robots and different number of
destination too. The result verifies that PSO is technically sound
for real-world problems of path finding even in the presence of
obstacles.
Implementation
Details
In
this implementation one Robot is considered as combination of one PC
process plus one NXT brick. The Robots are communicating each other
through a LAN connection connecting these computers. Internal
communication, that is communication between NXT brick and PC process
, is carried through blue-tooth. Robots are getting their current
position and position of food from a different process, here we
called this process as 'server', which calculates the positions of
each color in the arena using a camera. A schematic diagram is shown
below.
In
NXT brick we used two motors and two sensors. Motors are used for
rotating the tires. The sensors used are one Ultrasonic sensor, for
getting the distance of an obstacle, and one compass sensor, for
getting current alignment of the robot.
An
outline of the program implementation is given below. Here we used
three threads in PC program and two threads in NXT program. One PC
program can send data into one NXT and it can multi-cast data into
other processes (may be into processes in different systems connected
via LAN). PSO algorithm is used to minimize the value of f(x,y) given
in Table 1. Here we taken the values for the weights used in PSO as w
= 0.73 and c1 = c2 = 2 . Value for r1
and r2 are taken as random values .
f(x, y)
|
√ [ (x –
x1)2 + (y – y1)2 ]
|
where
(x1 , y1) is the position of food and
(x ,
y) is the position of particle.
|
Angle, θ
|
tan-1
[ ( newY – y) /
(newX – x) ]
|
where
(x , y) is the current position and
(newX, newY)
is the next position calculate using PSO algorithm.
|
Equations used
in PSO algorithm
|
V[]
= v[] * w + c1 * r1 *
(Pbest []
- X[]) + c2 * r2 *
(Gbest []
- X[])
newX[] =
X[]+V[]
|
Table
1: Table of equations
In
PC program we used 3 threads, one for connecting NXT , one for
sending data to other PC processes and other one for getting
particles coordinate details from the server program using camera.
In NXT program we used 2 threads, one for connecting PC and other one
for controlling the motors. We are doing all calculation parts in PC
program and finding out what should be the angle of robot for next
position and sending this angle and a flag ,indicating
different conditions, to the NXT. The value of angle varies
between -179 to 180 and is calculated using the equation given in
Table 1.
Algorithm used in PC
- Connect to the python server.
- Connect to the appropriate NXT.
- Initialize the position of the particle according to the values from the camera, and initial velocities to zero.
- Initialize the position of food, (x1 , y1).
- Calculate the value of f(x,y) and make this value as initial Pbest and Gbest
- Make a multi-cast connection for sending Pbest values to other robots.
- Start three threads.
- Thread 1
- Receive the values of Pbest from other robots and compare those values with the current Gbest and update value of Gbest .
- Goto Step 5.1.1
- Thread 2
- Receive the particles position from camera (discard some number of packets and then accept next valid packet).
- If the position of food is changed. Initialize the values as in Step 3 and goto step 5.2.1.
- Calculate what should be the next position of the robot using PSO algorithm explained above.
- Calculate the angle to the next point and flag value.
- Trigger thread 3 for sending data to the NXT (Set flagNXTSend to 1).
- Update current position of the particle (Robot) and Pbest values.
- Set Pbest as the current Gbest .
- Send Pbest value to other robots through multi-cast connection.
- Goto Step 5.2.1.
- Thread 3
- If flagNXTSend equal to zero sleep some time and then goto step 5.3.1.
- Calculate send_value.
- If angle is less than zero , send_value = flag * -1000 + angle
- If angle is greater than or equal to zero then
send_value = flag * 1000 + angle.
- Send send_value to the NXT.
- Set flagNXTSend to zero and goto step 5.3.1.
Algorithm used in NXT brick
- Connect with appropriate PC.
- Start two threads.
- Thread 1
- Receive send_value from PC process.
- Calculate value of flag and angle.
- If send_value is negative
- send_value = send_value * -1;
- flag = send_value / 1000;
- angle = send_value % 1000; (mode operation)
- angle = -1 * angle;
- goto step 2.1.3
- flag = send_value / 1000;
- angle = send_value % 1000; (mode operation )
- goto step 2.1.1
- Thread 2
- If value of flag is equal to 10.
- Rotate the robot indicating reached food, goto step 2.2.1.
- Take the current orientation of the robot using compass sensor.
- Calculate the angle of rotation such that the orientation of robot should be in the angle received from the PC through thread 1.
- Rotate the robot by a value calculated in Step 2.2.3
- Check for the obstacle, that is whether the value from Ultra sonic sensor is less than 25. If so continue to step 2.2.5.1 else to step 2.2.6
- Move Backward until the distance to the obstacle become greater than 30.
- Rotate the Robot until the distance to the obstacle become greater than 35.
- Rotate the Robot through an angle of 30. Assign a value of 3 to the flag.
- Steer the Robot around the Obstacle, and Check is there any further obstacle in front. If so goto 2.2.4.1.
- Repeat step 2.2.4.4 while flag value is 3.
- Move forward, goto step 2.2.5.
No comments:
Post a Comment