The goal of the project is for a robot to drive through a road map, avoid obstacles and follow traffic regulations. When the robot sees a traffic light it should be able to notice that it has seen a traffic light and obey it. If the robot sees a red traffic light it should stop and when the light turns green it should move forward and navigate the road map until it reaches its destination. A user should be able to input its start point and destination using a mini keypad. The robot will use Dijkstra’s algorithm to aid its path planning.
In order for me to make this project work successfully I came out with a milestone. This is to guide me through the project and know whether I am making progress or not. My first milestone is to be able to use a camera to detect traffic lights. In my case the traffic lights are paper colors. These colors are red and green. Where red would stop the robot from moving and green would make the robot move. My second milestone is to implement Dijkstra’s algorithm and make the robot plan a path and find the shortest path from its source to a specified target. My third milestone is to put milestone one and two together such that I would have the robot to move from its source to its target through a road map which would be a graph and when it sees the traffic light and the traffic light turns red then it would stop and when the traffic light turns green it would continue and find the shortest path to its target.
I started by working with the NXT camera. With the help of some source codes online I was able to use the camera to detect two colors that I used for my traffic lights. I installed the drivers for the program and a program called NXTCam_v3p0. I used this program to help me detect the colors for my traffic lights and uploaded it into the camera. Below is an image of the NXT camera.
After, the camera worked I proceeded by implementing a priority queue that a colleague of mine programmed. Before I implemented the Dijkstra’s algorithm, I created my road map with 8 nodes. I realized that the map was too big for my environment and the turns of the angle of the map varies and not consistent and would not make the robot turn accurately, so I changed it to a six node map with 45 degree turns. Below is the figure of my road map.
In order to represent the nodes and the distance properly I created an adjacency matrix as my map. I created a state in the priority queue to help me store the vertices and the distances in the map. With the help of the priority queue I was able to implement the Dijkstra’s algorithm. I extracted the path by creating an array and initializing all the items in the array to -1 and then storing the target as my current position and then iterating through the path that has been created by the Dijkstra’s algorithm. After I have extracted the path I created a navigation function for the robot. This is to help the robot know its orientation and then be able to move to the shortest path successfully.
The robot was able to find the shortest path from its source to its target. I had challenges getting the right measurement for my distance. I was not able to implement the traffic light system due to time constraints. I also had a bit of challenge in getting my orientation right.
The task was challenging and it has really made me think through the logical flow of codes. This project has been able to help me to think through algorithms properly before I implement them.