65 lines
1.6 KiB
Java
Raw Normal View History

2023-02-06 19:02:17 -05:00
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package frc.robot.subsystems;
2023-02-15 19:40:02 -05:00
import edu.wpi.first.cameraserver.CameraServer;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
2023-02-22 18:50:04 -05:00
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
2023-02-15 17:24:38 -05:00
import org.photonvision.PhotonCamera;
import org.photonvision.common.hardware.VisionLEDMode;
2023-02-20 20:05:55 -05:00
2023-02-15 17:24:38 -05:00
import edu.wpi.first.net.PortForwarder;
2023-02-06 19:02:17 -05:00
import edu.wpi.first.wpilibj2.command.SubsystemBase;
2023-02-15 17:24:38 -05:00
2023-02-06 19:13:18 -05:00
public class Limelight extends SubsystemBase {
2023-02-22 18:50:04 -05:00
ShuffleboardTab teb = Shuffleboard.getTab("teb");
2023-02-15 17:24:38 -05:00
PhotonCamera limelight = new PhotonCamera("limelight");
2023-02-06 19:13:18 -05:00
/** Creates a new Limelight. */
2023-02-15 17:24:38 -05:00
public Limelight() {
2023-03-07 19:17:53 -05:00
CameraServer.startAutomaticCapture();
teb .add("limelight", 0.1);
2023-02-15 17:24:38 -05:00
PortForwarder.add(5800, "photonvision.local", 5800);
}
public void cube() {
limelight.setLED(VisionLEDMode.kOff);
limelight.setPipelineIndex(3);
}
2023-02-15 18:23:38 -05:00
public void cone() {
2023-02-15 17:24:38 -05:00
limelight.setLED(VisionLEDMode.kOff);
limelight.setPipelineIndex(2);
}
2023-02-06 19:02:17 -05:00
2023-02-15 18:23:38 -05:00
public void apriltag() {
limelight.setLED(VisionLEDMode.kOff);
limelight.setPipelineIndex(0);
}
public void tape() {
limelight.setLED(VisionLEDMode.kOn);
limelight.setPipelineIndex(1);
}
2023-02-20 18:56:29 -05:00
public double getYaw() {
var result = limelight.getLatestResult();
if(result.hasTargets()){
return result.getBestTarget().getYaw();
}
return 0;
}
public void pilote(){
limelight.setLED(VisionLEDMode.kOff);
limelight.setDriverMode(true);
}
2023-02-06 19:02:17 -05:00
@Override
public void periodic() {
}
}