-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #160 from FRC2706/rcvi_vision3
Rcvi vision3
- Loading branch information
Showing
6 changed files
with
163 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/ca/team2706/frc/robot/commands/drivebase/AbsoluteGyroReset.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package ca.team2706.frc.robot.commands.drivebase; | ||
|
||
import ca.team2706.frc.robot.logging.Log; | ||
import ca.team2706.frc.robot.subsystems.DriveBase; | ||
import edu.wpi.first.wpilibj.command.InstantCommand; | ||
|
||
/** | ||
* Resets the absolute gyro heading of the robot to a target | ||
*/ | ||
public class AbsoluteGyroReset extends InstantCommand { | ||
|
||
/** | ||
* Type of target that robot is aligned with (CARGO_AND_LOADING or ROCKET) | ||
*/ | ||
private DriverAssistVisionTarget target; | ||
|
||
/** | ||
* Creates absolute gyro reset object | ||
* | ||
* @param target The type of target that the robot is aligned with | ||
*/ | ||
public AbsoluteGyroReset(DriverAssistVisionTarget target) { | ||
this.target = target; | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
Log.d("AGR: initialize() called"); | ||
double angRobotHeadingCurrent_Field = DriveBase.getInstance().getAbsoluteHeading() % 360; | ||
if (angRobotHeadingCurrent_Field < 0.0) { | ||
angRobotHeadingCurrent_Field += 360.0; | ||
} | ||
Log.d("AGR: angRobotHeadingCurrent_Field: " + angRobotHeadingCurrent_Field); | ||
double updatedAngle = DriverAssistVision.computeAngRobotHeadingFinal_Field(angRobotHeadingCurrent_Field, target); | ||
DriveBase.getInstance().resetAbsoluteGyro(updatedAngle); | ||
Log.d("AGR: Absolute gyro angle updated to: " + updatedAngle); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.