Skip to content

Commit

Permalink
added isNearSource method
Browse files Browse the repository at this point in the history
  • Loading branch information
woopers6 committed Feb 1, 2025
1 parent 4f2c7e5 commit 90dab23
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/main/java/frc/robot/subsystems/drivetrain/DriveSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void execute() {
m_currentDriveYState = new TrapezoidProfile.State(s_drivetrain.getState().Pose.getY(), s_drivetrain.getState().Speeds.vyMetersPerSecond);
m_currentTurnState = new TrapezoidProfile.State(s_drivetrain.getState().Pose.getRotation().getRadians(), s_drivetrain.getState().Speeds.omegaRadiansPerSecond);
} */

// Get error which is the smallest distance between goal and measurement
double errorBound = Math.PI;
double measurement = s_drivetrain.getState().Pose.getRotation().getRadians();
Expand All @@ -117,7 +117,7 @@ public void execute() {
m_currentDriveXState = s_driveProfile.calculate(dt, m_currentDriveXState, s_autoAlignTargetDriveX);
m_currentDriveYState = s_driveProfile.calculate(dt, m_currentDriveYState, s_autoAlignTargetDriveY);
m_currentTurnState = s_turnProfile.calculate(dt, m_currentTurnState, s_autoAlignTargetTurn);

s_drivetrain.setControl(
s_autoDrive
.withTargetDirection(new Rotation2d(m_currentTurnState.position))
Expand Down Expand Up @@ -156,7 +156,7 @@ public void end(boolean interrupted) {
private static CommandSwerveDrivetrain s_drivetrain;
private static SwerveRequest.FieldCentric s_drive;
private static FieldCentricWithPose s_autoDrive;

private static DoubleSupplier s_driveRequest = () -> 0;
private static DoubleSupplier s_strafeRequest = () -> 0;
private static DoubleSupplier s_rotateRequest = () -> 0;
Expand Down Expand Up @@ -227,6 +227,14 @@ public Pose2d getPose() {
return s_drivetrain.getState().Pose;
}

/**
* Checks if the robot is near the sourc
* @return The boolean value to check if the robot is near the source
*/
public boolean isNearSource() {
return ((getPose().getX() < 2.0) && ((getPose().getY() < 1.5) || getPose().getY() > 6.0));
}

/**
* Returns the location the robot should go to in order to align to the nearest reef pole
*/
Expand Down

0 comments on commit 90dab23

Please sign in to comment.