This repository has been archived by the owner on Jan 16, 2024. It is now read-only.
-
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.
- Loading branch information
Showing
4 changed files
with
118 additions
and
3 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
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,61 @@ | ||
package frc.robot.util; | ||
|
||
import edu.wpi.first.networktables.NetworkTable; | ||
import edu.wpi.first.networktables.NetworkTableInstance; | ||
|
||
public class Limelight { | ||
private double tv, tx, ty, ta; | ||
|
||
private final double mountingAngleDegrees = 10.0; | ||
private final double limelightLensHeightInches = 20.0;//TODO Find this | ||
private final double goalHeightInches = 25.0;//TODO Find this | ||
private final NetworkTable table = NetworkTableInstance.getDefault().getTable("limelight"); | ||
//private final AHRS navx; | ||
public final String name; | ||
private double[] data; | ||
// private final PoseZeroFilter zeroFilter = new PoseZeroFilter(50, 48); | ||
// private final PoseMedianFilter medianFilter = new PoseMedianFilter(10); | ||
private double latency; | ||
private static double HORIZONTAL_FOV = Math.toRadians(63.3); | ||
private static double VERTICAL_FOV = Math.toRadians(49.7); | ||
|
||
public Limelight(String name) { | ||
this.name = name; | ||
|
||
} | ||
|
||
public void update(){ | ||
tv = table.getEntry("tv").getDouble(0); | ||
tx = table.getEntry("tx").getDouble(0); | ||
ty = table.getEntry("ty").getDouble(0); | ||
ta = table.getEntry("ta").getDouble(0); | ||
} | ||
|
||
public double getTa() { | ||
return ta; | ||
} | ||
|
||
public double getTx() { | ||
return tx; | ||
} | ||
|
||
public double getTy() { | ||
return ty; | ||
} | ||
|
||
public double getTv() { | ||
return tv; | ||
} | ||
|
||
public double getDistance(){ | ||
return (goalHeightInches - limelightLensHeightInches)/Math.tan(Math.toRadians(ty + mountingAngleDegrees)); | ||
} | ||
|
||
public boolean aimed(){ | ||
return tx < 1; | ||
} | ||
|
||
public double getHorizontalFov() { | ||
return HORIZONTAL_FOV; | ||
} | ||
} |