The goal of our project was to design a robot that would stop 20 cm from the wall using both a bang bang control and a proportional control. Our robot, the Batmobile consists of two motors to drive it forward and an ultrasonic sensor in the front to detect the distance from the wall.

For the bang bang controller, we programmed the robot to move forward until is reached 20 cm from the wall. Once it reaches this point, the robot is programmed to break and then automatically terminate the program.

Using a proportional control, we created a separate program that allowed the Batmobile to come to a more gradual stop. The Batmobile was designed to start slowing down proportional to its distance from the wall at 40 cm and come to a complete stop at 20 cm. The robot is also designed to work in the reverse. If it is placed too close to the wall (less than 20 cm), the robot will back away from the wall and come to a gradual stop 20 cm from the wall.

Image Image Image

Above is the code for the bang bang control and below is the code for the proportional control.

Image