Skip to content

Commit 18915d1

Browse files
committed
Hunt
1 parent 966d22b commit 18915d1

12 files changed

+58
-25
lines changed

src/main/deploy/paths/MiddleInitial1_MiddleNote3.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
max_velocity = 5.0 #m/s
2-
max_acceleration = 4.7 #m/s
2+
max_acceleration = 4.5 #m/s
33
start_velocity = 0.0 #m/s
44
end_velocity = 0.0 #m/s
55
is_reversed = false
@@ -10,13 +10,13 @@ target_yaw = 0.0 #degrees
1010

1111
[end_pose]
1212
dataPoint = "M3"
13-
dX = -0.1
13+
dX = -0.2
1414
dY = 0.0
1515

1616
# W2
1717
[[internal_points]]
18-
x = 2.94
19-
y = 5.55
18+
x = 3.02
19+
y = 5.60 # 5.55
2020

2121
[[internal_points]]
2222
x = 5.221

src/main/deploy/paths/MiddleInitial1_WingNote1.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ target_yaw = 26.6 #degrees - old 22.0
1919

2020
[[internal_points]]
2121
x = 1.9
22-
y = 6.46
22+
y = 6.3

src/main/deploy/paths/MiddleNote3_MiddleShoot3.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ target_yaw = 0.0 #degrees
77

88
[start_pose]
99
dataPoint = "M3"
10-
dX = 0.1
10+
dX = 0.0
1111
dY = 0.0
1212
angle = 180.0
1313

1414
[end_pose]
1515
dataPoint = "MS3"
16-
dX = 0.9
16+
dX = 0.45
1717
dY = 0.0
18-
angle = 180.0 # 200.0
18+
angle = 180.0
1919

2020
[[internal_points]]
2121
x = 5.364 # 5.221

src/main/deploy/paths/MiddleShoot3_WingNote3.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ target_yaw = -30.0 #degrees
1111
[end_pose]
1212
dataPoint = "W3"
1313
dX = -0.1
14-
dY = 0.05
14+
dY = 0.0
1515
angle = -30.0
1616

1717
[[internal_points]]

src/main/java/frc/robot/commands/auton/DeadeyeHuntCommand.java

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public class DeadeyeHuntCommand extends Command {
1717
private ProfiledPIDController deadeyeYDrive;
1818
private PIDController deadeyeXDrive;
1919
private LedSubsystem ledSubsystem;
20+
private HuntState huntState;
21+
private int seenNote = 0;
2022

2123
public DeadeyeHuntCommand(
2224
DeadEyeSubsystem deadeye,
@@ -34,12 +36,13 @@ public DeadeyeHuntCommand(
3436
AutonConstants.kIDeadEyeYDrive,
3537
AutonConstants.kDDeadEyeYDrive,
3638
new Constraints(
37-
AutonConstants.kMaxVelDeadeyeDrive, AutonConstants.kMaxAccelDeadeyeDrive));
39+
AutonConstants.kMaxAutonVelDeadeyeDrive, AutonConstants.kMaxAccelDeadeyeDrive));
3840
deadeyeXDrive =
3941
new PIDController(
4042
AutonConstants.kPDeadEyeXDrive,
4143
AutonConstants.kIDeadEyeXDrive,
4244
AutonConstants.kDDeadEyeXDrive);
45+
huntState = HuntState.SEARCHING;
4346
}
4447

4548
@Override
@@ -51,30 +54,49 @@ public void initialize() {
5154
double ySpeed = deadeyeYDrive.calculate(deadeye.getDistanceToCamCenter(), 0.0);
5255
double xSpeed = deadeyeXDrive.calculate(deadeye.getDistanceToCamCenter(), 0.0);
5356
driveSubsystem.move(AutonConstants.kXSpeed / (xSpeed * xSpeed + 1), ySpeed, 0.0, false);
57+
seenNote++;
5458
} else {
55-
driveSubsystem.move(0.0, 0.0, -4.0, false);
59+
driveSubsystem.move(0.0, 0.0, AutonConstants.kDeadeyeHuntOmegaRadps, false);
5660
}
5761
}
5862

5963
@Override
6064
public void execute() {
61-
if (deadeye.getNumTargets() > 0) {
62-
double ySpeed = deadeyeYDrive.calculate(deadeye.getDistanceToCamCenter(), 0.0);
63-
double xSpeed = deadeyeXDrive.calculate(deadeye.getDistanceToCamCenter(), 0.0);
64-
driveSubsystem.recordYVel(ySpeed);
65-
driveSubsystem.move(AutonConstants.kXSpeed / (xSpeed * xSpeed + 1), ySpeed, 0.0, false);
66-
} else {
67-
driveSubsystem.move(0.0, 0.0, -4.0, false);
65+
switch (huntState) {
66+
case SEARCHING:
67+
if (deadeye.getNumTargets() > 0) {
68+
seenNote++;
69+
if (seenNote >= AutonConstants.kFoundNoteLoopCounts) {
70+
huntState = HuntState.DRIVING;
71+
}
72+
} else {
73+
driveSubsystem.move(0.0, 0.0, AutonConstants.kDeadeyeHuntOmegaRadps, false);
74+
seenNote = 0;
75+
}
76+
break;
77+
case DRIVING:
78+
if (deadeye.getNumTargets() > 0) {
79+
double ySpeed = deadeyeYDrive.calculate(deadeye.getDistanceToCamCenter(), 0.0);
80+
double xSpeed = deadeyeXDrive.calculate(deadeye.getDistanceToCamCenter(), 0.0);
81+
driveSubsystem.recordYVel(ySpeed);
82+
driveSubsystem.move(AutonConstants.kXSpeed / (xSpeed * xSpeed + 1), ySpeed, 0.0, false);
83+
}
84+
break;
6885
}
6986
}
7087

7188
@Override
7289
public void end(boolean interrupted) {
73-
driveSubsystem.move(0, 0, 0, true);
90+
driveSubsystem.move(0, 0, 0, false);
7491
}
7592

7693
@Override
7794
public boolean isFinished() {
7895
return robotStateSubsystem.hasNote();
7996
}
97+
98+
private enum HuntState {
99+
SEARCHING,
100+
DRIVING
101+
}
80102
}

src/main/java/frc/robot/commands/auton/MiddleNote3AndWingNotesCommand.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public MiddleNote3AndWingNotesCommand(
9494
new SequentialCommandGroup(
9595
new IgnoreNotesCommand(
9696
robotStateSubsystem, superStructure, magazineSubsystem, intakeSubsystem),
97-
new WaitCommand(1.5),
97+
new WaitCommand(2.0),
9898
new IntakeCommand(
9999
robotStateSubsystem, superStructure, magazineSubsystem, intakeSubsystem))),
100100
new ParallelCommandGroup(
@@ -118,6 +118,12 @@ public MiddleNote3AndWingNotesCommand(
118118
robotStateSubsystem, superStructure, magazineSubsystem, intakeSubsystem),
119119
new DeadeyeHuntCommand(deadeye, driveSubsystem, robotStateSubsystem, ledSubsystem),
120120
new AutoWaitNoteStagedCommand(robotStateSubsystem),
121+
new VisionShootCommand(
122+
robotStateSubsystem, superStructure, magazineSubsystem, intakeSubsystem),
123+
124+
// Backup
125+
new DeadeyeHuntCommand(deadeye, driveSubsystem, robotStateSubsystem, ledSubsystem),
126+
new AutoWaitNoteStagedCommand(robotStateSubsystem),
121127
new VisionShootCommand(
122128
robotStateSubsystem, superStructure, magazineSubsystem, intakeSubsystem));
123129
}

src/main/java/frc/robot/commands/auton/MiddleNoteDriveAutonCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public boolean isFinished() {
133133
public void end(boolean interrupted) {
134134
driveSubsystem.setEnableHolo(false);
135135
driveSubsystem.setDeadEyeDrive(false);
136+
driveSubsystem.recordAutoTrajectory(null);
136137

137138
if (!lastPath) {
138139
driveSubsystem.calculateController(

src/main/java/frc/robot/commands/auton/WingNoteDriveAutonCommand.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ public void execute() {
126126

127127
@Override
128128
public boolean isFinished() {
129-
return timer.hasElapsed(trajectory.getTotalTimeSeconds())
130-
|| robotStateSubsystem.intakeHasNote();
129+
return timer.hasElapsed(trajectory.getTotalTimeSeconds());
131130
}
132131

133132
@Override
134133
public void end(boolean interrupted) {
135134
driveSubsystem.setEnableHolo(false);
136135
driveSubsystem.setDeadEyeDrive(false);
136+
driveSubsystem.recordAutoTrajectory(null);
137137

138138
if (!lastPath) {
139139
driveSubsystem.calculateController(

src/main/java/frc/robot/commands/drive/DriveAutonCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public boolean isFinished() {
8484
@Override
8585
public void end(boolean interrupted) {
8686
driveSubsystem.setEnableHolo(false);
87+
driveSubsystem.recordAutoTrajectory(null);
8788

8889
if (!lastPath) {
8990
driveSubsystem.calculateController(

src/main/java/frc/robot/constants/AutonConstants.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ public final class AutonConstants {
1313
public static final double kIDeadEyeXDrive = 0.0;
1414
public static final double kDDeadEyeXDrive = 0.0;
1515
public static final double kMaxVelDeadeyeDrive = 4.0;
16+
public static final double kMaxAutonVelDeadeyeDrive = 2.0;
1617
public static final double kMaxAccelDeadeyeDrive = 3.5;
1718
public static final double kXSpeed = 2.0;
1819
public static final double kMaxXOff = 1.0;
1920
public static final double kSwitchXLine = 6.5;
20-
public static final double kWingSwitchXLine = 2.0;
21+
public static final double kWingSwitchXLine = 1.4;
2122
public static final double kPercentLeft = 0.65;
23+
public static final double kDeadeyeHuntOmegaRadps = -1.5;
24+
public static final double kFoundNoteLoopCounts = 3;
2225

2326
public static final int kSwitchStableCounts = 100;
2427

0 commit comments

Comments
 (0)