|
|
|
@@ -8,6 +8,7 @@ import edu.wpi.first.net.PortForwarder;
|
|
|
|
import edu.wpi.first.networktables.NetworkTable;
|
|
|
|
import edu.wpi.first.networktables.NetworkTable;
|
|
|
|
import edu.wpi.first.networktables.NetworkTableEntry;
|
|
|
|
import edu.wpi.first.networktables.NetworkTableEntry;
|
|
|
|
import edu.wpi.first.networktables.NetworkTableInstance;
|
|
|
|
import edu.wpi.first.networktables.NetworkTableInstance;
|
|
|
|
|
|
|
|
import edu.wpi.first.wpilibj.Timer;
|
|
|
|
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
|
|
|
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
|
|
|
import frc.robot.LimelightHelpers;
|
|
|
|
import frc.robot.LimelightHelpers;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -16,10 +17,24 @@ public class Limelight3 extends SubsystemBase {
|
|
|
|
NetworkTableEntry pipeline = table.getEntry("pipeline");
|
|
|
|
NetworkTableEntry pipeline = table.getEntry("pipeline");
|
|
|
|
/** Creates a new Limelight3. */
|
|
|
|
/** Creates a new Limelight3. */
|
|
|
|
public Limelight3() {
|
|
|
|
public Limelight3() {
|
|
|
|
|
|
|
|
|
|
|
|
for(int port = 5800; port <=5807; port++){
|
|
|
|
for(int port = 5800; port <=5807; port++){
|
|
|
|
PortForwarder.add(port, "limelight.local", port);
|
|
|
|
PortForwarder.add(port, "limelight.local", port);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
double previousValue = 0;
|
|
|
|
|
|
|
|
double previousTime = Timer.getFPGATimestamp();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public double derive(double currentValue) {
|
|
|
|
|
|
|
|
double previousValue = 0;
|
|
|
|
|
|
|
|
double previousTime = Timer.getFPGATimestamp();
|
|
|
|
|
|
|
|
double now = Timer.getFPGATimestamp();
|
|
|
|
|
|
|
|
double dt = now - previousTime;
|
|
|
|
|
|
|
|
double derivative = (currentValue - previousValue) / dt;
|
|
|
|
|
|
|
|
previousValue = currentValue;
|
|
|
|
|
|
|
|
previousTime = now;
|
|
|
|
|
|
|
|
return derivative;
|
|
|
|
|
|
|
|
}
|
|
|
|
public double[] getTargetPose(){
|
|
|
|
public double[] getTargetPose(){
|
|
|
|
NetworkTable limelightTable = NetworkTableInstance.getDefault().getTable("limelight-balon");
|
|
|
|
NetworkTable limelightTable = NetworkTableInstance.getDefault().getTable("limelight-balon");
|
|
|
|
NetworkTableEntry targetPoseEntry = limelightTable.getEntry("targetpose_cameraspace");
|
|
|
|
NetworkTableEntry targetPoseEntry = limelightTable.getEntry("targetpose_cameraspace");
|
|
|
|
|