Skip to content

Commit

Permalink
debug for auto aim test
Browse files Browse the repository at this point in the history
  • Loading branch information
PGgit08 committed Jan 26, 2024
1 parent f30a09f commit a0e7b26
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
19 changes: 14 additions & 5 deletions src/main/java/frc/robot/commands/shooter/AutoAim.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,33 @@ public void execute() {

double currentSwerveHeading = _swerve.getHeading().getDegrees();

if (_vision.isApriltagVisible()) {
desiredShooterAngle = _vision.anglesToSpeaker()[1]; // ty
desiredSwerveHeading = _vision.anglesToSpeaker()[0];
SmartDashboard.putBoolean("VISIBLE TAG", _vision.isApriltagVisible());

double[] visionAngles = _vision.anglesToSpeaker();

if (_vision.isApriltagVisible() && visionAngles != null) {
desiredShooterAngle = visionAngles[1];
desiredSwerveHeading = visionAngles[0];

SmartDashboard.putNumberArray("VISION ANGLES", visionAngles);

} else {
desiredShooterAngle = _swerve.anglesToSpeaker()[1];
desiredSwerveHeading = _swerve.anglesToSpeaker()[0];
}

desiredSwerveHeading += currentSwerveHeading;
desiredSwerveHeading -= currentSwerveHeading;

_shooter.setAngle(desiredShooterAngle);

SmartDashboard.putNumber("DESIRED HEADING", desiredSwerveHeading);

_swerve.driveChassis(
new ChassisSpeeds(
_xSpeed.getAsDouble() * Constants.Speeds.SWERVE_DRIVE_MAX_SPEED * Constants.Speeds.SWERVE_DRIVE_COEFF,
_ySpeed.getAsDouble() * Constants.Speeds.SWERVE_DRIVE_MAX_SPEED * Constants.Speeds.SWERVE_DRIVE_COEFF,
_headingController.calculate(currentSwerveHeading, desiredSwerveHeading)
// _headingController.calculate(currentSwerveHeading, desiredSwerveHeading),
0
)
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/frc/robot/subsystems/SwerveDriveSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ public ChassisSpeeds getRobotRelativeSpeeds() {
public SwerveDriveSubsystem(VisionSubsystem visionSubsystem) {
_visionSubsystem = visionSubsystem;

resetPose(_visionSubsystem.getBotpose().get());

// setupOrchestra();

// pathplannerlib setup
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/subsystems/VisionSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public boolean isApriltagVisible() {
public boolean isApriltagVisible(int ID) {
if (!isApriltagVisible()) return false;

return _limelight.getTag(ID) != null;
return (_limelight.getTag(ID) != null);
}

/**
Expand Down

0 comments on commit a0e7b26

Please sign in to comment.