-
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 #111 from strykeforce/4or5ThenWing3ThenSearch
4or5 then wing3 then search
- Loading branch information
Showing
32 changed files
with
838 additions
and
118 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
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,24 @@ | ||
max_velocity = 5.0 #m/s | ||
max_acceleration = 3.0 #m/s | ||
start_velocity = 0.0 #m/s | ||
end_velocity = 0.0 #m/s | ||
is_reversed = false | ||
target_yaw = -34.439 #degrees | ||
|
||
[start_pose] | ||
dataPoint = "M4" | ||
dX = -0.3 | ||
dY = 0.55 | ||
angle = 180.0 | ||
|
||
[end_pose] | ||
dataPoint = "NAS4" | ||
angle = 143.27 | ||
|
||
[[internal_points]] | ||
x = 5.56 | ||
y = 1.8 | ||
|
||
[[internal_points]] | ||
x = 2.483 | ||
y = 3.154 |
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,22 @@ | ||
max_velocity = 5.0 #m/s | ||
max_acceleration = 3.0 #m/s | ||
start_velocity = 0.0 #m/s | ||
end_velocity = 0.0 #m/s | ||
is_reversed = false | ||
target_yaw = -34.439 #degrees | ||
|
||
[start_pose] | ||
dataPoint = "M5" | ||
dX = -0.5 | ||
dY = 0.35 | ||
|
||
[end_pose] | ||
dataPoint = "NAS4" | ||
|
||
[[internal_points]] | ||
x = 5.021 | ||
y = 1.395 | ||
|
||
[[internal_points]] | ||
x = 2.483 | ||
y = 3.154 |
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
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
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,22 @@ | ||
max_velocity = 5.0 #m/s | ||
max_acceleration = 3.0 #m/s | ||
start_velocity = 0.0 #m/s | ||
end_velocity = 0.0 #m/s | ||
is_reversed = false | ||
target_yaw = 0.0 #degrees | ||
|
||
[start_pose] | ||
dataPoint = "NAS4" | ||
angle = -36.72 | ||
|
||
[end_pose] | ||
dataPoint = "M4" | ||
angle = 0.0 | ||
|
||
[[internal_points]] | ||
x = 2.71 | ||
y = 2.8 | ||
|
||
[[internal_points]] | ||
x = 5.56 | ||
y = 2.0 |
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,16 @@ | ||
max_velocity = 5.0 #m/s | ||
max_acceleration = 3.0 #m/s | ||
start_velocity = 0.0 #m/s | ||
end_velocity = 0.0 #m/s | ||
is_reversed = false | ||
target_yaw = 0.0 #degrees | ||
|
||
[start_pose] | ||
dataPoint = "NAS4" | ||
|
||
[end_pose] | ||
dataPoint = "M5" | ||
|
||
[[internal_points]] | ||
x = 5.021 | ||
y = 1.395 |
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,19 @@ | ||
max_velocity = 3.0 #m/s | ||
max_acceleration = 2.5 #m/s | ||
start_velocity = 0.0 #m/s | ||
end_velocity = 0.0 #m/s | ||
is_reversed = false | ||
target_yaw = 0.0 #degrees | ||
|
||
[start_pose] | ||
dataPoint = "NAS4" | ||
angle = 0.0 | ||
[end_pose] | ||
dataPoint = "W3" | ||
dX = -0.1 | ||
dY = 0.0 | ||
angle = 0.0 | ||
|
||
[[internal_points]] | ||
x = 2.2 | ||
y = 4.11 |
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
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
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
122 changes: 122 additions & 0 deletions
122
src/main/java/frc/robot/commands/auton/DeadeyeHuntRotateCommand.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,122 @@ | ||
package frc.robot.commands.auton; | ||
|
||
import edu.wpi.first.math.controller.PIDController; | ||
import edu.wpi.first.math.controller.ProfiledPIDController; | ||
import edu.wpi.first.math.trajectory.TrapezoidProfile.Constraints; | ||
import edu.wpi.first.wpilibj.DriverStation.Alliance; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.constants.AutonConstants; | ||
import frc.robot.subsystems.auto.AutoCommandInterface; | ||
import frc.robot.subsystems.drive.DriveSubsystem; | ||
import frc.robot.subsystems.led.LedSubsystem; | ||
import frc.robot.subsystems.robotState.RobotStateSubsystem; | ||
import frc.robot.subsystems.vision.DeadEyeSubsystem; | ||
import net.jafama.FastMath; | ||
|
||
public class DeadeyeHuntRotateCommand extends Command implements AutoCommandInterface { | ||
private DeadEyeSubsystem deadeye; | ||
private DriveSubsystem driveSubsystem; | ||
private RobotStateSubsystem robotStateSubsystem; | ||
private ProfiledPIDController deadeyeYDrive; | ||
private PIDController deadeyeXDrive; | ||
private LedSubsystem ledSubsystem; | ||
private double turnTo; | ||
private double turnToInverted; | ||
private double deltaTurn; | ||
private boolean reachedEnd = false; | ||
private boolean generated = false; | ||
|
||
public DeadeyeHuntRotateCommand( | ||
DeadEyeSubsystem deadeye, | ||
DriveSubsystem driveSubsystem, | ||
RobotStateSubsystem robotStateSubsystem, | ||
LedSubsystem ledSubsystem, | ||
double turnTo) { | ||
addRequirements(driveSubsystem); | ||
this.deadeye = deadeye; | ||
this.driveSubsystem = driveSubsystem; | ||
this.robotStateSubsystem = robotStateSubsystem; | ||
this.ledSubsystem = ledSubsystem; | ||
this.turnTo = turnTo; | ||
deadeyeYDrive = | ||
new ProfiledPIDController( | ||
AutonConstants.kPDeadEyeYDrive, | ||
AutonConstants.kIDeadEyeYDrive, | ||
AutonConstants.kDDeadEyeYDrive, | ||
new Constraints( | ||
AutonConstants.kMaxVelDeadeyeDrive, AutonConstants.kMaxAccelDeadeyeDrive)); | ||
deadeyeXDrive = | ||
new PIDController( | ||
AutonConstants.kPDeadEyeXDrive, | ||
AutonConstants.kIDeadEyeXDrive, | ||
AutonConstants.kDDeadEyeXDrive); | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
driveSubsystem.setAutoDebugMsg("DeadEYE Hunt Initialized"); | ||
deltaTurn = | ||
turnToInverted - getCorrectRange() >= 0 | ||
? AutonConstants.kHuntTurnSpeed | ||
: -AutonConstants.kHuntTurnSpeed; | ||
ledSubsystem.setColor(120, 38, 109); | ||
|
||
driveSubsystem.setIsAligningShot(false); | ||
if (deadeye.getNumTargets() > 0) { | ||
double ySpeed = deadeyeYDrive.calculate(deadeye.getDistanceToCamCenter(), 0.0); | ||
double xSpeed = deadeyeXDrive.calculate(deadeye.getDistanceToCamCenter(), 0.0); | ||
driveSubsystem.move(AutonConstants.kXSpeed / (xSpeed * xSpeed + 1), ySpeed, 0.0, false); | ||
} else if (deltaTurn > 0 && turnToInverted < getCorrectRange() | ||
|| deltaTurn < 0 && turnToInverted > getCorrectRange()) { | ||
reachedEnd = true; | ||
} else { | ||
driveSubsystem.move(0.0, 0.0, deltaTurn, false); | ||
} | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
if (deadeye.getNumTargets() > 0) { | ||
double ySpeed = deadeyeYDrive.calculate(deadeye.getDistanceToCamCenter(), 0.0); | ||
double xSpeed = deadeyeXDrive.calculate(deadeye.getDistanceToCamCenter(), 0.0); | ||
driveSubsystem.recordYVel(ySpeed); | ||
driveSubsystem.move(AutonConstants.kXSpeed / (xSpeed * xSpeed + 1), ySpeed, 0.0, false); | ||
} else if (deltaTurn > 0 && turnToInverted < getCorrectRange() | ||
|| deltaTurn < 0 && turnToInverted > getCorrectRange()) { | ||
reachedEnd = true; | ||
} else { | ||
driveSubsystem.move(0.0, 0.0, deltaTurn, false); | ||
} | ||
} | ||
|
||
@Override | ||
public void end(boolean interrupted) { | ||
driveSubsystem.setAutoDebugMsg("Finished Deadeye Hunt"); | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
return robotStateSubsystem.hasNote(); | ||
} | ||
|
||
@Override | ||
public void generateTrajectory() { | ||
turnToInverted = | ||
robotStateSubsystem.getAllianceColor() == Alliance.Blue | ||
? FastMath.normalizeZeroTwoPi(turnTo) | ||
: Math.PI - FastMath.normalizeZeroTwoPi(turnTo); | ||
|
||
generated = true; | ||
} | ||
|
||
@Override | ||
public boolean hasGenerated() { | ||
return generated; | ||
} | ||
|
||
public double getCorrectRange() { | ||
return robotStateSubsystem.getAllianceColor() == Alliance.Blue | ||
? FastMath.normalizeZeroTwoPi(driveSubsystem.getGyroRotation2d().getRadians()) | ||
: driveSubsystem.getGyroRotation2d().getRadians(); | ||
} | ||
} |
Oops, something went wrong.