Our team was trying to implement Path planner to run autonomous route on our swerve robot. We were trying to implement the following code based on the path planner github:
return new SequentialCommandGroup(
new InstantCommand(() → {
// Reset odometry for the first path you run during auto
if(isFirstPath){
this.resetOdometry(traj.getInitialHolonomicPose());
}
}),
new PPSwerveControllerCommand(
traj,
this::getPose, // Pose supplier
this.kinematics, // SwerveDriveKinematics
new PIDController(0, 0, 0), // X controller. Tune these values for your robot. Leaving them 0 will only use feedforwards.
new PIDController(0, 0, 0), // Y controller (usually the same values as X controller)
new PIDController(0, 0, 0), // Rotation controller. Tune these values for your robot. Leaving them 0 will only use feedforwards.
this::setModuleStates, // Module states consumer
eventMap, // This argument is optional if you don’t use event markers
this // Requires this drive subsystem
)
);
In specific we were trying to figure out out how to implement the setModuleStates method. We have tried looking at other teams code but we struggled to understand the code and only ended up more confused. If anybody knows how to implement the setModuleStates method in Java for pathplanner that would be greatly appreciated.
Our full code is here: https://github.com/FRC5549Robotics/BunnyBots_2022
Thank you!