Skip to content

Commit

Permalink
Added setting init to true in initilalize()
Browse files Browse the repository at this point in the history
  • Loading branch information
Technologyman00 committed Nov 22, 2023
1 parent 68943e6 commit f3e65d7
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ public class AbsoluteDrive extends CommandBase
private final SwerveSubsystem swerve;
private final DoubleSupplier vX, vY;
private final DoubleSupplier headingHorizontal, headingVertical;
private boolean firstLoop = true;
private boolean initRotation = false;

/**
* Used to drive a swerve robot in full field-centric mode. vX and vY supply translation inputs, where x is
@@ -61,6 +61,7 @@ public AbsoluteDrive(SwerveSubsystem swerve, DoubleSupplier vX, DoubleSupplier v
@Override
public void initialize()
{
initRotation = true;
}

// Called every time the scheduler runs while the command is scheduled.
@@ -74,7 +75,7 @@ public void execute()
headingVertical.getAsDouble());

// Prevent Movement After Auto
if(firstLoop)
if(initRotation)
{
if(headingHorizontal.getAsDouble() == 0 && headingVertical.getAsDouble() == 0)
{
@@ -84,8 +85,8 @@ public void execute()
// Set the Current Heading to the desired Heading
desiredSpeeds = swerve.getTargetSpeeds(0, 0, Math.sin(firstLoopHeading), Math.cos(firstLoopHeading));
}
//No Longer First Loop
firstLoop = false;
//Dont Init Rotation Again
initRotation = false;
}

// Limit velocity to prevent tippy

0 comments on commit f3e65d7

Please sign in to comment.