Skip to content

Commit

Permalink
added nt listener for auton selection
Browse files Browse the repository at this point in the history
  • Loading branch information
6kn4eakfr4s committed Apr 11, 2024
1 parent 6e00ea7 commit 5d3644c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5d3644c

Please sign in to comment.