Lab 4: RF Communication, Navigation and Final Demo
Objectives:
- Implement RF communication between the robot and the base station.
- Implement a navigation algorithm to navigate around the maze.
- Implement feedback control for the servos.
- Combine all of the elements we have been working on for all the other labs.
- Trigger the robot movement based off of a specific tone.
- Move around the maze, measuring IR beacons and sending the frequency to the base station.
Materials:
- 1 robot and circuits from previous lab
- 2 RF PCB adapters
- 2 4-pin headers
- 2 3-pin headers
- 2 8-pin header receivers
- 2 RF transceivers
- Wires
RF Communication:
We first soldered pins to the RF PCB adapters so we could insert them into our breadboards. The component can be seen below. Once this was done, we programmed the robot and base station to communicate using the transceivers. We first sent the time between the two devices, as seen below.
Navigation:
We then started working on a navigation algorithm for our robot. We initially tried to implement a depth first search. We implemented an algorithm to do this based on the ultrasonic sensor readings. We wrote a test code to send simulated distances based on a maze layout. Unfortunately, the ultrasonic sensors were not as reliable as we had hoped. As a result, the robot would mistakenly think that there was a wall when there was not or vice versa. As such, we switched to a simple right wall follow approach, as this is more robust to errors. The DFS approach would be unable to resolve mistakes if it loses track of where it is in the maze, but right wall follow does not have this issue. We worked to ensure that it would handle cases where it needed to turn left, as well as preventing the robot from just turning around after a left turn.
PID:
We also implemented PID for the servos. This again suffered from the same issue, where the unreliable measurements from the ultrasonic sensors affected performance. Additionally, the servos themselves were very inconsistent. As such, settings that worked at one point would fail a few hours later. Below is a video of one of the more successful tunes, but unfortunately it was not this good for our final demo.
IR Measurement:
We used the basic IR code and circuits from the previous labs to measure the IR beacon frequency. I also implemented a new feature that helped improve the results, automatic IR thresholding. The robot would switch the ADC to the IR sensor pin and measure the voltage from the ambient light. We would then multiply that by a constant and use that as our threshold.
Final Demo:
A video of our final demo can be seen below. The PID did not perform particularly well. The long distance between some of the walls also made the ultrasonic sensors unreliable, so the robot spent a lot of time randomly turning. Despite this, we successfully measured the frequency of the two beacons on the fly. The largest failure was that it did not stop after measuring the second beacon, which is strange because it did so in testing.