From f9dd8385edcfd2b0ec19078f22777d535582b238 Mon Sep 17 00:00:00 2001 From: HeeistHo Date: Tue, 27 Jun 2023 17:11:34 -0400 Subject: [PATCH] started base code --- .../java/frc/robot/subsystems/PhotonBack.java | 48 +++++++++++++++++++ .../frc/robot/subsystems/PhotonFront.java | 0 2 files changed, 48 insertions(+) create mode 100644 src/main/java/frc/robot/subsystems/PhotonBack.java create mode 100644 src/main/java/frc/robot/subsystems/PhotonFront.java diff --git a/src/main/java/frc/robot/subsystems/PhotonBack.java b/src/main/java/frc/robot/subsystems/PhotonBack.java new file mode 100644 index 0000000..c41a156 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/PhotonBack.java @@ -0,0 +1,48 @@ +// 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.targeting.PhotonPipelineResult; + +import edu.wpi.first.wpilibj2.command.CommandScheduler; +import edu.wpi.first.wpilibj2.command.SubsystemBase; + +public class PhotonBack extends SubsystemBase { + + public String photonName; + PhotonCamera cam = new PhotonCamera(photonName); + boolean hasTarget = false; + + /** Creates a new PhotonBack. */ + public PhotonBack(String photonName) { + this.photonName = photonName; + + CommandScheduler.getInstance().registerSubsystem(this); + } + + @Override + public void periodic() { + // This method will be called once per scheduler run + } + + + public PhotonPipelineResult getPipelineResult() { + return cam.getLatestResult(); + } + + public double getYaw(){ + return getPipelineResult().getBestTarget().getYaw(); + } + + public double getPitch(){ + return getPipelineResult().getBestTarget().getPitch(); + } + + public double getSkew(){ + return getPipelineResult().getBestTarget().getSkew(); + } + +} diff --git a/src/main/java/frc/robot/subsystems/PhotonFront.java b/src/main/java/frc/robot/subsystems/PhotonFront.java new file mode 100644 index 0000000..e69de29