Hello, this is my teams first year using Swerve and path planner. We are having trouble setting up the Path to be sent to the robot in order to run an auto. We are completely lost on how to set up an auto builder which is what we have seen that needs to be done. Any help is greatly Appreciated thanks.
First you need to configure AutoBuilder.configureHolonomic
of PathPlannerLib (preferably inside the swerve subsystem constructor) and then use AutoBuilder
to pass trajectories with event markers. AutoBuilder
returns a command and then return that command in getAutonomousCommand
in RobotContainer. Hope this helped!
Hey, I have tried making the AutoBuilder but I can’t seem to be able to make the
this::getRobotRelativeSpeeds
this::driveRobotRelative
I was able to use the odometry to get the pose and reset it.
Any idea on how to use those other too?
Thanks in advance
Here is my code for it:
Here is the implementation I used for relative control:
For this you can create a method that returns the relative speeds or use kinematics.toChassisSpeeds()
and pass in the module states.
If you would like to understand swerve in-depth here is a beautiful explanation: Swerve Drive - YAGSL
Thank you for your help I will be implementing it.
Thanks.
Hey I was able to get the rest of the methods working but ran into an error when trying to implement the ChassisSpeeeds.discretize
I have seen in many codes that it is what is being used but for some reason I get this error.
Thanks
Hello. Are you on the latest version of WPILib?
Not yet ,would that be the issue?
Yes, it was implemented in 2024 to solve the turning of the robot while strafing forward.
Ah ok that makes sense thank you again I will be installing the latest version and attempting it again.
Thanks
Hi again, After many tries we have gotten closer but we are getting one error with the getSpeeds(); which in your code is the part that says
() → kinematics .toChassisSpeeds(getModuleStates())
I have kDriveKinematics.toChassisSpeeds
And driver station says that there are more modules than previously allocated.
Would you mind sharing your code so that we can see what to do? Thanks in advance.
I have used AdvantageKit’s swerve template. Focus on Drive.java
file, you don’t need to really focus on the other files since they are for logging.
Thanks I will Check it out.