I am writing autonomous code for a swerve robot with pathplanner in Java, and I need help configuring the AutoBuilder, I am a fairly new programmer, and I think I have already found the parts needed for getPose and resetOdometry (lines 75 and 76) but I need help writing method for getting relative speeds for the robot and driving the robot using those speeds (getRobotRelativeSpeeds and driveRobotRelative) (77 and 78). The specific document in question is github linked below, with the full code being at the same link.
Based on the code you already have, its pretty simple. If you need any further explanation let me know, but its essentially using what you already have set up so hopefully it makes sense:
AutoBuilder.configureHolonomic(
this::getPose, // Robot pose supplier
this::resetOdometry, // Method to reset odometry (will be called if your auto has a starting pose)
() -> DriveConstants.DriveKinematics.toChassisSpeeds(
frontLeft.getState(),
frontRight.getState(),
rearLeft.getState(),
rearRight.getState()
),
(speeds) -> drive(speeds.vxMetersPerSecond, speeds.vyMetersPerSecond, speeds.omegaRadiansPerSecond, false, false),
new HolonomicPathFollowerConfig( // HolonomicPathFollowerConfig, this should likely live in your Constants class
new PIDConstants(5.0, 0.0, 0.0), // Translation PID constants
new PIDConstants(5.0, 0.0, 0.0), // Rotation PID constants
4.5, // Max module speed, in m/s
0.4, // Drive base radius in meters. Distance from robot center to furthest module.
new ReplanningConfig() // Default path replanning config. See the API for the options here
),
this // Reference to this subsystem to set requirements
);
And should the two I had originally above work too? I wasn’t completely sure about them or if I had filled in what it was asking for
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.