Skip to content

Commit 37e3dbf

Browse files
Make it so that drive assist occurs only when bounding box is seen
1 parent ba673dd commit 37e3dbf

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Robot2019/src/main/java/frc/robot/lib/Limelight.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,18 @@ public Limelight() {
2323

2424
// Adjusts the distance between a vision target and the robot. Uses basic PID with the ty value from the network table.
2525
public double distanceAssist() {
26+
tv = table.getEntry("tv").getDouble(0.0);
2627
ty = table.getEntry("ty").getDouble(0.0);
2728
SmartDashboard.putNumber("Crosshair Vertical Offset", ty);
2829
ta = table.getEntry("ta").getDouble(0.0);
2930
double adjustment = 0.0;
3031
double area_threshold = 0.5; // TODO: Set the desired area.
3132
double Kp = 0.2; // TODO: Set PID K value.
3233

33-
if (ta < area_threshold) {
34-
adjustment += Kp * ty;
34+
if (tv == 1.0) {
35+
if (ta < area_threshold) {
36+
adjustment += Kp * ty;
37+
}
3538
}
3639
return adjustment;
3740
}

0 commit comments

Comments
 (0)