Swerve Understanding Help

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.

  1. 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.

  2. 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)

  3. 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.

1 Like

What brand swerve modules, motors, encoders are you using?

Modules - Thrifty Swerve
Motors - Kraken Drive and Kraken Rotation
Encoders - CANcoders
IMU - Pigeon 2.0

I know we can use the ctre project generator but id rather learn how to understand it first before using that

1 Like

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.

  1. Max speed: Use the chart for the gearing provided by Thrifty bot. It is all based on motor speed and gearing.

image

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.

  1. We have used the wpilib sweve command controller example, the REV max serve template and the CTRE swerve project generator. The CTRE was by far the quickest and easiest to set up and will likely have the best performance.

  2. 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.

2 Likes

My understanding is that YAGSL is very similar to Ctre. If you wanna understand it best you should work with the (super basic) wpilib library.

If you would like some help feel free to reach out. I know a little, but I’d love to get you in contact with our programming lead.

1 Like

I know we are using the 12 pinion size and the 18t gear

ok so basically just put the number higher and whatever it goes to is the actual max speed since it cant actually get past that

I’ll see if I can get something set up

This sounds awesome if youd be willing

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.

1 Like

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.

  1. 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)
  2. 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.
  3. If you use YAGSL, don’t forget to join their discord
    YAGSL
2 Likes

Since they are using all CTRE components they really should use the Tuner X Swerve Gen for their setup. It’s faster and will always be better.

2 Likes