EdwardFaucher 77a03a5b34 drxgfh
2023-03-22 18:16:48 -04:00

69 lines
1.5 KiB
Java

// 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;
import org.photonvision.PhotonCamera;
import org.photonvision.common.hardware.VisionLEDMode;
import edu.wpi.first.net.PortForwarder;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
public class Limelight extends SubsystemBase {
PhotonCamera limelight = new PhotonCamera("limelight");
/** Creates a new Limelight. */
public Limelight() {
PortForwarder.add(5800, "photonvision.local", 5800);
}
public void cube() {
limelight.setLED(VisionLEDMode.kOff);
limelight.setPipelineIndex(3);
}
public void cone() {
limelight.setLED(VisionLEDMode.kOff);
limelight.setPipelineIndex(2);
}
public void apriltag() {
limelight.setLED(VisionLEDMode.kOff);
limelight.setPipelineIndex(0);
}
public void tape() {
limelight.setLED(VisionLEDMode.kOn);
limelight.setPipelineIndex(1);
}
public double getYaw() {
var result = limelight.getLatestResult();
if(result.hasTargets()){
return -result.getBestTarget().getYaw()/45;
}
return 0;
}
public void pilote(){
limelight.setLED(VisionLEDMode.kOff);
limelight.setDriverMode(true);
}
public void joueurhumain(){
limelight.setLED(VisionLEDMode.kOn);
}
public void joueurhumain1(){
limelight.setLED(VisionLEDMode.kOff);
}
@Override
public void periodic() {
}
}