diff --git a/src/main/java/org/team199/robot2022/Robot.java b/src/main/java/org/team199/robot2022/Robot.java index d49b4e0..c68bff0 100644 --- a/src/main/java/org/team199/robot2022/Robot.java +++ b/src/main/java/org/team199/robot2022/Robot.java @@ -4,11 +4,12 @@ package org.team199.robot2022; +import edu.wpi.first.wpilibj.DataLogManager; +import edu.wpi.first.wpilibj.DriverStation; import edu.wpi.first.wpilibj.TimedRobot; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.CommandScheduler; import frc.robot.lib.MotorErrors; -import frc.robot.lib.logging.Log; /** * The VM is configured to automatically run this class, and to call the functions corresponding to @@ -25,10 +26,11 @@ public class Robot extends TimedRobot { */ @Override public void robotInit() { + DataLogManager.start(); + DriverStation.startDataLog(DataLogManager.getLog()); // Instantiate our RobotContainer. This will perform all our button bindings, and put our // autonomous chooser on the dashboard. robotContainer = new RobotContainer(this); - Log.init(); } /** @@ -49,7 +51,6 @@ public void robotPeriodic() { double totalAmps = robotContainer.pdp.getTotalCurrent(); SmartDashboard.putNumber("PDP Voltage", batteryVolts); SmartDashboard.putNumber("PDP Current", totalAmps); - Log.logData(); MotorErrors.printSparkMaxErrorMessages(); } @@ -62,8 +63,6 @@ public void disabledInit() { robotContainer.dt.coast(); } catch(InterruptedException e) {} }).start(); - Log.flush(); - Log.setDataLoggingDisabled(true); } @Override @@ -75,7 +74,6 @@ public void autonomousInit() { robotContainer.dt.brake(); robotContainer.dt.resetOdometry(); robotContainer.getAutonomousCommand().schedule(); - Log.setDataLoggingDisabled(false); robotContainer.initShooterConfig(); } @@ -91,7 +89,6 @@ public void teleopInit() { // this line or comment it out. CommandScheduler.getInstance().cancelAll(); robotContainer.dt.brake(); - Log.setDataLoggingDisabled(false); robotContainer.initShooterConfig(); } diff --git a/src/main/java/org/team199/robot2022/RobotContainer.java b/src/main/java/org/team199/robot2022/RobotContainer.java index 5e2b00d..970c828 100644 --- a/src/main/java/org/team199/robot2022/RobotContainer.java +++ b/src/main/java/org/team199/robot2022/RobotContainer.java @@ -107,6 +107,8 @@ public RobotContainer(Robot robot) { autoSelector.addOption(Integer.toString(i), autoPaths[i]); } + SmartDashboard.putData(shooter); + SmartDashboard.putData("Auto Selector", autoSelector); SmartDashboard.putNumber("Field Offset from North (degrees)", getAutoPath() == null ? 180 : getAutoPath().path.get(0).getRotation2d(0).getDegrees() + 180); diff --git a/src/main/java/org/team199/robot2022/subsystems/Shooter.java b/src/main/java/org/team199/robot2022/subsystems/Shooter.java index 57d25d2..5f31642 100644 --- a/src/main/java/org/team199/robot2022/subsystems/Shooter.java +++ b/src/main/java/org/team199/robot2022/subsystems/Shooter.java @@ -5,16 +5,14 @@ import org.team199.robot2022.Constants; +import edu.wpi.first.util.sendable.SendableBuilder; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; -//import edu.wpi.first.wpilibj.SpeedController; -//import java.lang.AutoCloseable; import edu.wpi.first.wpilibj2.command.SubsystemBase; import frc.robot.lib.MotorControllerFactory; import frc.robot.lib.SparkVelocityPIDController; import frc.robot.lib.MotorErrors.TemperatureLimit; import frc.robot.lib.LinearActuator; import frc.robot.lib.LinearInterpolation; -import frc.robot.lib.logging.Log; public class Shooter extends SubsystemBase { private static double kV = 0.129 / 60; @@ -64,10 +62,6 @@ public Shooter() { slave.setIdleMode(IdleMode.kCoast); SmartDashboard.putNumber("Ball PSI", ballPSI); - - Log.registerDoubleVar("Shooter RPM", () -> pidController.getEncoder().getVelocity()); - Log.registerDoubleVar("Shooter Current Master", () -> master.getOutputCurrent()); - Log.registerDoubleVar("Shooter Current Slave", () -> slave.getOutputCurrent()); } public void updateFromPSI() { @@ -180,6 +174,13 @@ public T chooseFromPosition(T fender, T awayFender, T tarmac) { } } + @Override + public void initSendable(SendableBuilder builder) { + super.initSendable(builder); + builder.addDoubleProperty("Shooter Master Current", master::getOutputCurrent, null); + builder.addDoubleProperty("Shooter Slave Current", slave::getOutputCurrent, null); + } + public static enum ShotPosition { FENDER, AWAY_FROM_FENDER, TARMAC; }