# Hybrid Velocity Control Reveal

As my team will unfortunately not be attending worlds, I have decided to reveal the velocity control that my team used at states with great success. My team experimented with many variations of PID and TBH throughout the season, but we found there was just too much inconsistencies, no matter how much we tried to tune the constants. The general concept of this program is you run the motors at full speed until they cross over the target velocity. Then, the motors scale back to a predicted power, and use a simple low gain P controller added to the predicted power to hold the velocity to the target RPM. To get the predicted power, we measured the battery power, then adjusted motor power until we were consistently making it in the goal. We then repeated this test at 2 other different battery levels. We recorded this data, and in the program we set battery thresholds that corresponded to a particular predicted motor power. To adjust the power in match, we simply measured the max RPM our flywheel could run at, then divided by 127 to scale RPM to motor power. We then just made a button press make the predicted drive go up or down by 1, and the target RPM go up or down by this corresponding value. An improvement on this would be to actually map out the RPM that a specific motor power could output at a given battery power, however my team did not have this kind of time.

@John_Washburne thank you for sharing your algorithm. Our team used similar technique, but instead of correcting for battery voltage we used low gain P+I controller, where “I” component would correct for battery overcharge/undercharge as well as any unforeseen mechanical issues.

But I would agree with OP that properly correcting for battery level would be better to let “I” converge much quickly to the stable value. Coincidentally, my team spent last couple of weeks doing battery voltage corrections according to this thread.

@John_Washburne could you share some more details about your launcher? What type is it? How many motors drive it? And what is the recovery time for full-court shots?

I’m currently using a hybrid system which ends up acting similar to this. Basically I use TBH with heavy feedforward for overshoot. It basically runs at full power because of the high gain integral accumulator, and then when it crosses, it sets to an approximate power value scaled by tuned battery voltage over current battery voltage. This runs fairly quickly for getting up to speed at high speeds, but is inefficient for low speeds as we figured out at states. The feed forward comes in after the first cross, and only when the measured RPM is too great for the integral accumulator to handle properly (usually about 100-150+ over the deadband we have for auto-firing). The feed forward is basically the same approximate value for the first cross. This seemed to almost double my fire rate from VA states and increased accuracy because the RPM was almost always in range after a shot. I haven’t tested accuracy using a field yet, but all of the balls fed through seemed to all be hitting the same crack in the wall.

It is a single flywheel driven by 4 motors. The full field recovery time is around .7 seconds, we loaded at a more conservative rate at states though, as the fields were usually mostly cleared in the last 30 seconds.

Can you explain feedforward? I can’t really figure out how it works and what it does.

It’s basically where you tell the controller what the system should be doing instead of the controller working that out automatically. Basically, if the system is oscillating wildly around one value which you know is correct, but the controller can’t get to it by itself, you set the system to the correct value, which the controller can then correct if there is any small error.

ok thanks