From 6289926c32f17a6d0c52e7ce0d0a871bc0bc87fa Mon Sep 17 00:00:00 2001 From: Jesse Chu Date: Tue, 9 Apr 2024 23:11:34 -0700 Subject: [PATCH 1/2] Fix wrong NT entry name. --- .../frc/robot/subsystems/shooter/ShooterPivotSubsystem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/subsystems/shooter/ShooterPivotSubsystem.java b/src/main/java/frc/robot/subsystems/shooter/ShooterPivotSubsystem.java index f6a0549c..255cec6a 100644 --- a/src/main/java/frc/robot/subsystems/shooter/ShooterPivotSubsystem.java +++ b/src/main/java/frc/robot/subsystems/shooter/ShooterPivotSubsystem.java @@ -128,7 +128,7 @@ public ShooterPivotSubsystem(DoubleSupplier distanceSupplier, BooleanSupplier re ntInstance = NetworkTableInstance.getDefault(); motorsTable = ntInstance.getTable("Motors"); - shooter12CurrentEntry = motorsTable.getEntry("Shooter12CurrentEntry"); + shooter12CurrentEntry = motorsTable.getEntry("Shooter12Current"); shooter12VoltageEntry = motorsTable.getEntry("Shooter12Voltage"); shooter12TemperatureEntry = motorsTable.getEntry("Shooter12Temperature"); } From 5d3644cfd97586fbbcf85eba8e5b70ee8278c40e Mon Sep 17 00:00:00 2001 From: Jesse Chu Date: Wed, 10 Apr 2024 20:34:35 -0700 Subject: [PATCH 2/2] added nt listener for auton selection --- src/main/java/frc/robot/RobotContainer.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 7b3c7569..24d7492c 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -8,6 +8,7 @@ import static frc.robot.Constants.VisionConstants.BACK_RIGHT_CAMERA; import static frc.robot.Constants.VisionConstants.NOTE_CAMERA; +import java.util.EnumSet; import java.util.function.BooleanSupplier; import com.choreo.lib.ChoreoTrajectory; @@ -18,6 +19,10 @@ import edu.wpi.first.math.geometry.Pose2d; import edu.wpi.first.math.util.Units; import edu.wpi.first.networktables.GenericEntry; +import edu.wpi.first.networktables.NetworkTable; +import edu.wpi.first.networktables.NetworkTableEntry; +import edu.wpi.first.networktables.NetworkTableEvent; +import edu.wpi.first.networktables.NetworkTableInstance; import edu.wpi.first.util.PixelFormat; import edu.wpi.first.wpilibj.DriverStation; import edu.wpi.first.wpilibj.GenericHID; @@ -145,10 +150,24 @@ public class RobotContainer { private boolean isNoteTrapReady = false; private boolean noteInBack = false; + private NetworkTableInstance ntInstance; + private NetworkTable autonTable; + private String autonValue; + private int autonHandle; /** * The container for the robot. Contains subsystems, OI devices, and commands. */ public RobotContainer() { + ntInstance = NetworkTableInstance.getDefault(); + autonTable = ntInstance.getTable("Auton"); + // try{ + autonTable.addListener("Auton", EnumSet.of(NetworkTableEvent.Kind.kValueAll), (table, key, event) -> { + this.autonValue = event.valueData.value.getString(); + System.out.print("New auton value: " + this.autonValue); + }); + // } catch (Exception e) { + // System.out.print(e); + // } fmsSubsystem = new FieldManagementSubsystem(); lightBarSubsystem = new LightBarSubsystem(); superstructureSubsystem = new SuperstructureSubsystem(lightBarSubsystem, fmsSubsystem);