Background
This was my fourth season competing in FRC, and my second season on team 9432 after founding the team in 2024. As a homeschooled kid working with a small team out of my family’s garage, I was able to invest a lot of time into FRC during the competition season, both leading the design of and writing the software for this robot. Everything was built in nine short weeks between the game reveal and our first competition.
The Challenge
The playing field 1 / 2
The game this robot is built for, Reefscape, tasks teams with clearing Algae (16” diameter playground balls) from their alliance’s Reef, then filling the Reef with Coral (4.5” diameter PVC pipe).
The Reef has six sides, each with two poles. Each pole has three branches for scoring Coral. Each pair of poles starts with an Algae between them, blocking some of the lower branches until it is cleared. Algae removed from the Reef can be scored in the Barge (a tall net spanning the center of the field), or put into the Processor opening near the floor.
Robots collect Coral from stations in the corners of the field, where human players roll it down a ramp either onto the floor or directly into a robot. At the end of the match, teams can lift their robot off the ground by climbing one of three Cages hanging underneath the Barge for extra points. More details can be found in the short game overview video.
Design
Our robot is designed to complete all the scoring tasks in this game. Coral is dropped into a large funnel and guided to our scoring arm, which is mounted to an elevator that extends upwards and gives the arm the reach necessary to score anywhere on the field. The arm is dual-purpose, and in addition to scoring Coral, it collects Algae from the Reef and scores it in either location. Stowed beneath the funnel is our climber mechanism, used to suspend the robot from a Cage to finish the match.
The robot was designed fully in Onshape, and the model is viewable online.
Scoring Arm
The scoring arm is designed to control both game pieces, while being as lightweight and simple as possible. It uses a mechanical four-bar linkage with some clever geometry to solve the toughest design challenges we faced. As far as our team could tell, this style of scoring mechanism was a unique approach to solving the game’s problems; we didn’t see any other teams with a similar design.
This has the added benefit of lifting the Coral above the top of the elevator with the lightweight arm instead of additional heavy elevator stages.
Another challenge we faced was finding a way to consistently align Coral within the arm. If a Coral isn’t loaded far enough, it will hit an elevator crossbar when the elevator tries to extend upwards, jamming and potentially breaking several things. Our solution was to add a small metal plate at the very front of the robot, giving the Coral a mechanical hardstop to ensure it ends up in the same place every time. The plate is attached to the drivetrain, so it doesn’t affect anything when the elevator rises up to score.
Elevator
We used a “belt-in-tube” elevator to lift the arm and game pieces to every scoring level. This belted style of elevator is relatively standard in the FRC world due to its compact profile, enclosed rigging that minimizes the risk of damage, and low maintenance once assembled. I researched this design style a lot pre-season, and made several demo models of how we could execute it, so it was a fairly straightforward choice once the game was revealed.
More Details
Rigging
The elevator is driven up and down by a pair of belts routed through the box tubing used for the structure, hence the name “belt-in-tube”.
Supports
Our elevator supports take a fairly unusual approach of using sheet metal plates and box tube to create a frame that both acts as a crossbar and ties the mechanism into the drivetrain. The semi-standard way to do this is to use round tubing with endcaps and ball joints to build a more weight-efficient support, but we weren’t confident in our ability to manufacture or secure endcaps like that, so we went with the safer approach in the time that we had.
Funnel
The back of our robot is entirely dedicated to maximizing the collection area for Coral, which is dropped into the funnel from the stations in the corners of the field. It has powered belts running along the center to help orient the Coral and move it to the arm as quickly as possible. The large, low funnel was a distinctive feature, as it allowed the robot to catch new pieces even in the presence of obstacles, including stray Algae and defending robots from the opposing alliance.
Climber
Our Cage climber is designed to stow neatly under the funnel, a packaging solution inspired by team 6328. We combined this idea with a component published by team 118, a simple polycarbonate barb used to passively latch onto the Cage. The pivot mechanism itself is straightforward, using a commercial planetary gearbox chained to a piece of box tube holding both the plastic barb and a bar to brace against the Cage.
This was a late addition to the robot, and we tested it for the first time as we packed for our initial event. Despite that, it worked very well for the entire season. Almost every missed climb was due to driver misalignment, as it isn’t the easiest task and the unpredictable nature of the swinging Cage made it very difficult to automate away.
Drivetrain
We used a fairly standard drivetrain setup, choosing proven off-the-shelf “swerve” modules to minimize the risk a custom solution would bring. Each of the four modules on the drivetrain is an independent wheel that can steer itself to point at any angle. When all four modules work in sync, this lets the robot move sideways or spin while driving.
A key benefit of this is enabling field-relative control, where the robot can be driven as if it’s always facing forwards. Combined with the ability to move sideways, this makes it so moving the joystick up always moves towards the back of the field, left always towards the left, etc. This makes it very easy for the driver (and automated code) to properly align the rotation of the robot en route to a scoring location, removing the need to have a precise approach angle and making everything much faster.
Software
My primary goal while writing the software for this robot was to minimize human input. Working out of a garage, we didn’t have enough room to practice driving the robot in a competition-like environment. The solution to this was to automate the hardest tasks, drastically reducing the skill needed to drive at a competitive level.
By the end of the season, the primary driver had two main buttons: Score and Collect Algae. This means the main skill-based driver task is getting the massive funnel on the back of the robot close enough to the Coral station to catch a piece, and that’s not something that takes a lot of practice.
All our code was human-written in Kotlin, and is public on GitHub.
Simple Automations
I started by automating simple systems that could later be combined to make complex full-robot sequences. This let simple blocks be tested and proven as the robot was built, without relying on the full system to get things working.
Automated Mechanism Positions
It may seem like a small thing, but getting the robot to a point where you can tell it “prepare to score a Coral on the top branch” and it just does that takes a lot of work. Doing so relies on the arm and elevator being able to move to the specific positions we need them to, for example “move the elevator 30 inches up, and the arm to 45 degrees”. This is more than a little tricky, because at a basic level, you can only tell each motor to spin forwards or backwards with varying amounts of power, not spin to a position.
The simple explanation of this process is that we find the difference between where the mechanism is and where we want it to be using sensors built into the motors, and we give that difference to an algorithm called a PID controller which calculates the motor power necessary to move the mechanism where we want.
More about PID control
Fortunately this is a very common problem that applies to many things in the real (non-frc) world, and many solutions to it exist. Another good fortune, in our use case the motors are very overpowered relative to the work they’re doing, and we don’t really need to do anything fancy. This is good because the rabbit hole is pretty deep with this stuff.
The motors we use have a built-in encoder, which is a type of sensor that allows the code to know what position the motor is actually at. This is pretty important, as it would be very tricky to move a certain amount if you have no feedback to see what’s happening.
We give this position information to a simple algorithm to calculate the motor output needed to move the mechanism to a position. The chosen algorithm is known as a PID controller. Each of the letters stands for a different sub-algorithm which combine together for the final result. For our mechanisms, we only use PD control, standing for Proportional and Derivative respectively.
Proportional
The Proportional component is the most important, and is very simple, using a constant to map error (distance to target position) to motor output.
kP = tuned constant
error = (target position - current position)
P = error * kP
motor_output = P This basically tells the motor to go push really hard when it’s far away from the target, progressively less and less as it gets closer, then backwards as a brake once it moves past the goal.
Derivative
The D component of the controller works in a very similar way, but it looks at how fast the error is changing instead of the current position difference, then applies another constant. This means at the start of the motion, where the arm isn’t moving quickly closer to the target, it doesn’t do much. But as it picks up speed towards the target, reducing the error quickly, it helps stop pushing earlier, reducing the effects of the overshoot-and-brake strategy of the P controller alone. These two do most of the work, but we use a couple of other tricks.
Feedforward
For both mechanisms, we apply “feedforward” components to make tuning easier. The feedforward uses known properties of the mechanism such as weight to predict power needed, as opposed to just reacting to feedback from a sensor.
The first thing we did on both mechanisms was slowly apply power to the motors until we found the minimum required to overcome friction, attempting to mitigate gravity by tipping the robot sideways and such. By applying this amount of power whenever we’re trying to move, we essentially make the mechanism frictionless from the perspective of the PD controller, making it that much easier to tune.
We also attempt to compensate for gravity by applying a value based on the weight of the elevator, and a number calculated for the arm based on its weight and current position. This number attempts to hide the effect of gravity, again making the feedback controller easier.
Full Calculation
Here’s an example of the full controller for the elevator:
kP, kD = tuned constants
error = (target position - current position)
P = error * kP
error_difference = (error - last_loop_error)
D = error_difference * kD
kS = output needed to overcome static friction
kG = output needed to hold against gravity
motor_output = P + D + kS + kG For the arm the only difference would be replacing kG with cos(arm_angle) * kG.
This accounts for the fact that holding the arm straight up or down takes zero effort, but holding it straight out takes a lot.
This runs 1000x a second on the integrated motor controller. This speed is important as it gives plenty of time for the motor to figure out when it is getting close to the goal and needs to stop. It would be much harder if we were only updating it once a second for example, as it would move well past the goal before it realized it needed to reverse or slow down. Spoiler alert, this is a problem with other things later! (see Software Issues below)
Motion Profile
You probably thought you were done reading the tedious math section, but there’s one more thing!
The final trick we use for position-controlled mechanisms is a motion profile. Basically instead of saying “go from A to B”, we use a motion profile to say “go from A to B at C inches per second”. The plain controller above works well if you always want to go as fast as possible, but it doesn’t have any kind of speed control. In theory going fast is nice, but in reality a smooth and controlled speed up and slow down often works much better. The motion profile works by moving the target position from point A to B in small steps instead of an instant jump. These steps are still given to the PD controller as target positions, and it moves to follow them the same way it would a large jump.
Beyond the issue of getting them moving, coordinating the mechanisms so they don’t crash into each other or the rest of the robot is a whole separate class of problem. Long story short, we needed (and found) a way to sequence movements to go from any position to any other position, moving the arm and elevator in the right order to avoid all the obstacles.
Mechanism Sequencing
Our solution for this is a somewhat modified version of an idea presented by team 6328 here. In essence, we define a list of all possible states the pair of mechanisms can be in, and all the valid transitions between them. The robot then moves step by step through these transitions to get to the target state, sometimes moving the arm first, sometimes the elevator, sometimes in parallel.
For example, to go from stowed to scoring a top Coral, the robot will move from the Stowed state to the Arm Above Bumper state, then to the Score High state. The transition from Stowed to Arm Above Bumper is defined as being elevator-first, so the arm will wait to swing up until it is clear of the bumper. We know the arm is clear once the robot is in the Arm Above Bumper state, so the transition from there to the Score High state lets both mechanisms move in parallel. We have a unit test set up to make sure every state always has a valid path of transitions that can reach it from any other state.
Automatic Game Piece Detection
The robot tracks which game pieces it is in possession of to enable even more automated behavior. When Coral reaches the end of the arm it is pushed into the hardstop, causing the motor moving it to slow down. This is detected by the code, which automatically moves the arm and elevator to prepare to score. Before the championship, we added an IR beam break sensor that could react slightly faster without relying fully on tracking the motor speed.
When an Algae is collected, the robot uses a similar method to detect it, with one twist. Unlike Coral, to hold Algae securely we need to apply a small amount of power to the rollers to constantly pull it in. Algae is also too large to fully fit in the front of the robot, so the elevator remains up slightly, holding the Algae outside the robot. This means that it can bump things as the robot drives around, and is occasionally knocked free by an unlucky hit. Rather than relying on the drivers to react to this, the robot will detect the lack of resistance in the rollers when it is supposed to be gripping an Algae, and automatically reset if it drops.
Field Localization
All game fields have a set of AprilTags, which look like small QR codes and basically allow the robot to figure out exactly where it is on the field based on a photo. We have two cameras on the front of our robot running PhotonVision, a community program to continuously take and process photos to find the robot’s position. They are carefully positioned to ensure we have a view of the tags while driving up and aligning to any of the Coral scoring locations.
Knowing where the robot is on the field enables many automated features. Most importantly, it acts as a feedback sensor for the drivetrain, letting us drive automatically to any location on the field using a PID controller like the arm and elevator. It is also used for several other things. The robot uses this position to ensure it is always far enough away from the Reef before swinging the arm up and down to avoid collisions. When scoring, it also immediately drops the game piece once the robot is aligned, without needing to wait for a driver reaction.
Complex Automations
We combine the above building blocks to bring functionality to the two main driver buttons. Scoring height (for Coral) and location (for Algae; Barge vs Processor) are selected by the secondary driver, so the robot always knows what its next target is.
Once a Coral is detected, the arm and elevator will immediately rise to the selected scoring height so scoring can happen as soon as the drivetrain is aligned. When the Score button is pressed, the robot will drive to the nearest pole and place the Coral at the preselected height.
When the Collect Algae button is pressed, the robot will drive up and collect the Algae from the nearest Reef face. If the button is pressed directly after scoring a Coral, the robot will automatically back up and lower the arm at a safe distance before moving in to collect the Algae.
While the robot is holding an Algae, the same Score button can be pressed and the robot will drive to either the Processor or Barge and score there.
Once any of these automated tasks complete, the robot will instantly begin driving away and resetting itself. This seamlessly continues the match flow, moving back to driver control when the joysticks are touched.
Autonomous Routines
The first 15 seconds of each match are played fully autonomously, with zero input from humans. One major benefit of automating so much of the human control was that it made it very easy to create routines for this period. Each of our autonomous routines simply chains together the existing automations to drive from place to place, pick up, and score game pieces. This can be seen easily in our Algae routine where we preprogram the scoring locations, then essentially press these driver buttons virtually: Score, Collect Algae, Score, Collect Algae, Score. This behaves exactly as it would if a human were to press the same buttons during a match.
Final Notes
Issues
This was easily the most reliable robot from any of my seasons competing in FRC, but that’s certainly not to say it didn’t have issues.
Another small improvement we could’ve made was stiffening the arm linkage to make it easier to control. The linkage worked very well, and was nearly indestructible, but it likely would’ve scored a little more consistently if it were more rigid (see software issues below). A straightforward upgrade would be replacing the nearly solid 3/8” hex shaft at the top of the linkage with a much stiffer thin-wall circular tube of the same weight.
Software Issues
Our software worked without problems for the most part, and almost all the issues we had came from the same root cause. JVM languages like Java (standard in FRC) or Kotlin (which we used) periodically need to trigger a garbage collection to free memory. The main on-robot computer every team must use has very limited memory and a slow processor, so this process usually takes ~50-100 milliseconds and happens many times a match. During this pause, our robot code is blocked, and essentially nothing can happen.
Unfortunately, this freeze often happens at inopportune moments, and with the speeds we attempt to move and score at, even a short pause can make a large difference. For example, when we want to be slowing to a stop, a pause like this can delay that instruction until it’s too late, and the robot overshoots its planned trajectory. Given that most of our alignment involves stopping a very tall robot right against a solid wall to score, there were many cases where we crashed into said wall, causing the top of the elevator to start swinging. Our robot has no way of detecting this mechanical flex, and in these cases would often attempt to score and miss while everything was still swaying.
This was a widespread issue for several years, and we tried all the tricks in the book to solve it with little success. Fortunately, a much more modern processor will be used starting in the 2027 season, which should largely solve the issue for future teams.
Official Results
I would kind of rather not include this section as there is always so much out of the control of the team during matches, and the exact outcomes have always mattered less to me than the journey with the successes and failures of our individual robot.
Nevertheless, thanks in no small part to some luck, we were the first pick of the eventual winning alliance at both of our regional events, qualifying us for the world championship in Houston. We also won the Autonomous Award and the Innovation in Control Award at our first and second events respectively. In Houston, we were invited to the third-seeded alliance as the fifth robot selected overall in our division of 75 teams. Due to consecutive failures across the alliance, we fell quickly in the double-elimination bracket, and were ultimately taken out by the eventual division-winning alliance.
Conclusion
Overall, this was one of my favorite seasons. We had, in my opinion, the best-executed robot across all the years I competed, and it played consistently as we intended with relatively few issues. It was exciting to build and succeed with our unique scoring mechanism, and cool to receive recognition for the automation that let us compete at the level we did.
