Robotic Tug Boat
This project was for my Fundamentals of Robotics course. As a group we were tasked with making three overarching functions: Hunt, Follow and Avoid. Hunt's task was to make the boat rotate back and forth in place, scanning the entire area in front of it trying to find a pink narwhal stuffed animal. Follow does exactly that, it turns the boat so that it can follow the narwhal. Avoid's task was to keep the boat safe by detecting obstacles and guiding the boat around them. We also needed an Arbiter to pick which outputs to obey.
I worked almost exclusively on the Follow function and the other sub-functions needed to make it work properly. The first thing we needed to get working was the detection of the narwhal. To do this we used a PixyCam which has built-in computer vision capabilities. Setting up the PixyCam to only recognize the narwhal took a large amount of time. Eventually we got the number of false detections to be basically non-existent. The sub-function returned a custom struct object containing information on if the narwhal was in frame as well as its x position, its y position and its angle from the center of the camera. This information was then used by the Follow function to track the narwhal and send a heading value to an arbiter.
I also worked on the arbiter. All 3 of the overarching functions output an array representing -90 degrees to 90 degrees. The arrays contained values from -100 to 100 that represented each function's preference on where to turn the boat (100 being strong preference, 0 being neutral, and -100 being strong preference against). The arbiter took these outputs and let them interact constructively. The resulting largest value would correspond the the ideal heading and the arbiter would send that to the motors to turn the boat.
One thing to note is that, to avoid conflict, the arbiter also contained a state machine where it would ignore the Hunt output if there was a narwhal detected and would ignore the Follow output if there was no narwhal detected.