Robotics 2: 315P (High Stakes) | ||||
|---|---|---|---|---|
| đ¨THIS IS A TECHNICAL POSTđ¨ This is the second part of what will soon become a four- or five-part series. The first two parts are about my time on the robotics team 315P. Here are the previous posts: Preface: For much of the Over Under and High Stakes seasons of the VEX V5 Robotics Competition, I served as the lead coder for the middle school team 315P. This post is a collection of my thoughts about working on it :) Season 2: High Stakes#Luckily for whoever is still reading this, there are no more cringe blog posts for you read 𼳠After we had finished celebrating our awards, we began working on our robot for the next season, High Stakes. I wonât bother going through the game or the evolution of our robot again, but for reference, here is a description of the game. Iâm not going to write a sonnet about my time on the team again, but Iâd instead like to dive a little more into some technical details in this section. Iâll go in order from the bare metal to the code I wrote. Kernel#Any and all code I write for the robot runs on the VEX V5 brain:
Typically, these binaries are built and uploaded through VEXâs proprietary IDE, VEXcode, or its corresponding VScode extension. However, there is also a division of VRC called VEXU, which is a collegiate-level version of the competition with more coding, two robots per team, and a few other different things. It turns out that Purdue University has a VEXU team, BLRS the Purdue ACM SIGBots (one of my all-time favorite teams :D), and clearly college students have too much time because they wrote their own operating system for the V5⌠PROS#PROS (either Purdue Robotics Operating System, or the infamously recursive PROS Robotics Operating System) is a custom RTOS built on top of the V5âs VEXos kernel by the Purdue Sigbots team. It looks something like this:
âWait but this is just what VEXcode does đ¤â⌠yes, that is true. However, PROS is chosen by the top teams for a number of reasons:
This is hopefully enough to convice anyone to switch to PROS! Time to go one abstraction level higher. VOSS#VOSS is a PROS library which includes utilities for robots. It contains quite a few utilities:
Each of these things on its own isnât super hard, but VOSS packages them all neatly into one, well, package. There are other libraries in this space, like LemLib, but I chose VOSS for our codebase because 1) it supported the newest PROS version (4.0), 2) it was written by Purdue SIGbots, who also maintained PROS, and 3) it had an intuitive and well-structured API that put my code to shame. VOSS is truly magic; it replaces about two hundred lines of odometry code, followed by dozens of lines of path planning math, followed by another hundred lines of PID controls, with this:
Itâs honestly insane how much thought the SIGbots team put into this, so please give them a â on Github :) My code#All of the above work is either of VEX or the SIGbots, so itâs finally time to dive into my code! All of the code Iâm talking about is from this repo. My code is honestly very simple, less than 500 lines, so this overview ought to be pretty short. Level 1: Wrappers VOSS provides an excellent API surface to build off of, but at the time of writing the initial codebase, the team was considering adding another coder, and to simplify their onboarding, I decided to write yet another wrapper over VOSS which abstracts even more away. Namely, it handles the motor setup, odometry parameters, etc., and limits the number of functions that could be called (as a means of enforcing that other coders wrote appropriate code). Here is a basic header containing basically the entire wrapper API:
This is quite the shortening from the ~100 public functions that could be called from VOSS. If I wanted to execute a particularly customized motion in a routine, however, I would directly call a VOSS function. A briefly explanation of what each namespace contains:
Now that this is all out of the way, letâs explain a bit more about the autonomous selector. Level 2: The autonomous selector and autonomous routines As noted in the first blog post, V5RC matches start with a 15-second autonomous period. This is where the code I write gets executed (there are only ~50 LOC dedicated to running in the driver control period). Strategy in High Stakes is very important; for example, if teams do not coordinate their autonomous strategies, both robots could try to score on their alliance stake at the same time and clash, preventing either one from scoring and messing up the rest of the autonomous routines. Thus, a number of different routines, colloquially known as âautonsâ, are needed. There is, of course, also a need to choose two things at the beginning of a match: which auton to run, and what side the robot is on (blue or red). The latter is important because in High Stakes, the field is symmetric by reflection (while the Over Under field was symmetric by rotation), creating the need to âmirrorâ the turns of an autonomous routine if it switches sides. This was handled by our selector, which ended up looking like this:
When the field control told the robot to run its autonomous, whichever routine had last been clicked on was run. The code for autons themselves look something like this:
Thatâs basically all I have to say about the robotâs codebase. Hope some of these details were helpful! Epilogue#Due to internal frustrations with how the team was being managed and the lack of focus on coding, I left the team in October 2024. As for the future of the team, they recently qualified to the World Championships by getting a design award at states. Unfortunately, their coding is in limbo at the moment as multiple other coders have left the team or are busy with other extracurriculars. As noted above, to preserve my original code (entirely written by me, with no external authors), I have cloned the repository at the time of my leaving the team in this MIT-licensed repo. Hope this post was helpful/inspiring/something! Footnotes#
|