You are on page 1of 3

Algorithm

We use a matrix to index the arena into rows and columns and this is used to locate the position of
the auto bot in the arena.

Column
1

2 R
4
o
3 w

Key for the algorithm


The auto bot uses
o A matrix (G) to store the unknown area in the arena (0), known area without blocks (1),
known area with blind spots (2) and position of the block (3).
o Two 1×2 arrays to store the position of the block. One for each type of the block (a, b).
o A counter to count the no of blocks (count) and a variable to recognise the type (t).
o Two counters to store the position of the current position (pr,pc).
o A variable to recognise the intersection (inter).
o A variable to recognise if the block is bot is on the manual bot or on the arena (i).
o A variable to store which block to pick next (n) – 1 for block type A, 2 for block type B.
o Two variables to store the distance sensor readings (d1, d2).
o Two variables to store the proximity sensor readings (p1, p2).
o An array to store the line sensor readings.
o A counter to store the direction in which the bot is facing (dir).

Blind spots: the distance sensors can only sense an object precisely in the range 20 cm to
150 cm (as given in the data sheet) and if the object is less than 20 cm the readings will not
be precise and the object distance may be misinterpreted as in the range of its vision. Hence
to avoid such ambiguity we place a blind spot at both the positions i.e. at a distance <20 cm
and in the appropriate distance in the range 20-150 cm.

Auto-bot deployment
 After power on, check if both the proximity sensors read white. If white wait i=1, else check
i. If i=1, move forward by following the line until an intersection is reached and update the
current position of the bot as (-1, 1).
 Else if i=0, move forward by following the line until an intersection is reached and update the
current position of the bot as (-1, 5). Turn right and move forward by following the line until
an intersection is reached and update the current position of the bot as (-1, 4). Continue
moving forward until (-1, 1) is reached and turn left.
 Now move forward by following the line until an intersection is reached and update the
current position of the bot as (0, 1).

Search and capture the block

Structure of the algorithm:


1. Start
2. Read distance and update the matrix
3. Move forward until an intersection and update the position
4. Now move forward until the row 6 is reached
5. Turn left and update the direction
6. Move forward till the column 2 is reached
7. Read distance and update the matrix
8. If in between a blind spot or block is encountered in the present column identify the block
and pick it.
9. Go to the nearest block and identify it
10. Check the type of the block is in the order ABAB or BABA
11. If it is in order pick the block and place the block on the ramp1 of the manual bot
12. Else store the block position
13. Go to the nearest block or blind spot or unknown area
14. Repeat steps from 8 to 12 until all the blocks are picked
15. Move up the ramp1 and get onto the manual bot
16. end

Different segments in the algorithm


 Read distance and update the matrix
 Move forward until an intersection and update the position
 Identify the block
 Pick the block

Read distance and update the matrix


 Turn on the distance sensors
 Check the readings of d1 and d2
 If d1>6 and d2>6 update matrix with 1s in both present row and column
 If d1<6 and d2>6 update matrix with 1s in the present column and with 2s in the pr+1 th and
pr+d1th rows and with 1s in between pr+1 th and pr+d1th rows.
 If d1>6 and d2<6 update matrix with 1s in the present row and with 2s in the pc+1 th and
pc+d2th column and with 1s in between pc+1 th and pc+d2th column.
 If d1<6 and d2<6 update matrix with 2s in the pr+1 th, pc+1th, pc+d2th and pr+d1th position in
the matrix and with 1s in between pr+1 th and pr+d1th rows and pc+1th and pc+d2th column.
 Turn off the distance sensor

Move forward until an intersection and update the position


 Take the weighted average of the line sensor reading to find the current position of the bot
on the line
 Based on the weighted average, the required speed of the right and left wheels to smoothly
adjust the robot to the line is deduced
 Move forward until an intersection is reached
 Check the direction
 If dir=1 pr=pr-1, if dir=2 pc=pc+1, if dir=3 pr=pr+1, if dir=4 pc=pc-1

Identify the blocks


 Turn on the proximity sensors
 Move forward until either p2 reads a value or an intersection is reached whichever is
encountered first
 If intersection is reached first, update matrix with 1 in the present position and check the
direction if dir=1 or dir=3 replace 2 by 3 in the matrix in the present column and if dir=2 or
dir=4 replace 2 by 3 in the matrix in the present row.
 If p2 reads first stop and compare it with the reading of p1
 If both are equal then it is block of type A and make t=0 else it is of the type B and make t=1
 Check count, if count=0 pick the block and update n=t+1
 Else if count is>1 check n if n=1 and t=0 or n=2 and t=1 pick the block and update n=t+1
 Else if t=0 store the position of the block in a matrix if t=1 store the position in b matrix
 Turn off the proximity sensors

Pick the blocks


 Roll down the gripping belt
 Move in the reverse direction until an intersection is reached
 Check the matrix for blocks in the present column, pc+1 th or pc-1th column
 If there are no blocks, then turn to face the direction 1
 Else repeat the above steps until the if condition is satisfied
 Now move forward until the row -1 is reached and then lift the gripping belt
 Move in the reverse direction until an intersection is reached turn to face direction 3

You might also like