In terms of programming a swerve I wanted to go about it. In terms of creating the subsystem and commands seems fine but I was wondering how to make the swerve exceptionally good. This means propper tuning. How would I go about tuning the pid on my swerve modules well? As well as position tracking with limelight and having presets for all 4 directions of travel? Thanks to anyone who can help.
Use BaseFalconSwerve by team 364 as a starting point. What do you mean by presets for all directions?
yeah i’m not entirely sure what you mean by that, could you elaborate?
Such as having buttons to align for perfect strafing and locking wheels in the directions for that. Might be a bit confusing the way I stated it.
Also if I were to replace a swerve module mid match would I need to retune the module or would the constants remain the same?
honestly i believe there would be no need for that, if you have a driver with enough practice and skill, you shouldn’t need to set up something like that, but i would recommend a button for locking your wheels in an x because it is quite helpful when you don’t want to move
the only constants you might need to change is encoder offsets
To tune the swerve do I just need to run the module in phoenix tuner and tune the value to the graph or some other method?
If you are using a module supported by BaseFalconSwerve, you should not need to do any PID tuning on the module. However, if you would like to tune the motor, I found that directly editing the constants in the class provided by BaseFalconSwerve was easy enough. All we changed was the P value of the controller from 0.5 to 0.3 because our modules were over oscillating by a little bit
Ok so I will figure out if it needs further tuning when I drive the actual module and the constants that are currently in the file work?
Yep! Go to the GitHub page for BaseFalconSwerve and follow the steps listed to get it up and running. Change all the things it asks you to
All right this might be a little bit down the road for our team, is there anyplace where i can learn about incorporating vision to maximize the efficiency of our swerve drive?
My advice, for any technical challenge like this, would be to first describe what you want the robot to do in words. In this case it would look something like this:
- I would like the robot to automatically align to the AprilTag targets.
From there, I would break this down into the individual steps in the process, because the current description might leave you scratching your head on where to start.
- First, I want the robot to see the AprilTags and get that data.
- Then, I want the robot to generate a trajectory to the closest tag in view when I press a button.
Above, you can start to imagine what kind of steps you will have to take to get the end result. Repeat this process until you get to steps that you either feel comfortable implementing OR you are able to find the resources you need to learn how to implement them. Example expansion below:
- Access AprilTag data from Limelight on robot and visualize it to SmartDashboard and use it in code.
- Generate a Trajectory (How do I do that?!)
- Follow that trajectory (How do I do THAT!?)
- Report when done and do something else like move arm to scoring position
… expand to final points …
- Create an interface that takes in Limelight pose data (Finally, something I am comfortable with!)
- Install PathPlanner and read docs on the GitHub to learn to make paths in code
- Store AprilTag poses in code
- Create a method that makes a trajectory from the current robot position to end position
- Send that trajectory to a path following command (i.e. PPSwerveController)
- Report when done
- Put in sequential command group to move arm when path is finished
That list above still will seem scary for someone new to vision tracking and trajectory generation. However, there will always be things that us programmers won’t know how to do! Google is your best friend. Also, the majority of the things in my “more detailed” list can be answered on the setup guides for both PathPlanner and on the Limelight setup guide.
Whats the best way to create a resetPose function on my robot for pathplanner in my swerve subsystem. I see teams doing it differently.
You could also look at YAGSL (either to use or as a reference) for swerve drive programming. I would definitely recommend learning how it works however.
When I simulate my pathplanner code am I supposed to see the velocites change on my motors?
Unfortunately not, the physics engine doesn’t take that into account in glass, however if you use frc-web-components or AdvantageScope you can see the simulated velocities.
I do get displacement on the other hand is that normal?
When I had a 6 wheel drivetrain I could see the velocities change.
Depends on the motor you choose, i had implemented CTRE’s PhysicsEngine from their example code and used REVs from their library. I know velocities appear for drive motors on CTRE and might not for REV, either way these values shouldn’t affect the simulation at all. If you give the wrong location for modules however it definitely could.
In short - Probably normal, and if you’re referring to the robot moving in simulation then it is desired infact, it also reports the angle of the motors relative the the robot pose.