Skip to content

Commit 3e772f8

Browse files
authored
Merge branch 'master' into feature/pole-height-switcher
2 parents dbe7077 + bda8cc9 commit 3e772f8

17 files changed

Lines changed: 658 additions & 76 deletions

src/main/deploy/pathplanner/paths/L4 Opposite 1 - Triple.path

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
},
99
"prevControl": null,
1010
"nextControl": {
11-
"x": 6.072698863636364,
12-
"y": 5.421022727272727
11+
"x": 5.751089743589744,
12+
"y": 5.5937179487179485
1313
},
1414
"isLocked": false,
1515
"linkedName": "OppositeStart"
@@ -20,8 +20,8 @@
2020
"y": 5.096
2121
},
2222
"prevControl": {
23-
"x": 5.595607954545455,
24-
"y": 5.345289772727273
23+
"x": 5.431153846153845,
24+
"y": 5.542115384615385
2525
},
2626
"nextControl": null,
2727
"isLocked": false,
@@ -32,7 +32,7 @@
3232
"constraintZones": [
3333
{
3434
"name": "Constraints Zone",
35-
"minWaypointRelativePos": 0.769403824521935,
35+
"minWaypointRelativePos": 0.78,
3636
"maxWaypointRelativePos": 1.0,
3737
"constraints": {
3838
"maxVelocity": 1.5,

src/main/deploy/pathplanner/paths/L4 Opposite 2 - Triple.path

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
},
99
"prevControl": null,
1010
"nextControl": {
11-
"x": 4.37238446477125,
12-
"y": 6.006865646057453
11+
"x": 3.61474358974359,
12+
"y": 7.048910256410256
1313
},
1414
"isLocked": false,
1515
"linkedName": "ReefTopRight"
@@ -20,8 +20,8 @@
2020
"y": 7.1959659090909085
2121
},
2222
"prevControl": {
23-
"x": 2.582642045454545,
24-
"y": 6.368323863636363
23+
"x": 2.3246794871794867,
24+
"y": 6.997307692307693
2525
},
2626
"nextControl": null,
2727
"isLocked": false,
@@ -32,7 +32,7 @@
3232
"constraintZones": [
3333
{
3434
"name": "Constraints Zone",
35-
"minWaypointRelativePos": 0.8256467941507301,
35+
"minWaypointRelativePos": 0.76,
3636
"maxWaypointRelativePos": 1.0,
3737
"constraints": {
3838
"maxVelocity": 1.5,

src/main/deploy/pathplanner/paths/L4 Opposite 3 - Triple.path

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
},
99
"prevControl": null,
1010
"nextControl": {
11-
"x": 2.2635511363636365,
12-
"y": 6.55778409090909
11+
"x": 2.2209556741938354,
12+
"y": 6.483850839917186
1313
},
1414
"isLocked": false,
1515
"linkedName": "TopSource"
@@ -20,8 +20,8 @@
2020
"y": 5.096
2121
},
2222
"prevControl": {
23-
"x": 3.5519090909090916,
24-
"y": 5.484892045454546
23+
"x": 3.5631410256410248,
24+
"y": 5.366666666666667
2525
},
2626
"nextControl": null,
2727
"isLocked": false,
@@ -32,11 +32,11 @@
3232
"constraintZones": [
3333
{
3434
"name": "Constraints Zone",
35-
"minWaypointRelativePos": 0.708661417322838,
35+
"minWaypointRelativePos": 0.67,
3636
"maxWaypointRelativePos": 1.0,
3737
"constraints": {
38-
"maxVelocity": 0.9,
39-
"maxAcceleration": 1.5,
38+
"maxVelocity": 1.0,
39+
"maxAcceleration": 1.3,
4040
"maxAngularVelocity": 540.0,
4141
"maxAngularAcceleration": 720.0,
4242
"nominalVoltage": 12.0,

src/main/deploy/pathplanner/paths/L4 Opposite 4 - Triple.path

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
},
99
"prevControl": null,
1010
"nextControl": {
11-
"x": 3.442221590909091,
12-
"y": 5.524778409090909
11+
"x": 3.3257692307692306,
12+
"y": 5.4698717948717945
1313
},
1414
"isLocked": false,
1515
"linkedName": "ReefTopLeft_OffsetLeft"
@@ -20,8 +20,8 @@
2020
"y": 7.1959659090909085
2121
},
2222
"prevControl": {
23-
"x": 2.0940340909090915,
24-
"y": 6.747244318181817
23+
"x": 2.1698717948717943,
24+
"y": 6.625769230769231
2525
},
2626
"nextControl": null,
2727
"isLocked": false,
@@ -32,7 +32,7 @@
3232
"constraintZones": [
3333
{
3434
"name": "Constraints Zone",
35-
"minWaypointRelativePos": 0.7984234234234222,
35+
"minWaypointRelativePos": 0.74,
3636
"maxWaypointRelativePos": 1.0,
3737
"constraints": {
3838
"maxVelocity": 1.0,

src/main/deploy/pathplanner/paths/L4 Opposite 5 - Triple.path

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
},
99
"prevControl": null,
1010
"nextControl": {
11-
"x": 2.0398863636363638,
12-
"y": 6.822954545454544
11+
"x": 2.135968509345801,
12+
"y": 6.8154492991273745
1313
},
1414
"isLocked": false,
1515
"linkedName": "TopSource"
@@ -20,8 +20,8 @@
2020
"y": 5.096
2121
},
2222
"prevControl": {
23-
"x": 3.472136363636363,
24-
"y": 5.4450056818181825
23+
"x": 3.5321794871794863,
24+
"y": 5.480192307692307
2525
},
2626
"nextControl": null,
2727
"isLocked": false,
@@ -32,11 +32,11 @@
3232
"constraintZones": [
3333
{
3434
"name": "Constraints Zone",
35-
"minWaypointRelativePos": 0.8,
35+
"minWaypointRelativePos": 0.84,
3636
"maxWaypointRelativePos": 1.0,
3737
"constraints": {
38-
"maxVelocity": 1.5,
39-
"maxAcceleration": 1.5,
38+
"maxVelocity": 1.0,
39+
"maxAcceleration": 1.4,
4040
"maxAngularVelocity": 540.0,
4141
"maxAngularAcceleration": 720.0,
4242
"nominalVoltage": 12.0,

src/main/java/frc/robot/RobotContainer.java

Lines changed: 58 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@
6565
import frc.robot.subsystems.drive.commands.DriveCommandFactory;
6666
import frc.robot.subsystems.drive.commands.DriveWeightCommand;
6767
import frc.robot.subsystems.drive.weights.AntiTipWeight;
68+
import frc.robot.subsystems.drive.weights.DynamicAlignWeight;
6869
import frc.robot.subsystems.drive.weights.FollowPathDirect;
6970
import frc.robot.subsystems.drive.weights.FollowPathNearest;
7071
import frc.robot.subsystems.drive.weights.JoystickDriveWeight;
72+
import frc.robot.subsystems.drive.weights.LocalTagAlignWeight;
7173
import frc.robot.subsystems.drive.weights.PathplannerWeight;
7274
import frc.robot.subsystems.gantry.GantryIO;
7375
import frc.robot.subsystems.gantry.GantryIOSim;
@@ -148,6 +150,8 @@ public class RobotContainer {
148150

149151
private FollowPathNearest followPathReef;
150152
private FollowPathDirect followPathCoral;
153+
private LocalTagAlignWeight localAlign;
154+
private DynamicAlignWeight dynamicAlign;
151155

152156
private final JoystickDriveWeight joystickDriveWeight;
153157

@@ -167,15 +171,15 @@ public RobotContainer() {
167171
case REAL:
168172
new CoProcessInput(new OrangePILogger());
169173
gyro = new Gyro(new GyroIONavX());
170-
aprilTagVisions.add(
171-
new AprilTagVision(
172-
new AprilTagVisionIOPhotonvision(CameraConstants.frontCameraRight),
173-
CameraConstants.frontCameraRight));
174+
// aprilTagVisions.add(
175+
// new AprilTagVision(
176+
// new AprilTagVisionIOPhotonvision(CameraConstants.frontCameraRight),
177+
// CameraConstants.frontCameraRight));
174178

175-
aprilTagVisions.add(
176-
new AprilTagVision(
177-
new AprilTagVisionIOPhotonvision(CameraConstants.frontCameraLeft),
178-
CameraConstants.frontCameraLeft));
179+
// aprilTagVisions.add(
180+
// new AprilTagVision(
181+
// new AprilTagVisionIOPhotonvision(CameraConstants.frontCameraLeft),
182+
// CameraConstants.frontCameraLeft));
179183

180184
aprilTagVisions.add(
181185
new AprilTagVision(
@@ -298,20 +302,9 @@ public RobotContainer() {
298302
algaeCommandFactory,
299303
algaeIntakeSubsystem);
300304
AprilTagVision[] visionArray = aprilTagVisions.toArray(AprilTagVision[]::new);
301-
generateNamedCommands();
302305
driveSubsystem = new DriveSubsystem(gyro);
303306
driveCommandFactory = new DriveCommandFactory(driveSubsystem);
304307
robotOdometry = new RobotOdometry(driveSubsystem, gyro, visionArray);
305-
dashboard =
306-
new Dashboard(
307-
driveSubsystem,
308-
liftSubsystem,
309-
gantrySubsystem,
310-
climberSubsystem,
311-
algaeIntakeSubsystem,
312-
coralOuttakeSubsystem,
313-
winchSubsystem,
314-
driveController);
315308
alertsManager = new AlertsManager();
316309
AlertsManager.addAlert(
317310
() -> RobotController.getBatteryVoltage() < WarningThresholdConstants.minBatteryVoltage,
@@ -383,6 +376,21 @@ public RobotContainer() {
383376
DriveWeightCommand.create(
384377
driveCommandFactory, () -> liftSubsystem.getMotorPosition() > 0.3));
385378

379+
localAlign =
380+
new LocalTagAlignWeight(
381+
() ->
382+
DistanceManager.getNearestPosition(
383+
RobotOdometry.instance.getPose("Main"),
384+
AllianceManager.chooseFromAlliance(
385+
FieldConstants.reefPositionsBlue, FieldConstants.reefPositionsRed)),
386+
() -> RobotOdometry.instance.getPose("Main").getRotation(),
387+
driveSubsystem,
388+
driveCommandFactory,
389+
gyro,
390+
visionArray);
391+
392+
dynamicAlign = new DynamicAlignWeight(followPathReef, localAlign);
393+
386394
// winchSubsystem.setDefaultCommand(
387395
// climberCommandFactory.winchApplyVoltageCommand(() -> -operatorController.getLeftY() *
388396
// 4));
@@ -399,7 +407,8 @@ public void periodic() {
399407
Logger.recordOutput("AlgaeMode", algaeMode);
400408
Logger.recordOutput("CoralPreset", coralPreset);
401409
Logger.recordOutput("TargetPosAutoalign", getTarget());
402-
Logger.recordOutput("AutoAlignDone", followPathReef.isAutoalignComplete());
410+
Logger.recordOutput("AutoAlignDone", dynamicAlign.isAutoalignComplete());
411+
Logger.recordOutput("LocalTagAlign/alignStage", dynamicAlign.getStage());
403412
Logger.recordOutput("LiftDone", liftSubsystem.isAtPreset(presetActive));
404413
Logger.recordOutput(
405414
"LiftDoneAuto", liftSubsystem.isAtPreset(coralPreset.getLift()));
@@ -423,6 +432,19 @@ public void periodic() {
423432
Logger.recordOutput("target", getTarget());
424433
}
425434
});
435+
436+
generateNamedCommands();
437+
driveSubsystem.configurePathplanner();
438+
dashboard =
439+
new Dashboard(
440+
driveSubsystem,
441+
liftSubsystem,
442+
gantrySubsystem,
443+
climberSubsystem,
444+
algaeIntakeSubsystem,
445+
coralOuttakeSubsystem,
446+
winchSubsystem,
447+
driveController);
426448
}
427449

428450
public int getPoleID() {
@@ -510,14 +532,19 @@ private void configureBindings() {
510532
.getTranslation()
511533
.getDistance(getTarget().getTranslation())
512534
< 1.3
513-
&& followPathReef.isEnabled()
535+
&& dynamicAlign.isEnabled()
514536
&& Robot.getState() != RobotState.AUTONOMOUS)
515537
.onTrue(setupAutoPlace(() -> coralPreset));
516538
// coral place routine for autoalign
517539
// new Trigger(() -> coralAutoAlignWeight.isAutoalignComplete())
518540
// .onTrue(new InstantCommand(() -> driveController.setRumble(RumbleType.kRightRumble, 1)));
519-
followPathReef.generateTrigger(
520-
() -> driveHID.getAButton() && !followPathReef.isAutoalignComplete());
541+
// followPathReef.generateTrigger(
542+
// () ->
543+
// driveController.a().getAsBoolean()
544+
// && !followPathReef.isAutoalignComplete());
545+
DriveWeightCommand.createWeightTrigger(
546+
dynamicAlign,
547+
() -> driveController.a().getAsBoolean() && !dynamicAlign.globalAlignComplete());
521548
followPathCoral.generateTrigger(
522549
() -> driveHID.getLeftBumperButton() && !followPathCoral.isAutoalignComplete());
523550

@@ -1021,5 +1048,13 @@ public void generateNamedCommands() {
10211048
NamedCommands.registerCommand("PlaceTrough", autoScoringCommandFactory.placeTrough());
10221049
NamedCommands.registerCommand(
10231050
"logtest", new InstantCommand(() -> Logger.recordOutput("logtest", true)));
1051+
1052+
NamedCommands.registerCommand(
1053+
"LocalAlign",
1054+
localAlign
1055+
.getAutoCommand()
1056+
.deadlineFor(autonAutoPlace(() -> coralPreset))
1057+
.until(() -> localAlign.isAutoalignComplete() || !localAlign.isReady()));
1058+
NamedCommands.registerCommand("WaitForLocal", new WaitUntilCommand(() -> localAlign.isReady()));
10241059
}
10251060
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class FieldConstants {
1919
AprilTagFieldLayout.loadField(AprilTagFields.k2025ReefscapeAndyMark))
2020
.addValue(AprilTagSetting.WPICal, WPICALPosManager.aprilTagFieldLayout)
2121
.get();
22+
2223
public static final int tagCount = 22;
2324

2425
public static final VisionSystemSim visionSim = new VisionSystemSim("main");

0 commit comments

Comments
 (0)