We use pathplanner for auto and it works fine.
We are trying to do a simple on the fly / tele-op trajectory with our swerve drive. Straight line from where we are now to a specific location.
We output to Dashboard outputs reasonable pose data for where we go,
So what happens is when we run the code we go right and then curve around and go towards where we should go but then keep going, the trajectory doesn’t stop. It is odd because we only have 2 points in our trajectory but it seems to do more.
So the command is mapped like this
new Trigger(m_controller::getLeftTriggerButton)
.whileTrue(m_drivetrainSubsystem.doubleSubstation());
and the code for the command is
public Command doubleSubstation(){
// More complex path with holonomic rotation. Non-zero starting velocity of 2 m/s. Max velocity of 4 m/s and max accel of 3 m/s^2
PathPlannerTrajectory traj = PathPlanner.generatePath(
new PathConstraints(2, 3),
new PathPoint(getPose().getTranslation(),getYawR2d(), getYawR2d(), 0.0),
new PathPoint(new Translation2d(FieldTrajectoryConstants.fieldLengthMeters - 1.2, FieldTrajectoryConstants.fieldWidthMeters - 0.6), Rotation2d.fromDegrees(0), Rotation2d.fromDegrees(0), 0.0)
);
//FieldTrajectoryConstants.fieldLengthMeters - 1.2. FieldTrajectoryConstants.fieldWidthMeters - 0.6
return new PPSwerveControllerCommand(
traj,
this::getPose, // Pose supplier
this.m_kinematics, // SwerveDriveKinematics
new PIDController(TranslationGains.kP, TranslationGains.kI, TranslationGains.kD),
new PIDController(TranslationGains.kP, TranslationGains.kI, TranslationGains.kD),
new PIDController(ThetaGains.kP, ThetaGains.kI, ThetaGains.kD), this::setDesiredStates, // Module states consumer
true, // Should the path be automatically mirrored depending on alliance color. Optional, defaults to true
this // Requires this drive subsystem
);
}
So what do we need to do to get this right?