Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
n00bs
  • Loading branch information
Iooob committed Nov 6, 2023
1 parent 1130ee0 commit f771b93
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
4 changes: 3 additions & 1 deletion src/main/java/frc/robot/commands/AimCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ public void execute() {
Units.degreesToRadians(CamResult.getBestTarget().getPitch()))
- GOAL_RANGE_METERS;
// turn and move towards target.
m_driveSubsystem.driveAndTurn(m_driveSubsystem.getYaw(), angleGoal, distanceFromTarget);
//m_driveSubsystem.driveAndTurn(m_driveSubsystem.getYaw(), angleGoal, distanceFromTarget);
m_driveSubsystem.turnToAngle(m_driveSubsystem.getYaw(), angleGoal);
m_driveSubsystem.driveToDistance(distanceFromTarget);
// we reset the angle everytime as the target could change / move.
m_driveSubsystem.turnSetGoal(angleGoal);
m_driveSubsystem.distanceSetGoal(distanceFromTarget);
Expand Down
28 changes: 15 additions & 13 deletions src/main/java/frc/robot/subsystems/DriveSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,21 @@ public void driveToDistance(double targetDistance) {
}
}

public void turnToAngle(double gyroYawAngle, double TargetAngleDegrees) {
/*
* When this function is activated, execute another command to rotate to target angle. Since a Tank drive
* system cannot move forward simultaneously while rotating, all joystick input
* is ignored until this button is released.
*/
this.calcuateAngleRate(gyroYawAngle, TargetAngleDegrees);
double leftStickValue = turnRotateToAngleRate;
double rightStickValue = -turnRotateToAngleRate;
if (!m_turnController.atGoal()) {
this.tankDrive(leftStickValue, rightStickValue);
}
}


public void driveAndTurn(double gyroYawAngle, double TargetAngleDegrees, double targetDistance) {
/*
This lets you set a gyro angle and a distance you need to travel.
Expand Down Expand Up @@ -251,19 +266,6 @@ private void calcuateAngleRate(double gyroYawAngle, double targetAngleDegrees) {
turnRotateToAngleRate = MathUtil.clamp(m_turnController.calculate(gyroYawAngle), -1.0, 1.0);
}

public void turnToAngle(double gyroYawAngle, double TargetAngleDegrees) {
/*
* When this function is activated, execute another command to rotate to target angle. Since a Tank drive
* system cannot move forward simultaneously while rotating, all joystick input
* is ignored until this button is released.
*/
this.calcuateAngleRate(gyroYawAngle, TargetAngleDegrees);
double leftStickValue = turnRotateToAngleRate;
double rightStickValue = -turnRotateToAngleRate;
if (!m_turnController.atGoal()) {
this.tankDrive(leftStickValue, rightStickValue);
}
}

// magnitude = (joystickL + joystickR) / 2;
public void driveStraight(
Expand Down

0 comments on commit f771b93

Please sign in to comment.