Vous êtes sur la page 1sur 60

SWARM Robotics

Flood Fill & Grid Navigation Algorithm


Based on NEXUS problem statement.......

www.robosoftsystems.co.in

Arena for Techfest Nexus 2010

SWARM Robotics

The arena will consist of a 5 x 5 squares grid of white lines on a black surface. The lines

will be equally spaced. Each cell of the grid will be a square with inner dimensions 220
mm x 220 mm. The total size of the upper outer square is 1550 mm x 1550 mm. The thickness of each white line is 30 mm.

At the start of each run, the machine must be placed within a horizontal square of 200
mm x 200 mm in the start zones shown in Green. Any machine not able to fit into this square at start will be disqualified. The dimension of the boundary of the square will be less than or equal to 5 mm. The dimensions of the arena will be accurate to within 5% or 20 mm, whichever is less.

Assembly joints on the arena floor will not involve steps greater than 0.5 mm.

www.robosoftsystems.co.in

Dimension of the machine

SWARM Robotics

The machine must fit within a box of dimensions 200mm x 200mm x 250mm (l x b x

h). The machine can expand itself from its initial size but must fit within 200mm x
200mm x 250mmat all points of time during the run. The machine must be stable and must stand on its own at the beginning of the race when put in the start zone.

The machine should not separate or split into two or more units. All machines/units
which are touching each other or are in the start zone will be considered as one machine. The teams are allowed to use ready-made wireless modules/ready-made microcontroller boards/ready-made sensor kits. Use of ready-made mechanical kits is not allowed.

www.robosoftsystems.co.in

Power Supply and Propulsion


allowed.

SWARM Robotics

The machine has to use an on-board power supply. No external power supply will be Each team shall prepare its own power supply for its machine. The potential difference between any two points of the machine should not exceed 24 V

DC.
The method of propulsion is at the discretion of the builder provided the power source is non-polluting. A power supply other than electric must be approved by the organizers beforehand to prevent disqualification.

www.robosoftsystems.co.in

Controls

SWARM Robotics

The machine must be completely autonomous. It should not receive any input from

outside the arena other than the data received from the organizers' computer during the
course of the run. Any team found violating this rule will be disqualified. The machine must be able to receive and transmit information wirelessly with the

transceiver connected to a computer of the organizers. The details of these transceiver


modules can be found in the communication rules section.

www.robosoftsystems.co.in

Communication rules for Techfest Nexus 2010

SWARM Robotics

There will be one computer transmitting data through a Transceiver Module readily

available in most hobby shops, which uses a TI CC2500 at frequency 2433MHz.


Participants are urged to use a similar module to ensure compatibility. The organizers' computer will have a unique address. It uses a software to send data

automatically to the contestant's bot. This address and the unique address of the team's
machine will be given to the participant 2 weeks before the event. Each message sent from the computer will consist of a variable number of bytes. The message will always be addressed to the device id of the team; the first byte will always be the length of the packet. The next (length-1) bytes will be the data.

www.robosoftsystems.co.in

Communication rules (contd..)


the data byte '0x03', etc.

SWARM Robotics

A coordinate (1,2) will be given by the data byte '0x12', A coordinate (0,3) will be given by In the initial transmission by the organizers computer: The first byte will be the length of the packet.

The second byte will be final destination coordinate for the robot.
The third byte will be the number of checkpoints. The next few bytes will be the coordinates of each of the checkpoints. This will be followed by the number of danger points. The next few bytes will be their coordinates.

www.robosoftsystems.co.in

Communication rules (contd..)

SWARM Robotics

The teams must add all the bytes as unsigned binary numbers, discarding any overflow

bits and transmit the result to the organizers' computer. The organizers' computer will
return a packet which contains '0x02' '0x01' for "ok" or '0x02' '0x02' for "fail". In case of fail, or not receiving any data from the machine, the computer will resend the

path information up to a maximum of 3 times.


The teams must then send its route to the computer in the following manner. First byte will be the length of packet. Second byte will be the first point on its preferred route. Third byte will be the second point on its preferred route.

So on till (length-1) bytes.

www.robosoftsystems.co.in

Communication rules (contd..)

SWARM Robotics

The computer will acknowledge receipt of this route by sending its checksum similar to

rule 6; the machine must send '0x02' '0x01' for "ok" and a '0x02' '0x02' for "fail". In case
of a "fail", the team must resend the path. After this, the computer will send a signal '0x02' '0x13' for "go". The time will be

measured from this point onwards.


It is the team's responsibility to ensure that the channel selected for communication has no interference. The organizers will not be responsible for interference in any channel, but will try to ensure that there isn't any.

www.robosoftsystems.co.in

Game Rules for Techfest Nexus 2010

SWARM Robotics

The maximum time given for completing the run is 3 minutes.

At the start of the run, the machine will be kept in the arena in the starting zone along
the white line. Only one member from the team is allowed to be near the game field while

starting the machine. The machine must be started by only one switch.
After the starting of the machine, the computer will send the data as mentioned in the communication rules. The machine will be given a finish point and a set of checkpoints,

in the data format as mentioned in the communication rules. The machine will also be
given a set of danger points. The machine must send back to the computer the path that it will follow to reach the destination. After receiving the path from the team's machine, the computer will issue a 'go' signal by sending data as mentioned in the

communication rules.

www.robosoftsystems.co.in

Game Rules (contd..)

SWARM Robotics

The machine can start only after receiving the 'go' signal from the computer. The

organizers will start measuring time as soon as the signal is sent. The team's machine is
supposed to make its way to the finish with a calculated route which must pass through

the checkpoints preferably in the order transmitted but must avoid the danger points. The
team need not follow the path transmitted at the start of the run. A machine is said to pass through check points if, at some point of time during the run,

it completely covers the intersection corresponding to the check point. This will be
determined by the judges at the arena. A machine is said to pass through a danger point if, at some point of time during the run, it partially/completely covers the intersection corresponding to the danger point. This will be determined by the judges at the arena.

www.robosoftsystems.co.in

Game Rules (contd..)

SWARM Robotics

During restarts, a contestant may not feed information about the grid to the machine.

However, contestants are allowed to: adjust sensors (gain, position etc.), change speed
settings and make repairs. However, a contestant may not alter a machine in a manner

that alters its weight (e.g. removal of a bulky sensor array or switching to lighter batteries
to get better speed). The judges shall arbitrate. The team will be given a chance to calibrate their machine once before their run.

The machine is not allowed to leave anything behind while traversing the grid. It should
not make any marks on the floor of the arena. Any machine found damaging the arena will be immediately disqualified. Although not compulsory, teams are encouraged to use LEDs/other display techniques to indicate that they have received/transmitted information and

also while crossing the danger points/cross points.

www.robosoftsystems.co.in

Game Rules (contd..)


machine in the arena.

SWARM Robotics

Such techniques have to be pre-defined and told to the organizers before putting the Participants are not allowed to keep anything inside the arena other than the machine.

Laptops/personal computers are not allowed near the arena. Other Wi-Fi, Bluetooth, etc
devices must be switched off. The organizers hold the right to check for these devices and their usage.

www.robosoftsystems.co.in

Penalties, Disqualification and Restarts

SWARM Robotics

Teams will be awarded 40 points for a correct path transmitted.

Any machine which crosses a danger point will be given a 20 point penalty for each
danger point crossed. Multiple penalties will be awarded for crossing a danger point more than once.

Any machine which crosses a checkpoint will be given 40 points for each checkpoint
crossed. No extra points will be awarded for crossing a check point more than once in a restart. A bonus of 25 points will be awarded if all the check points are crossed in the order mentioned.

www.robosoftsystems.co.in

Penalties, Disqualification and Restarts (contd..)

SWARM Robotics

The maximum time allowed for one run is 3 minutes. Maximum of two runs will be

given to a team. A maximum of two restarts will be allowed per run. The team may
decide to have a second run before they use all the available restarts in a run. Once a restart is given in any run, the total points are set back to zero, but the timer is

not.
Once placed on the arena, the contestants may only touch their machine for a maximum of two times during that run, only for the purpose of restarts. On restart, the machine must be placed in the same start zone it started from in the same orientation. In case of restarts, the organizers' computer will resend the data. The same start procedure must be

followed again. Machines cannot start moving until the 'go' signal is given again. The
teams are not allowed to give any external inputs to the machine in this time. Please note that time will keep running during this procedure.

www.robosoftsystems.co.in

Penalties, Disqualification and Restarts (contd..)

SWARM Robotics

The organizers may stop any machine at any time if they feel that it is performing, or is

about to perform, any action that is dangerous or hazardous to people or equipment. No


machine is allowed to use any flammable, combustible, explosive or potentially dangerous processes.

The time will start from the moment the machine receives a 'go' signal from the
computer. The time will stop as soon as the front edge of the machine crosses the finish square. There will be a penalty if the machine partially covers the finish square or crosses it completely. No penalty will be awarded if it covers the finish square completely when it

stops.

www.robosoftsystems.co.in

Penalties, Disqualification and Restarts (contd..)

SWARM Robotics
Points awarded

Action Taken

Correct path transmitted


A danger point crossed A check point crossed All checkpoints crossed in the

+40
-20 +40 +25

order mentioned

www.robosoftsystems.co.in

SWARM Robotics
Now we have a clear idea about the grid that will be there. Now we have to decide what data types and what variables to consider when we make the representation of the grid. Please note that your robot will not be allowed to traverse the grid and find out the

coordinates.
To find out the location of each nodes of the grid you will have to use a certain algorithm.

Over here we will discuss the Flood Fill Algorithm

www.robosoftsystems.co.in

SWARM Robotics

Flood Fill Algorithm


www.robosoftsystems.co.in

SWARM Robotics

The grid with the danger points.

www.robosoftsystems.co.in

SWARM Robotics

Destination has been marked with green.

www.robosoftsystems.co.in

SWARM Robotics

The start point where your robot is right now.

0
www.robosoftsystems.co.in

SWARM Robotics
After you know the start point, you will have to traverse the total grid virtually, while marking each cell either as visited or non-visited. While you traverse the grid, you cannot move in the x & y direction simultaneously.

This means that your can either move in the x or in the y direction.
At the start point, you can mark it as visited by inserting a 0. The next point will be marked by 1 and so on.

Every time you try to move, you will have to either move in the x or in the y direction.
All possible directions in the x and y coordinates should be traversed.

The danger zones will not be marked as visited so that the robot will know that it cannot
take any path which includes the danger zones. The next figure shows the first step.

www.robosoftsystems.co.in

SWARM Robotics

Step 1 Fill 1s in the x and y coordinates.

1
www.robosoftsystems.co.in

1 0

SWARM Robotics

Step 2 Fill 2s in the x and y coordinates.

2
www.robosoftsystems.co.in

2 1

1 0

2 1

SWARM Robotics

Step 3 Fill 3s in the x and y coordinates.

3 2

3 2 1

1 0

3 2 1

3 2

www.robosoftsystems.co.in

SWARM Robotics

Step 4 Fill 4s in the x and y coordinates.

4 3 2

4 3 2 1

1 0

4 3 2 1

4 3 2

www.robosoftsystems.co.in

SWARM Robotics

Step 5 Fill 5s in the x and y coordinates.

4 3 2

5 4 3 2 1

5 1 0

5 4 3 2 1

5 4 3 2

www.robosoftsystems.co.in

SWARM Robotics

6
Step 6 Fill 6s in the x and y coordinates.

4 3 2

5 4 3 2 1

6 5 1 0

5 4 3 2 1

5 4 3 2

www.robosoftsystems.co.in

SWARM Robotics
After all the possible cells have been marked as visited, the robot will have to find out all the possible routes to reach from the start point to the destination point. To calculate the possible routes to move from start point to the destination point, the robot

will also have to take into consideration, the danger zones.


There can be many paths to traverse the same course. After the robot has found out all the possible routes, it has to find out the shortest path.

The following slides show the possible routes that the robot can follow to reach from the
start point to the destination.

www.robosoftsystems.co.in

SWARM Robotics

6
Possible routes Route 1

4 3 2

5 4 3 2 1

6 5 1 0

5 4 3 2 1

5 4 3 2

www.robosoftsystems.co.in

SWARM Robotics

6
Possible routes Route 2

4 3 2

5 4 3 2 1

6 5 1 0

5 4 3 2 1

5 4 3 2

www.robosoftsystems.co.in

SWARM Robotics

6
Possible routes Route 3

4 3 2

5 4 3 2 1

6 5 1 0

5 4 3 2 1

5 4 3 2

www.robosoftsystems.co.in

SWARM Robotics

6
Possible routes Route 4

4 3 2

5 4 3 2 1

6 5 1 0

5 4 3 2 1

5 4 3 2

www.robosoftsystems.co.in

SWARM Robotics

Grid Navigation Algorithm


www.robosoftsystems.co.in

SWARM Robotics
We have now finished with the Flood Fill Algorithm. Now we know the routes that can be followed and we run a shortest path algorithm on the various paths and find out the shortest path. You must be wondering, why we are actually so bothered about the grid following part?

You may think that once you know the path that you have to follow, you just need to
move your robot forward, backward, left or right and thats it. To know why we need to learn this complex algorithm, please view the following few

slides.

www.robosoftsystems.co.in

SWARM Robotics

The grid with the danger points.

www.robosoftsystems.co.in

SWARM Robotics

The grid with the start point.

www.robosoftsystems.co.in

SWARM Robotics

The grid with the destination.

www.robosoftsystems.co.in

SWARM Robotics
The robot may have come from the straight direction in which case it will have to continue straight, or it may have come from the left direction in which case it will have to take a left turn and the continue straight, or it may have come from the right direction in which case it will have to take a right turn and then continue straight or

lastly it may have come from the opposite (backward) direction which will need the
robot to take a reverse turn and then continue straight. The point that becomes pretty obvious in all the above cases, is that, the direction that

the robot will continue so as to reach to the next point is dependant upon
WHERE IT HAS COME FROM (previous) and WHERE IS IT NOW (current)!

www.robosoftsystems.co.in

SWARM Robotics

Position 1
Check the current position of the robot!

www.robosoftsystems.co.in

SWARM Robotics

Position 2
Check the current position of the robot!

www.robosoftsystems.co.in

SWARM Robotics

Position 3
Check the current position of the robot!

www.robosoftsystems.co.in

SWARM Robotics

Position 4
Check the current position of the robot!

www.robosoftsystems.co.in

SWARM Robotics
In the above cases, the turn that the robot will take is dependant on the current position of the robot. The current position of the robot is dependant on the previous position of the robot. The turn of the robot is also dependant on the next position of the robot.

Each of these positions will have an x and y component.


Previous Position previousx Next Position nextx

previousy
Current Position currentx

nexty

currenty

www.robosoftsystems.co.in

SWARM Robotics
lastx = 0 lasty = 5
rows (x)
(6,6) (6,5) (6,4) (6,3) (6,2) (6,1) (6,0) (5,6) (5,5) (5,4) (5,3) (5,2) (5,1) (5,0)

currentx = 1 currenty = 5 nextx = 2 nexty = 5

(4,6)

(4,5)

(4,4)

(4,3)

(4,2)

(4,1)

(4,0)

(3,6)

(3,5)

(3,4)

(3,3)

(3,2)

(3,1)

(3,0)

(2,6)

(2,5)

(2,4)

(2,3)

(2,2)

(2,1)

(2,0)

(1,6)

(1,5)

(1,4)

(1,3)

(1,2)

(1,1)

(1,0)

(0,6)

(0,5)

(0,4)

(0,3)

(0,2)

(0,1)

(0,0)

columns (y)

www.robosoftsystems.co.in

SWARM Robotics
lastx = 1 lasty = 5
rows (x)
(6,6) (6,5) (6,4) (6,3) (6,2) (6,1) (6,0) (5,6) (5,5) (5,4) (5,3) (5,2) (5,1) (5,0)

currentx = 2 currenty = 5 nextx = 3 nexty = 5

(4,6)

(4,5)

(4,4)

(4,3)

(4,2)

(4,1)

(4,0)

(3,6)

(3,5)

(3,4)

(3,3)

(3,2)

(3,1)

(3,0)

(2,6)

(2,5)

(2,4)

(2,3)

(2,2)

(2,1)

(2,0)

(1,6)

(1,5)

(1,4)

(1,3)

(1,2)

(1,1)

(1,0)

(0,6)

(0,5)

(0,4)

(0,3)

(0,2)

(0,1)

(0,0)

columns (y)

www.robosoftsystems.co.in

SWARM Robotics
We will now present the algorithm that has been used to take the decision to move the robot forward. Data types that have been used checkpoint array of integers having the coordinates of the checkpoints

next array of integers having the coordinates of the whole shortest path
danger array of integers having the coordinates of the danger zones Functions that have been used

goStraight() makes the robot go forward until the sensor detects a grid node
turnLeft() makes the robot make a 90 degree left turn turnRight() makes the robot make a 90 degree right turn reverse() makes the robot turn reverse

www.robosoftsystems.co.in

SWARM Robotics
if(currenty > previousy) //robot has come from right { if((nexty > currenty) && (nextx == currentx)) { goStraight(); //robot continues on same row } if((nexty == currenty)&&(nextx > currentx)) { turnRight(); //robot makes a right turn and continues goStraight(); //on the same column }
if((nexty == currenty) && (nextx < currentx)) { turnLeft(); //robot makes a left turn and continues goStraight(); //on the same column }

www.robosoftsystems.co.in

SWARM Robotics
if(nextx == previousx) { reverse(); goStraight(); } } //checkpoint reached turn back

www.robosoftsystems.co.in

SWARM Robotics
if(currenty < previousy) //robot has come from left { if((nexty < currenty) && (nextx == currentx)) { goStraight(); //robot continues on same row } if((nexty == currenty) && (nextx > currentx)) { turnLeft(); //robot makes a left turn and continues goStraight(); //on the same column }
if((nexty == currenty) && (nextx < currentx)) { turnRight(); //robot makes a right turn and continues goStraight(); //on the same column }

www.robosoftsystems.co.in

SWARM Robotics
if(nextx == previousx) { reverse(); goStraight(); } } //checkpoint reached turn back

www.robosoftsystems.co.in

SWARM Robotics
if(currenty == previousy) //robot is where it was { if((nexty > currenty) && (nextx == currentx)) { turnLeft(); //robot makes a left turn and continues goStraight(); //on the same row }
if(nexty == currenty) && (nextx > currentx)) { goStraight(); //robot continues on same column } if((nexty < currenty) && (nextx == currentx)) { turnRight(); //robot makes a right turn and continues goStraight(); //on the same row }

www.robosoftsystems.co.in

SWARM Robotics
if(nexty == previousy) { reverse(); goStraight(); } } //checkpoint reached turn back

www.robosoftsystems.co.in

SWARM Robotics
if(currentx > previousx) //robot has come from below { if((nextx > currentx) && (nexty == currenty)) { goStraight(); //robot continues on same column } if((nextx == currentx) && (nexty < currenty)) { turnRight(); //robot makes a right turn and continues goStraight(); //on the same row }
if((nextx == currentx) && (nexty > currenty)) { turnLeft(); //robot makes a left turn and continues goStraight(); //on the same row }

www.robosoftsystems.co.in

SWARM Robotics
if(nexty == previousy) { reverse(); goStraight(); } } //checkpoint reached turn back

www.robosoftsystems.co.in

SWARM Robotics
if(currentx < previousx) //robot has come from up { if((nextx < currentx) && (nexty == currenty)) { goStraight(); //robot continues on same column } if((nextx == currentx) && (nexty < currenty)) { turnLeft(); //robot makes a left turn and continues goStraight(); //on the same row }
if((nextx == currentx) && (nexty > currenty)) { turnRight(); //robot makes a right turn and continues goStraight(); //on the same row }

www.robosoftsystems.co.in

SWARM Robotics
if(nexty == previousy) { reverse(); goStraight(); } } //checkpoint reached turn back

www.robosoftsystems.co.in

SWARM Robotics
if(currentx == previousx) //robot is where it was { if((nexty < currenty) && (nextx == currentx)) { gostraight(); //robot continues on same row } if((nexty == currenty) && (nextx > currentx)) { turnleft(); //robot makes a left turn and continues gostraight(); //on the same column }
if(nexty == currenty) && (nextx < currentx)) { turnright(); //robot makes a left turn and continues gostraight(); //on the same column }

www.robosoftsystems.co.in

SWARM Robotics
if(nexty == previousy) { reverse(); goStraight(); } } //checkpoint reached turn back

www.robosoftsystems.co.in

Vous aimerez peut-être aussi