Line Tracing
We use a PID algorithm for our line tracing. The light array on the bottom of the robot returns a position on the line. From this, we can find an error, because the line should ideally be in the center of the robot. We put the error through three mathematical functions, a proportional function, an integral function, and a derivative function. These combined give us a correction to put on our motors, which makes the robot accommodate. |
Gap Detection/Sharp Turns
Our robot used to have an issue with sharp turns. It would think that it had to go in the opposite direction the turn actually went. Upon seeing that there was no line there, it would think the situation was actually a gap and turn back around to catch the line again. To fix this, we made a change to the gap detection's algorithm. |
We made it so that if the robot thought it saw a 90 degree turn, it would turn in the direction it thought. Then, seeing that there was no line there, the robot would turn back more than 180 degrees the other way. This way the robot would get the line again if it was a sharp turn. If it still didn't see the line, it would know that it was a gap and face forward again and move forward, looking for the line.
|
We first put a mask on the frame the camera received, using an HSV filter tuned for the green squares. We then found contours on that mask, and ruled out the contours that were too small, to eliminate noise. Then, we looked at the areas directly above, below, to the right of, and to the left of each contour to see if the line was present there.
Based on this, we could tell the position of each line in relation to the intersection. |
Obstacle Avoidance
When the robot's ultrasonic sensor saw an obstacle, it first has to find out which direction is safe for the robot to go in. To do this, it first tests one side. If that side is clear, it continues that way. If not, then it turns 180 degrees and goes that way. Once it decides which way to go, it moves and turns in a square until it sees the line again. |
Silver Detection
The algorithm for detecting similar is much like detecting the green squares. First, an HSV mask is applied to the frame. This HSV mask keeps a tight range on the Hue, because silver shows up gray on camera, and thus shouldn't have much hue. Then, the Value is kept near the middle, to rule out the black line and the white background. Then, contours are found on that mask, and the smaller ones are removed. If there is still a contour of a considerable size, then the robot concludes that it has reached the silver. |
Evacuation Room
Once the robot has entered the evacuation room, it turns around looking for victims. Victims are detected by the camera. Adaptive threshold and dilation of contours is used to identify a ball as silver(alive) or black(dead). The silver balls are prioritized, and once a victim has been found, the robot turns around scanning for the evacuation point. It then goes to the evacuation point, drops off the victim, and looks for the next one. |