Muhammad Arham
Lego Robot Autopilot
Purpose: Our original proposal was to write a program that allowed a Lego robot to follow a path and stop if it ran into an obstacle, but with recent advancements in vehicle autopilot systems in cars such as the Tesla, we thought it would be interesting to see if we could make a fully autonomous autopilot program for the Lego robots with a collision/obstacle avoidance component. The project goal was to design a code to allow the robot to ‘think’ for itself in real time by being able to find and follow a path already laid out for it (simulating a road) and automatically avoid any obstacles in its path and continue along the path while controlling speed depending on the proximity of those obstacles. Our code includes various safety features other than obstacle avoidance system. For example, if the touch sensors detect a collision the robot stops, theoretically this should never happen if the robot is programmed to avoid obstacles but the ultrasonic sensors on the robots aren’t always reliable and the obstacle could be out of the detection range of the sensor. Another safety feature is the speed control, if the robot detects an obstacle, its speed varies based on the obstacles proximity, so it slows down as it approaches the obstacle. The program is also coded to warn others and get their attention when maneuvering around obstacles, the LED display turns red, the headlight turns on, and a turning signal is activated (the top mounted motor spins).
Method: The program includes the use of the colour sensor, the ultrasonic sensor and the two bump sensors and all four motors. It uses the colour sensor to detect the path it needs to travel. The colour sensor reads the line and returns a value between 1 and 8. From the value returned it will then correct left, correct right or continue to go straight. This is done using a series of condition statements that checks the light value returned from the colour sensor and tells the motors to go a certain speed. The ultrasonic sensor is used to detect how far objects are away and the robot acts accordingly. If and object is greater than thirty centimetres away it will continue to execute the the line following algorithm at regular speed. When the object is between thirty and fifteen centimetres away it will slow its speed while still executing the line following algorithm. It will also start to warn people by displaying a message on the screen using a built in function and turn the LED colour to flash orange. When and object is less than fifteen centimetres away the code will go into another while loop that will avoid the object using a series of turns while turning the head light on and flash the LED red. This is all done by constantly checking how far objects are away in the various loops. The robot is able stop when an object goes undetected by using the bump sensors. If the robot is hit by an object, the bump sensors will detect it and stop immediately. This is done using a conditional statement. If the right or left bump values return a value of 1 then the robot will stop and end the code after playing a song and displaying a message. Muhammad worked on the Vehicle avoidance system part of the code and the bump protection. Miguel worked on the line following algorithm as well as structuring the loops and variables to read the different values at the correct time.
Conclusion: The robot was successful in our trials. The code could be more efficient by using more functions for more unexpected scenarios but it worked for our purposes.