So now that my team has gone through the long and wonderful process of getting absolutely everything for swerve, I actually have to start programming it, I’m not really the best programmer in the world but I’m learning so I have a couple of questions about programming swerve.
How the heck do I figure out the max speed of the robot if it’s not programmed and moving, what kind of math do I have to do to figure this out? I’m assuming you basically just guess the max speed until you can actually figure it out.
Whats the best way to learn how to program it generally (ive been watching the frc 0 to autonomous swerve drive, and doing my own research on YAGSL and stuff)
Is anyone willing to get on something like discord or google meets to explain the programming side to me? Or actually any side at all building, electrical, etc because I think me and 2 other students are going to do majority of it.
I have looked at a bunch of different teams code and while it did teach me stuff in a way, its also done a lot of confusing me because of the different ways everyone does everything. So any explanation of anything would help me.
So the CTRE swerve generator is awesome. I used it for the first time recently and it was by far the most painless way to set up swerve. I understand wanting to try to do it on your own though so I will answer as best I can.
Max speed: Use the chart for the gearing provided by Thrifty bot. It is all based on motor speed and gearing.
So it depends on how you choose to gear it. The chart has the speed in ft/s. Most of the wpilib swerve code wants this value in meters per second so it will need to be converted. Another way is to put a value in that is a little higher than it can possibly go then output the encoder velocity to shuffleboard or something similar and see the max speed it will go.
If there is another team nearby that does swerve it might be best to get some help there where they can walk through it hands on, but if that is not an option you are still struggling to figure it out. Have an adult mentor DM me and see if we can set up something. I am not a programming expert by any means and do not totally understand all the black magic, but a have worked my way though programming a swerve and getting them to work a few times to help my team set it up.
so with that gearing I would expect a max free speed to be about 4.72 m/s. You would likely be fine using that value then you can output the value to shuffle board and see what you actually get. You will likely not quite reach that due to drag and friction, but it is a good start. It is best to put a reasonable number around there.
There’s an unofficial FRC discord with 20k+ very knowledgeable people who are happy to answer any questions that you have. It’s a very handy tool that I highly recommend.
You don’t have to figure it out accurately. You can start by approximating it using max_ground_speed (m/s) = motor_free_speed (rad/sec) / gear_ratio * wheel_radius(m)
Most would recommend YAGSL for its ease of use. But it doesn’t matter what codebase you choose. The important thing is, once you’re settled on one, start playing around with it. Create some drive commands that you think would be useful for the upcoming season (e.g., face-to-target-while-driving, auto-alignment…). Try running some autos on the field to see if it’s following the trajectories correctly.
If you use YAGSL, don’t forget to join their discord YAGSL