From bde1715f76bed1918cc096c874ee06d05194faf7 Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Wed, 30 Oct 2024 18:46:48 -0400 Subject: [PATCH] LIMELIGHT 3G --- .../java/frc/robot/Subsystems/Limelight.java | 28 ----------- .../frc/robot/Subsystems/Limelight3G.java | 48 +++++++++++++++++++ 2 files changed, 48 insertions(+), 28 deletions(-) delete mode 100644 src/main/java/frc/robot/Subsystems/Limelight.java create mode 100644 src/main/java/frc/robot/Subsystems/Limelight3G.java diff --git a/src/main/java/frc/robot/Subsystems/Limelight.java b/src/main/java/frc/robot/Subsystems/Limelight.java deleted file mode 100644 index afeb914..0000000 --- a/src/main/java/frc/robot/Subsystems/Limelight.java +++ /dev/null @@ -1,28 +0,0 @@ -// 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 edu.wpi.first.wpilibj2.command.SubsystemBase; -import edu.wpi.first.networktables.NetworkTable; -import edu.wpi.first.networktables.NetworkTableEntry; -import edu.wpi.first.networktables.NetworkTableInstance; -public class Limelight extends SubsystemBase { -NetworkTable table = NetworkTableInstance.getDefault().getTable("limelight"); -NetworkTableEntry tx = table.getEntry("tx"); -NetworkTableEntry ty = table.getEntry("ty"); -NetworkTableEntry ta = table.getEntry("ta"); - -//read values periodically -double x = tx.getDouble(0.0); -double y = ty.getDouble(0.0); -double area = ta.getDouble(0.0); - /** Creates a new Limelight. */ - public Limelight() {} - - @Override - public void periodic() { - // This method will be called once per scheduler run - } -} diff --git a/src/main/java/frc/robot/Subsystems/Limelight3G.java b/src/main/java/frc/robot/Subsystems/Limelight3G.java new file mode 100644 index 0000000..de2ad2a --- /dev/null +++ b/src/main/java/frc/robot/Subsystems/Limelight3G.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 edu.wpi.first.wpilibj2.command.SubsystemBase; +import edu.wpi.first.net.PortForwarder; +import edu.wpi.first.networktables.NetworkTable; +import edu.wpi.first.networktables.NetworkTableEntry; +import edu.wpi.first.networktables.NetworkTableInstance; +public class Limelight3G extends SubsystemBase { + NetworkTable table = NetworkTableInstance.getDefault().getTable("limelight"); + + NetworkTableEntry tx = table.getEntry("tx"); + NetworkTableEntry ty = table.getEntry("ty"); + NetworkTableEntry pipeline = table.getEntry("pipeline"); + NetworkTableEntry tv = table.getEntry("tv"); + NetworkTableEntry camMode = table.getEntry("camMode"); + NetworkTableEntry tid = table.getEntry("tid"); + /** Creates a new Limelight. */ + public Limelight3G() { + for (int port = 5800; port <= 5807; port++) { + PortForwarder.add(port, "limelight.local", port); + }} + public double getx(){ + return tx.getDouble(0); + } + public double gety(){ + return ty.getDouble(0); + } + public double getv(){ + return tv.getDouble(0); + } + public void setpipeline(){ + pipeline.setNumber(0); + } + public void setcamMode(){ + camMode.setNumber(0); + } + public double getTid(){ + return tid.getDouble(0); + } + @Override + public void periodic() { + // This method will be called once per scheduler run + } +}