How graph algorithms can be used in line follower maze solving robot. I have solved grid using DFS search but do not know how to implement it actual line follower robot. my shortest path finding implements on a 20 by 20 grid . where s= start and g = destination and numbers denotes the position of each point inside the grid (row by row basis).
-
How can anyone tell? What robot is that? What its API? – zmbq Sep 15 '14 at 21:16
-
Since i am a new user ..i could not upload image (sorry for that !!!) ...it is simple AVR uc based line follower robot..programmes written in c++ and detection of line is taken care of by the array of sensors (infra red sensor)(simple follow line method is working perfectly) – Debashish Sep 15 '14 at 21:19
-
So try describing it in English. – zmbq Sep 15 '14 at 21:19
-
detection of line is done by six array sensors ... grid is a square grid (say 8*8..) ...some 4 way node points are blocked and others are free. out of all those node points there will be one start point and one goal. Task is to reach goal in minimum steps. – Debashish Sep 15 '14 at 21:29
-
please elaborate if you dont mind – Debashish Sep 15 '14 at 21:33
-
1"I have solved grid using DFS search but do not know how to implement it actual line follower robot." What does this mean? Did you or did you not implement DFS, and if you did, you've already implemented it, so what exactly are you struggling with? – wookie919 Sep 15 '14 at 23:52
-
@wookie919 .... i think you have noticed the line follower robot problem that i have mentioned – Debashish Sep 16 '14 at 04:02
-
provide more info about maze (planar,3d,..?) how are the crossroads (line followers usually have either `+` or empty space there, also what is your map representation etc... does not mater how your bot is looking we need to know what movement it is capable off also you can post image elswhere and provide link to it some of us will copy it here then if you ask for it... – Spektre Sep 16 '14 at 06:20
3 Answers
-If you are a beginner to microcontroller, then i would recommend you to first achieve in making your robot follow the line .
-If robot performs well in line following then you should try it in making your robot pass the strips(junctions in the grid) and make your robot transverse complete grid(all co-ordinates of the grid), simultaneously you can make a count of number of strips the robot passed(you can use two dimensional array to store there co-ordinates).
-If you can achieve the above two tasks then you are good to go for applying your logic in solving the maze inside the grid.

- 659
- 10
- 23
-
Thanks !! .My line follower robot is working perfectly (in following a line or loop etc. ). i will consider your method. What i need is how to scan the grid (1st trial) -- Store it -- eliminate the redundant turns or paths -- then follow the shortest path in the next trial . (to keep it simple the algorithm is the main concern) – Debashish Sep 17 '14 at 14:00
-
-
You need to store the co-ordinates and their status in separate variables(globally declared and it can be array) during the dry run(1st trial). On the main run the robot should make a decision before passing to the next hop(node) by grabbing the data from the stored variable and checking its status. – Harsha Sep 18 '14 at 05:38
I once implemented shortest path algorithm on AVR board.
Here are the steps that you should follow.
Step 1: Do a dry run of arena and save all coordinate in an 2-D array. As you have described, there seems to be two type of junction. Make sure to blink a different LED on board every time you pass a junction. This way you can make sure that you are reading the board correctly.
Step 2: Now you have all the coordinates in a 2D array. You are applying DFS. I would not recommend that. since you have a grid not a tree to solve. Use Dijkstra's algorithm.
Implementation of this should not be hard. As compiler of AVR is very much similar to C.
Step 3: Now follow the result. lets day you have a 8*8 array. define a numbering from 1 to 64. your output should be in form of
1 9 10 18.... so on
Now calculate difference between two adjacent number
8, 1, 8 and so on
and fix a move for every number like for 8 go on left , for 1 go north. Just keep your current direction in mind to make move to other direction. Like going north from west would be different from going north from east.
Again I would recommend you to display your final result on LED first. Sometime your algorithm works fine and hardware stops working.

- 2,124
- 4
- 24
- 46
Shortest path algorithm for line follower robot, which do not involve loops in the line are relatively easy to implement.
It can be made by exhaustively traversing through all possible routs, making a default left/right turn at every decision making point. This way if there are no loops in the track, the robot will eventually get to the destination. The robot should keep track of all the turns that were made until the destination is reached.
After that it is a matter of reduction to eliminate the unnecessary turn the robot had made. I have discussed this shorted path algorithm in detail at my blog here.