102 lines
2.5 KiB
Java
102 lines
2.5 KiB
Java
// 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;
|
|
|
|
import org.littletonrobotics.junction.LogFileUtil;
|
|
import org.littletonrobotics.junction.LoggedRobot;
|
|
import org.littletonrobotics.junction.Logger;
|
|
import org.littletonrobotics.junction.networktables.NT4Publisher;
|
|
import org.littletonrobotics.junction.wpilog.WPILOGReader;
|
|
import org.littletonrobotics.junction.wpilog.WPILOGWriter;
|
|
|
|
import edu.wpi.first.wpilibj.PowerDistribution;
|
|
import edu.wpi.first.wpilibj.PowerDistribution.ModuleType;
|
|
import edu.wpi.first.wpilibj2.command.Command;
|
|
import edu.wpi.first.wpilibj2.command.CommandScheduler;
|
|
import frc.robot.constants.CompetitionConstants;
|
|
|
|
public class Robot extends LoggedRobot {
|
|
private Command m_autonomousCommand;
|
|
|
|
private final RobotContainer m_robotContainer;
|
|
|
|
@SuppressWarnings("resource")
|
|
public Robot() {
|
|
Logger.recordMetadata("ProjectName", "2026_Robot_Code");
|
|
|
|
if(isReal()) {
|
|
if(CompetitionConstants.kLogToNetworkTables) {
|
|
Logger.addDataReceiver(new NT4Publisher());
|
|
}
|
|
|
|
Logger.addDataReceiver(new WPILOGWriter());
|
|
|
|
new PowerDistribution(1, ModuleType.kRev);
|
|
} else {
|
|
setUseTiming(false);
|
|
String logPath = LogFileUtil.findReplayLog();
|
|
Logger.setReplaySource(new WPILOGReader(logPath));
|
|
Logger.addDataReceiver(new WPILOGWriter(LogFileUtil.addPathSuffix(logPath, "_sim")));
|
|
}
|
|
|
|
Logger.start();
|
|
|
|
m_robotContainer = new RobotContainer();
|
|
}
|
|
|
|
@Override
|
|
public void robotPeriodic() {
|
|
CommandScheduler.getInstance().run();
|
|
}
|
|
|
|
@Override
|
|
public void disabledInit() {}
|
|
|
|
@Override
|
|
public void disabledPeriodic() {}
|
|
|
|
@Override
|
|
public void disabledExit() {}
|
|
|
|
@Override
|
|
public void autonomousInit() {
|
|
m_autonomousCommand = m_robotContainer.getAutonomousCommand();
|
|
|
|
if (m_autonomousCommand != null) {
|
|
CommandScheduler.getInstance().schedule(m_autonomousCommand);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void autonomousPeriodic() {}
|
|
|
|
@Override
|
|
public void autonomousExit() {}
|
|
|
|
@Override
|
|
public void teleopInit() {
|
|
if (m_autonomousCommand != null) {
|
|
m_autonomousCommand.cancel();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void teleopPeriodic() {}
|
|
|
|
@Override
|
|
public void teleopExit() {}
|
|
|
|
@Override
|
|
public void testInit() {
|
|
CommandScheduler.getInstance().cancelAll();
|
|
}
|
|
|
|
@Override
|
|
public void testPeriodic() {}
|
|
|
|
@Override
|
|
public void testExit() {}
|
|
}
|