Control and Sensing System:
These systems are for the robot to control its speed and position relative to information it receives.
Speed and Position Control:
For Position Control, I first had to implement a Speed Control and ultimately decided to do so for both wheels. The idea was to use one of the speed controlled wheels for the use of the position control. The ultimate purpose of this was to have the robot stay as close to the middle of the hallway as possible. This way, any amount of wall following would not result in the robot getting stuck.
I needed to set up the encoders in a way where I could find the max speed of one of the motors. Here, I needed to find the number of pulses per revolution, measure the wheel diameter for later, and find the frequency. This way, I would be able to control the velocity. At around 80% speed, I was able to find a frequency of around 600Hz.
Code snippets below:


The button and picture just below are about the Ultrasonic Sensor.
