Hopefully working auto align
This commit is contained in:
parent
0ced1e4d59
commit
2f981f2d09
|
|
@ -59,7 +59,7 @@ public class AutoShootCommandChassisTurret extends Command{
|
||||||
cameraAutoCenterController.setSetpoint(0);
|
cameraAutoCenterController.setSetpoint(0);
|
||||||
|
|
||||||
|
|
||||||
deadreckoningAutoCenterController = new PIDController(Math.PI * 0.1, 0, 0.0);
|
deadreckoningAutoCenterController = new PIDController(Math.PI, 0, 0.0);
|
||||||
deadreckoningAutoCenterController.setTolerance(0.2); // Units is rotations
|
deadreckoningAutoCenterController.setTolerance(0.2); // Units is rotations
|
||||||
deadreckoningAutoCenterController.enableContinuousInput(-Math.PI, Math.PI);
|
deadreckoningAutoCenterController.enableContinuousInput(-Math.PI, Math.PI);
|
||||||
}
|
}
|
||||||
|
|
@ -92,12 +92,7 @@ public class AutoShootCommandChassisTurret extends Command{
|
||||||
Translation2d delta = botPose.getTranslation().toTranslation2d().minus(closestTag.getTranslation().toTranslation2d());
|
Translation2d delta = botPose.getTranslation().toTranslation2d().minus(closestTag.getTranslation().toTranslation2d());
|
||||||
Logger.recordOutput("AutoAlign-ClosestAprilTagTransform", delta);
|
Logger.recordOutput("AutoAlign-ClosestAprilTagTransform", delta);
|
||||||
|
|
||||||
DriverStation.getAlliance().ifPresent((aliance) -> {
|
deadreckoningAutoCenterController.setSetpoint(delta.getAngle().plus(Rotation2d.kZero).getRadians());
|
||||||
if (aliance == Alliance.Blue) {
|
|
||||||
// Add 180 because we want the back of the robot to face the HUB
|
|
||||||
deadreckoningAutoCenterController.setSetpoint(delta.getAngle().plus(Rotation2d.k180deg).getRadians());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -111,7 +106,7 @@ public class AutoShootCommandChassisTurret extends Command{
|
||||||
Logger.recordOutput("AutoAlignState-Tracking", "Deadreckoning");
|
Logger.recordOutput("AutoAlignState-Tracking", "Deadreckoning");
|
||||||
|
|
||||||
Pose3d botPose = driveSubsystem.getBotPose();
|
Pose3d botPose = driveSubsystem.getBotPose();
|
||||||
driveSubsystem.rotateChassis(deadreckoningAutoCenterController.calculate(botPose.getRotation().toRotation2d().getRadians()));
|
driveSubsystem.rotateChassis(-deadreckoningAutoCenterController.calculate(botPose.getRotation().toRotation2d().getRadians()));
|
||||||
}
|
}
|
||||||
else // We have an april tag, center it to the camera frame
|
else // We have an april tag, center it to the camera frame
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue