It has been a long time since I attempted to do this but the issue was that SwerveKinematics[ ] provided by the MAXSwerve template did not work in the AutoBuilder constructor. Is there a way to make this compatible?
Do you happen to be using the 2024 beta pathplanner?
In 2023 here is my autobuilder, you can replace m_swerve with this if in drivesubsystem.
autoBuilder =
new SwerveAutoBuilder(
m_swerve::getPose,
m_swerve::resetOdometry,
DriveConstants.kDriveKinematics,
new PIDConstants(AutoConstants.kPXController, 0.0, 0.0),
new PIDConstants(AutoConstants.kPThetaController, 0, 0),
m_swerve::setModuleStates,
eventMap,
true,
m_swerve);
For 2024 beta this was the autoBuilder (again with m_swerve being this if in the drivesubsystem)
AutoBuilder.configureHolonomic(
m_swerve::getPose,
m_swerve::resetPose,
m_swerve::getRobotRelativeSpeeds,
m_swerve::driveRobotRelative,
new HolonomicPathFollowerConfig(
new PIDConstants(AutoConstants.kPXController,0,0),
new PIDConstants(AutoConstants.kPThetaController,0,0),
4.8, // max speed in m/s
Units.inchesToMeters(Math.sqrt(Math.pow(28.5, 2)+Math.pow(18.5,2))/2), // Radius in meters of 28.5 x 18.5 inch robot using a^2 +b^2 = c^2
new ReplanningConfig()
),
m_swerve
);
And here is the robot relative methods
public void driveRobotRelative(ChassisSpeeds speeds){
this.drive(speeds.vxMetersPerSecond,speeds.vyMetersPerSecond,speeds.omegaRadiansPerSecond,false,false);
}
public ChassisSpeeds getRobotRelativeSpeeds(){
return DriveConstants.kDriveKinematics.toChassisSpeeds(m_frontLeft.getState(),
m_frontRight.getState(),
m_rearLeft.getState(),
m_rearRight.getState());
}
We are still on 2023. Is the part that initializes autoBuilder supposed to go inside the DriveSubsystem constructor or somewhere else? The documentations is unclear on this.
It can live in the drive subsystem constructor (or maybe in robotcontainer). Somewhere to write the commands you want. We just made a separate Autos class. Though I think I will put it back with the drive subsystem next year, given the changes being made for it. https://github.com/frc1108/Robot2023/blob/main/src/main/java/frc/robot/Autos.java
I know Round Table Robotics has it working GitHub - OCHS-STEM-Club/2023-Hangnail but they are still tuning it
I wanted to ask… I see that the ADIS… gyro was replaced by the NAV-X2 gyro - we are doing this too. Is there an issue with ADIS reporting positive angles CCW and NAV-X2 reporting angles positive CW? Should or did you negate the NAV-X2 angles?
It should be correct for NAVX if kGyroReversed is false.
Aren’t they using Path Weaver?
I’m not sure what the path Weaver folder is about but I think it’s not needed. But they also have Pathplanner in the deploy folder
The code that uses the ADIS controller shows kGyroReversed = false. so, should the constant be set to true or am I missing something here?
I am on 2024 now. Not sure what should supply ChassisSpeeds.
I had to pass the swerve module states getState()
to the toChassisSpeeds()
methods of the drive kinematics (which was in DriveConstants to return the ChassisSpeeds for the MaxSwerve.
The modules have to be in the same order that you created the drive kinematics.
FireBears posted an example on their github that they have working!