Skip to content

Commit d04cb66

Browse files
authored
Merge pull request #121 from strykeforce/Implement-WallEye
Implement wall eye - build fails b/c of wallEye maven dependency
2 parents 04453a7 + 4723399 commit d04cb66

File tree

10 files changed

+1104
-351
lines changed

10 files changed

+1104
-351
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ dependencies {
5252
implementation wpi.java.deps.wpilib()
5353
implementation wpi.java.vendor.java()
5454

55+
implementation "org.strykeforce:wallEYE:1.0.0"
5556
implementation("com.opencsv:opencsv:5.7.1")
5657
implementation("com.squareup.moshi:moshi:1.13.0")
5758
implementation 'net.jafama:jafama:2.3.2'

networktables.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

simgui-ds.json

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
{
2+
"keyboardJoysticks": [
3+
{
4+
"axisConfig": [
5+
{
6+
"decKey": 65,
7+
"incKey": 68
8+
},
9+
{
10+
"decKey": 87,
11+
"incKey": 83
12+
},
13+
{
14+
"decKey": 69,
15+
"decayRate": 0.0,
16+
"incKey": 82,
17+
"keyRate": 0.009999999776482582
18+
}
19+
],
20+
"axisCount": 3,
21+
"buttonCount": 4,
22+
"buttonKeys": [
23+
90,
24+
88,
25+
67,
26+
86
27+
],
28+
"povConfig": [
29+
{
30+
"key0": 328,
31+
"key135": 323,
32+
"key180": 322,
33+
"key225": 321,
34+
"key270": 324,
35+
"key315": 327,
36+
"key45": 329,
37+
"key90": 326
38+
}
39+
],
40+
"povCount": 1
41+
},
42+
{
43+
"axisConfig": [
44+
{
45+
"decKey": 74,
46+
"incKey": 76
47+
},
48+
{
49+
"decKey": 73,
50+
"incKey": 75
51+
}
52+
],
53+
"axisCount": 2,
54+
"buttonCount": 4,
55+
"buttonKeys": [
56+
77,
57+
44,
58+
46,
59+
47
60+
],
61+
"povCount": 0
62+
},
63+
{
64+
"axisConfig": [
65+
{
66+
"decKey": 263,
67+
"incKey": 262
68+
},
69+
{
70+
"decKey": 265,
71+
"incKey": 264
72+
}
73+
],
74+
"axisCount": 2,
75+
"buttonCount": 6,
76+
"buttonKeys": [
77+
260,
78+
268,
79+
266,
80+
261,
81+
269,
82+
267
83+
],
84+
"povCount": 0
85+
},
86+
{
87+
"axisCount": 0,
88+
"buttonCount": 0,
89+
"povCount": 0
90+
}
91+
]
92+
}

simgui.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"NTProvider": {
3+
"types": {
4+
"/FMSInfo": "FMSInfo",
5+
"/Shuffleboard/Match/SetAllianceBlue": "Command",
6+
"/Shuffleboard/Match/SetAllianceRed": "Command",
7+
"/Shuffleboard/Match/Update With Vision": "Command"
8+
}
9+
},
10+
"NetworkTables": {
11+
"transitory": {
12+
"High": {
13+
"open": true
14+
},
15+
"WallEYE": {
16+
"open": true
17+
}
18+
}
19+
},
20+
"NetworkTables Info": {
21+
"Clients": {
22+
"open": true
23+
},
24+
"glass@1": {
25+
"Publishers": {
26+
"open": true
27+
},
28+
"open": true
29+
},
30+
"visible": true
31+
}
32+
}

src/main/java/frc/robot/Constants.java

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ public static final class VisionConstants {
387387

388388
public static final double kCameraOffset = .335; // was .273 on driveChasis
389389
public static final double kCameraAngleOffset = 0; // DEGREES was 24 on driveChasis
390-
public static final double kHighCameraAngleOffset = 0.0;
390+
public static final double kHighCameraAngleOffset = 0;
391391
public static final double kHighCameraOffset = -0.075;
392392
public static final double kLastUpdateCloseEnoughThreshold = 2.0; // IN SECONDS
393393
public static final double kLastUpdateCloseEnoughThresholdYaw = 1.0;
@@ -398,7 +398,7 @@ public static final class VisionConstants {
398398
public static int kBufferLookupOffset = 2;
399399

400400
public static Matrix<N3, N1> kStateStdDevs =
401-
VecBuilder.fill(0.1, 0.1, Units.degreesToRadians(5));
401+
VecBuilder.fill(0.1, 0.1, Units.degreesToRadians(0));
402402

403403
// Increase these numbers to trust sensor readings from encoders and gyros less. This matrix is
404404
// in the form [theta], with units in radians.
@@ -409,7 +409,32 @@ public static final class VisionConstants {
409409
// form [x, y, theta]ᵀ, with units in meters and radians.
410410
// Vision Odometry Standard devs
411411
public static Matrix<N3, N1> kVisionMeasurementStdDevs =
412-
VecBuilder.fill(0.05, 0.05, Units.degreesToRadians(5));
412+
VecBuilder.fill(0.05, 0.05, Units.degreesToRadians(5000));
413+
414+
// When trusting wheels the amount of times before the decay goes away
415+
public static int kNumResultsToResetStdDev = 3;
416+
417+
// Times it takes to trust wheels after trusting vision
418+
public static final int kNumResultsToTrustWheels = 5;
419+
420+
// Time (seconds) before std dev starts to decay
421+
public static final double kTimeToTightenStdDev = 1.0;
422+
423+
// Time (seconds) before getting kicked into only trusting camera
424+
public static final double kTimeToTrustCamera = 10.0;
425+
426+
// The linear rate of change on the std dev
427+
public static final double kStdDevDecayCoeff = 0.01 / 3.0;
428+
429+
// Minimum std dev for the declining std dev
430+
public static final double kMinimumStdDev = 0.01;
431+
432+
// Constants for the vision filter equations
433+
public static final int kMaxVisionOff = 5;
434+
public static final double kLinearCoeffOnVelFilter = 0.1;
435+
public static final double kOffsetOnVelFilter = 0.2;
436+
public static final double kSquaredCoeffOnVelFilter = 0.2;
437+
public static final double kCloseDistance = 4.0;
413438
}
414439

415440
public static final class FieldConstants {
@@ -877,7 +902,7 @@ public static class CompConstants {
877902
public static final double kShoulderFollowerZeroTicks = 2097; // 2057
878903

879904
// Intake
880-
public static final int kIntakeZeroTicks = 3_300; // 2440 ->2540->2_900
905+
public static final int kIntakeZeroTicks = 3_700; // 3300
881906
public static final double kExtendPosTicks = -2_200;
882907

883908
// Hand

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,10 @@ public RobotContainer() {
168168
rgbLightsSubsystem);
169169

170170
driveSubsystem.setRobotStateSubsystem(robotStateSubsystem);
171+
visionSubsystem.setRobotStateSubsystem(robotStateSubsystem);
171172

172173
driveSubsystem.setVisionSubsystem(visionSubsystem);
173-
visionSubsystem.setFillBuffers(true); // FIXME TRUE
174-
175-
// FIX ME
176-
robotStateSubsystem.setAllianceColor(Alliance.Blue);
174+
// visionSubsystem.setFillBuffers(true); // FIXME TRUE
177175

178176
configurePaths();
179177
// configureDriverButtonBindings();

src/main/java/frc/robot/subsystems/DriveSubsystem.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
import edu.wpi.first.wpilibj.Timer;
3131
import frc.robot.Constants;
3232
import frc.robot.Constants.DriveConstants;
33-
import frc.robot.Constants.VisionConstants;
3433
import frc.robot.subsystems.RobotStateSubsystem.GamePiece;
3534
import frc.robot.subsystems.RobotStateSubsystem.TargetCol;
35+
import frc.robot.subsystems.VisionSubsystem.VisionStates;
3636
import java.nio.file.Paths;
3737
import java.util.ArrayList;
3838
import java.util.Set;
@@ -349,10 +349,9 @@ public void driveToPose(TargetCol targetCol) {
349349
if (Math.abs(getFieldRelSpeed().vxMetersPerSecond) // FIXME TEMP CHECK IF STATEMENT
350350
<= DriveConstants.kMaxSpeedToAutoDrive
351351
&& Math.abs(getFieldRelSpeed().vyMetersPerSecond) <= DriveConstants.kMaxSpeedToAutoDrive
352-
&& (visionSubsystem.lastUpdateWithinThresholdTime(
353-
VisionConstants.kLastUpdateCloseEnoughThreshold)
352+
&& (visionSubsystem.getState() == VisionStates.trustWheels
354353
|| robotStateSubsystem.getIsAuto())
355-
&& ((visionSubsystem.getBufferedVelocity() <= DriveConstants.kMaxSpeedForCamUpdate))
354+
&& ((true))
356355
|| robotStateSubsystem.getIsAuto()) {
357356
setAutoDriving(true);
358357
if (robotStateSubsystem.getGamePiece() != GamePiece.NONE) {
@@ -385,8 +384,7 @@ public void driveToPose(TargetCol targetCol) {
385384
>= DriveConstants.kMaxSpeedToAutoDrive
386385
&& Math.abs(getFieldRelSpeed().vyMetersPerSecond)
387386
>= DriveConstants.kMaxSpeedToAutoDrive,
388-
visionSubsystem.lastUpdateWithinThresholdTime(
389-
VisionConstants.kLastUpdateCloseEnoughThreshold));
387+
visionSubsystem.getState() == VisionStates.trustWheels);
390388
logger.info("{} -> AUTO_DRIVE_FAILED", currDriveState);
391389
currDriveState = DriveStates.AUTO_DRIVE_FAILED;
392390
}
@@ -1037,8 +1035,8 @@ public void updateOdometryWithVision(Pose2d calculatedPose) {
10371035
odometryStrategy.addVisionMeasurement(calculatedPose, Timer.getFPGATimestamp());
10381036
}
10391037

1040-
public void updateOdometryWithVision(Pose2d calculatedPose, long timestamp) {
1041-
odometryStrategy.addVisionMeasurement(calculatedPose, timestamp);
1038+
public void updateOdometryWithVision(Pose2d calculatedPose, double timestamp) {
1039+
if (visionUpdates) odometryStrategy.addVisionMeasurement(calculatedPose, timestamp);
10421040
}
10431041

10441042
// Holonomic Controller

src/main/java/frc/robot/subsystems/RobotStateSubsystem.java

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import frc.robot.Constants.HandConstants;
1616
import frc.robot.Constants.IntakeConstants;
1717
import frc.robot.Constants.RobotStateConstants;
18-
import frc.robot.Constants.VisionConstants;
1918
import frc.robot.subsystems.ArmSubsystem.ArmState;
2019
import frc.robot.subsystems.DriveSubsystem.DriveStates;
2120
import frc.robot.subsystems.HandSubsystem.HandStates;
@@ -320,6 +319,7 @@ public void toAutoDrive() {
320319
"Starting AutoDrive. Gamepiece: {}, TargetCol: {}", gamePiece.toString(), tempTargetCol);
321320
driveSubsystem.driveToPose(tempTargetCol); // FIXME
322321
}
322+
323323
/**
324324
* @param isOnAllianceSide Is the robot on the alliance side of the charge station(Towards Tori)
325325
*/
@@ -430,13 +430,14 @@ public boolean shouldFastStowArm() {
430430
public void periodic() {
431431
switch (currRobotState) {
432432
case STOW:
433-
// if (!hasZeroedHand && handSubsystem.getVel() <= HandConstants.kHandVelocityThreshold) {
434-
// stableHandVel++;
435-
// if (stableHandVel >= HandConstants.kHandVelStable) {
436-
// stableHandVel = 0;
437-
// handSubsystem.zeroHand();
438-
// hasZeroedHand = true;
439-
// }
433+
// if (!hasZeroedHand && handSubsystem.getVel() <=
434+
// HandConstants.kHandVelocityThreshold) {
435+
// stableHandVel++;
436+
// if (stableHandVel >= HandConstants.kHandVelStable) {
437+
// stableHandVel = 0;
438+
// handSubsystem.zeroHand();
439+
// hasZeroedHand = true;
440+
// }
440441
// }
441442
if (currRobotState != nextRobotState) {
442443
switch (nextRobotState) {
@@ -937,7 +938,7 @@ public void periodic() {
937938
// INDICATOR STATE
938939

939940
// if (driveSubsystem.currDriveState == DriveStates.AUTO_BALANCE_FINISHED) {
940-
// //Auto_Balance_Finished
941+
// //Auto_Balance_Finished
941942
// }
942943
break;
943944
case CHECK_AMBIGUITY:
@@ -950,11 +951,11 @@ public void periodic() {
950951
currRobotState = RobotState.SHELF_WAIT_TRANSITION;
951952
}
952953
// if (visionSubsystem.lastUpdateWithinThresholdTime(
953-
// VisionConstants.kLastUpdateCloseEnoughThreshold)) {
954-
// rgbLightsSubsystem.setColor(0.0, 1.0, 1.0);
955-
// // toAutoDrive();
954+
// VisionConstants.kLastUpdateCloseEnoughThreshold)) {
955+
// rgbLightsSubsystem.setColor(0.0, 1.0, 1.0);
956+
// // toAutoDrive();
956957
// } else {
957-
// rgbLightsSubsystem.setColor(1.0, 0.0, 0.0);
958+
// rgbLightsSubsystem.setColor(1.0, 0.0, 0.0);
958959
// }
959960
break;
960961
case RECOVER_GAMEPIECE:
@@ -987,11 +988,7 @@ public void periodic() {
987988
&& driveSubsystem.getPoseMeters().getX()
988989
<= (RobotStateConstants.kFieldMaxX - DriveConstants.kPastBumpIndicateX)))
989990
&& !driveSubsystem.isAutoDriving()) {
990-
if (visionSubsystem.lastUpdateWithinThresholdTime(
991-
VisionConstants.kLastUpdateCloseEnoughThreshold
992-
- VisionConstants.kDifferenceCloseEnoughThreshold)
993-
&& (visionSubsystem.getBufferedVelocity() <= DriveConstants.kMaxSpeedForCamUpdate))
994-
rgbLightsSubsystem.setCubeColor();
991+
if (true) rgbLightsSubsystem.setCubeColor();
995992
else rgbLightsSubsystem.setColor(1.0, 0.0, 0.0);
996993
}
997994
}
@@ -1048,35 +1045,37 @@ public Pose2d getAutoPlaceDriveTarget(double yCoord, TargetCol tempTargetCol) {
10481045
}
10491046

10501047
// public double autoDriveYawRight(double yCoord) {
1051-
// int gridIndex =
1052-
// ((yCoord > Constants.RobotStateConstants.kBound1Y) ? 1 : 0)
1053-
// + ((yCoord > Constants.RobotStateConstants.kBound2Y) ? 1 : 0);
1054-
// // CHECK VISION
1055-
// double tempYaw = driveSubsystem.getGyroRotation2d().getDegrees();
1056-
// if (getAllianceColor() == Alliance.Red)
1057-
// tempYaw = driveSubsystem.getGyroRotation2d().getDegrees() - 180;
1058-
// logger.info("grid Index: {}", gridIndex);
1059-
// if (!visionSubsystem.lastUpdateWithinThresholdTime(0.05)) {
1060-
// // && visionSubsystem.getHasTargets() == 0) {
1061-
// logger.info("Threshold and no targets");
1062-
// if (driveSubsystem.getPoseMeters().getY() <
1048+
// int gridIndex =
1049+
// ((yCoord > Constants.RobotStateConstants.kBound1Y) ? 1 : 0)
1050+
// + ((yCoord > Constants.RobotStateConstants.kBound2Y) ? 1 : 0);
1051+
// // CHECK VISION
1052+
// double tempYaw = driveSubsystem.getGyroRotation2d().getDegrees();
1053+
// if (getAllianceColor() == Alliance.Red)
1054+
// tempYaw = driveSubsystem.getGyroRotation2d().getDegrees() - 180;
1055+
// logger.info("grid Index: {}", gridIndex);
1056+
// if (!visionSubsystem.lastUpdateWithinThresholdTime(0.05)) {
1057+
// // && visionSubsystem.getHasTargets() == 0) {
1058+
// logger.info("Threshold and no targets");
1059+
// if (driveSubsystem.getPoseMeters().getY() <
10631060
// Constants.RobotStateConstants.kGridY[gridIndex]) {
1064-
// // left of tag on grid {gridIndex} GYRO POSITIVE IS COUNTERCLOCKWISE (Yaw/Look To The
1065-
// // Right)
1066-
// logger.info("Left Of Tag, Look Right(Yaw CounterClockwise), tempYaw: {}", tempYaw);
1067-
// return 1;
1068-
// } else {
1069-
// // right of tag GYRO NEGATIVE IS CLOCKWISE (Yaw/Look To The LEFT)
1070-
// logger.info("Right Of Tag, Look Left(Yaw Clockwise), tempYaw: {}", tempYaw);
1071-
// return 2;
1072-
// }
1073-
// }
1074-
// logger.info(
1075-
// "Returned 0, tempYaw: {}, withThresholdVisUpdate: {}",
1076-
// tempYaw,
1077-
// visionSubsystem.lastUpdateWithinThresholdTime(
1078-
// Constants.VisionConstants.kLastUpdateCloseEnoughThresholdYaw));
1079-
// return 0;
1061+
// // left of tag on grid {gridIndex} GYRO POSITIVE IS COUNTERCLOCKWISE
1062+
// (Yaw/Look To The
1063+
// // Right)
1064+
// logger.info("Left Of Tag, Look Right(Yaw CounterClockwise), tempYaw: {}",
1065+
// tempYaw);
1066+
// return 1;
1067+
// } else {
1068+
// // right of tag GYRO NEGATIVE IS CLOCKWISE (Yaw/Look To The LEFT)
1069+
// logger.info("Right Of Tag, Look Left(Yaw Clockwise), tempYaw: {}", tempYaw);
1070+
// return 2;
1071+
// }
1072+
// }
1073+
// logger.info(
1074+
// "Returned 0, tempYaw: {}, withThresholdVisUpdate: {}",
1075+
// tempYaw,
1076+
// visionSubsystem.lastUpdateWithinThresholdTime(
1077+
// Constants.VisionConstants.kLastUpdateCloseEnoughThresholdYaw));
1078+
// return 0;
10801079
// }
10811080

10821081
public boolean isBlueAlliance() {

0 commit comments

Comments
 (0)