added vision class
This commit is contained in:
parent
0e91643b57
commit
34a547026d
47
src/main/java/frc/robot/subsystems/Vision.java
Normal file
47
src/main/java/frc/robot/subsystems/Vision.java
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
package frc.robot.subsystems;
|
||||||
|
|
||||||
|
import edu.wpi.first.networktables.BooleanSubscriber;
|
||||||
|
import edu.wpi.first.networktables.DoubleSubscriber;
|
||||||
|
import edu.wpi.first.networktables.NetworkTable;
|
||||||
|
import edu.wpi.first.networktables.NetworkTableInstance;
|
||||||
|
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||||
|
|
||||||
|
public class Vision extends SubsystemBase{
|
||||||
|
|
||||||
|
private DoubleSubscriber cam1GlobalPose;
|
||||||
|
private DoubleSubscriber cam1ClosestTag;
|
||||||
|
private BooleanSubscriber cam1TagDetected;
|
||||||
|
|
||||||
|
private DoubleSubscriber framerate;
|
||||||
|
|
||||||
|
public Vision(){
|
||||||
|
NetworkTableInstance inst = NetworkTableInstance.getDefault();
|
||||||
|
|
||||||
|
NetworkTable visionTable = inst.getTable("Fiducial");
|
||||||
|
|
||||||
|
cam1GlobalPose = visionTable.getDoubleTopic("cam1GlobalPose").subscribe(0.0);
|
||||||
|
cam1ClosestTag = visionTable.getDoubleTopic("cam1ClosestTag").subscribe(0.0);
|
||||||
|
|
||||||
|
cam1TagDetected = visionTable.getBooleanTopic("cam1_visible").subscribe(false);
|
||||||
|
// cam2TagDetected = visionTable.getBooleanTopic("cam2_visible").subscribe(false);
|
||||||
|
|
||||||
|
framerate = visionTable.getDoubleTopic("fps").subscribe(0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getCam1GlobalPose(){
|
||||||
|
return cam1GlobalPose.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getCam1ClosestTag(){
|
||||||
|
return cam1ClosestTag.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getCam1TagDetected(){
|
||||||
|
return cam1TagDetected.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getFPS(){
|
||||||
|
return framerate.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user