FRC Robotics
I was part of FIRST Robotics Competition Team 447 for the 2017-2020 seasons. I acted as a programmer for each of those years, as safety captain for the 2019 and 2020 seasons, and as a technician as needed. During the 2019 and 2020 season we also developed a scouting app for competitions.The 2017 Season
During the 2017 season we used LabVIEW to program our robot. This is a visual signal based programming language. We had a ball shooter, gear placer, and rope climber. For the first section of a match, the robot moved autonomously, without any human input. After that, the robot was controlled remotely by game controllers. We implemented the autonomous section and the controllers. I focused on a computer vision system for the ball shooter, a system for making autonomous setups, and tuning PID loops for our shooter. Unfortunately, I do not have the code for this season.The 2018 Season
Code (GitHub)
During the 2018 season we began using Java to program our robot. This provided a much more traditional system which was easier for us to program in. We also created "bling" for our robot in the form of an LED matrix. While I helped with the code for the robot, I worked more on the bling, and on the conceptual side of the code. I developed the command system for our bling as well as writing a very primitive bitmap (.bmp) file parser. This allowed us to generate many different patters quickly which was particularly useful for working with other teams. This year we competed at FIRST Championship - Detroit, colloquially known as Worlds.The 2019 Season
Code (GitHub)
The 2019 season did not have a full autonomous mode, rather a 15 second period with a curtain blocking the drive crews' view. This made the challenge less about fully automating this section, and rather creating tools to make it easier for the drive team during this time. This made the programming side significantly easier, but also less interesting. We did not end up using vision significantly, as it was easier to focus on the drive team.The 2020 Season
Code (GitHub)
Bling Code
Our Best Programming Year
The FRC season starts in January and Worlds is in April. Obviously, we all know what happened during that time period in 2020, but regardless I still regard this year as our best programming year. Beyond me and the other programmer having far more experience, the rules were changed this year allowing for work on the robot throughout the season. Before there was a build season, and after that, we only had so much time we could work on the robot between competitions. In 2020 we could work on the robot any time we wanted. Given that our mechanical and electrical work was done well before the old end of the build season, this gave us more of time to work on the code, even with our season being cut short.
Vision and PID Loops
This year our biggest improvement was in our vision system. Previously, we had done some vision work, but not nearly as much as we would this year. This years game involved shooting foam balls at a target. This target had a large outer hole, and a smaller inner hole which was worth more points. Around the outer hole was some retro-reflective tape. We built a turret for our robot which used a flywheel to launch the balls. Our goal was to be able to make shoots in as many situations as possible.
We used LED's to illuminate the tape in a specific color, which the camera could easily distinguish from the surroundings. We used a Raspberry Pi running Chameleon Vision. This allowed us to focus on using the data from the vision system, rather than the vision system itself.
One of the most important parts of using the data from the vision system was controlling motors. The turret needed to be aimed and the flywheel needed to be speed up to a specific speed. To accomplish this we used proportional–integral–derivative (PID) loops. Given that I was learning calculus at this point, I implemented my own PID loop, with optional feed-forward, in order to understand how they work and how to use them. For the flywheel, I used linear feed-forward to approximate the PWM value needed to maintain a speed, and then used the PID loop to tune it more precisely based on feed-back from encoders. For the turret aiming, I used a PID loop.
I also made several Python scripts to help us tune the PID loops and feed-forward. For the feed-forward on the shooter, I simply set the motor to several PWM values, took the speed that caused the motor to run, and did a regular regression on that (note that the speed was considered the independent variable because we used this to calculate a PWM value from a speed). For tuning both PID loops I used the Ziegler–Nichols tuning method. This required setting the PID loop up to oscillate, and finding the amplitude and period of the oscillations. This was then used to calculate the terms. This system formed the core of our turrets ability to shoot. Further systems were set up to reset the integral to avoid runaway integral.
Further scripts were made to help calibrate the speed of the flywheel needed to shoot a specific distance. These were more manual, increasing and decreasing the speed until it hit, then using that in a regression. This was also linear, although that was imperfect. I remember doing math to determine the actual relationship, but it was never implemented into our code.
Although not fully implemented, I also had begun work on adjusting our aim and shooter speed based on the movement of the robot. This would have allowed us to move and shoot, including during turns, but this was not implemented because of time restraints.
Video of Vision Based Shooting
Scouting System
This year we made our most advanced scouting app yet. A major issue with previous years' scouting apps was that the data had to be moved manually from the app to a computer, then processed, then given to the drive team. This year, we added a web-server to our scouting system. This allowed us to automate the process of moving and processing the data, provided an up-to-date view to the drive team. Although this was a major improvement, it did come with some challenges.
A major challenge was that WiFi was generally not provided at competitions, so we had to make our apps work with mobile data. Furthermore, our scouting tablets did not have mobile data. To solve this, we implemented a data format which could be used as a URL parameter. Then we converted the URL into a QR code which could be scanned by someones phone. This would send the data up to the server using their mobile data.
The next challenge was actually collecting the data. In general, our scouting was split into two section: pit and match scouting. Pit scouting involved asking teams what they could do before the start of actual matches. Match scouting involved watching what teams did in actual matches. Implementing pit scouting in the app was relatively simple because it was mostly a survey, and had relatively loos time constraints. Match scouting, on the other had, was far harder to implement. Many things would happen during a match, making it imperative that it was quick to enter information. We also wanted information on where teams were shooting from, so we had to implement an input method for that. In the end, we had a map of the course that could be touched to represent the position they shoot from. Most other information could be added by pressing a series of buttons on the display. At the end of the match, the QR code would be displayed to send the information to the server.
The next major challenge was displaying the data to the drive team in a concise manor. The server was run node.js with TypeScript, which neither me nor my coding partner were supper familiar with. Moreover, we used mostly raw JavaScript, HTML, and CSS to write the webpage that was used to view the data. This required us to implement many things manually. We did use handlebars for templating and d3.js to display the positions where teams were shooting from. We also implemented a system for approximating what score an alliance would get. If I were to redo this, I would likely use Python on the back-end given my familiarity, and the many statistics and visualization tools available on Python.