[examples] Prepare for RobotInit deprecation by updating examples (#6623)

Co-authored-by: Tyler Veness <calcmogul@gmail.com>
This commit is contained in:
Jade
2024-07-17 11:22:39 +08:00
committed by GitHub
parent f62a055608
commit 57fa388724
156 changed files with 260 additions and 355 deletions

View File

@@ -17,14 +17,13 @@ import edu.wpi.first.wpilibj2.command.CommandScheduler;
public class Robot extends TimedRobot {
private Command m_autonomousCommand;
private RobotContainer m_robotContainer;
private final RobotContainer m_robotContainer;
/**
* This function is run when the robot is first started up and should be used for any
* initialization code.
*/
@Override
public void robotInit() {
public Robot() {
// Instantiate our RobotContainer. This will perform all our button bindings, and put our
// autonomous chooser on the dashboard.
m_robotContainer = new RobotContainer();

View File

@@ -11,10 +11,9 @@ import edu.wpi.first.wpilibj2.command.CommandScheduler;
public class Robot extends TimedRobot {
private Command m_autonomousCommand;
private RobotContainer m_robotContainer;
private final RobotContainer m_robotContainer;
@Override
public void robotInit() {
public Robot() {
m_robotContainer = new RobotContainer();
}

View File

@@ -12,7 +12,7 @@ import edu.wpi.first.wpilibj.internal.DriverStationModeThread;
/** Educational robot base class. */
public class EducationalRobot extends RobotBase {
public void robotInit() {}
public EducationalRobot() {}
public void disabled() {}
@@ -34,8 +34,6 @@ public class EducationalRobot extends RobotBase {
@Override
public void startCompetition() {
robotInit();
DriverStationModeThread modeThread = new DriverStationModeThread();
int event = WPIUtilJNI.createEvent(false, false);

View File

@@ -14,8 +14,7 @@ public class Robot extends EducationalRobot {
* This function is run when the robot is first started up and should be used for any
* initialization code.
*/
@Override
public void robotInit() {}
public Robot() {}
/** This function is run when the robot is enabled. */
@Override

View File

@@ -15,7 +15,7 @@ import edu.wpi.first.wpilibj.internal.DriverStationModeThread;
* package after creating this project, you must also update the build.gradle file in the project.
*/
public class Robot extends RobotBase {
public void robotInit() {}
public Robot() {}
public void disabled() {}
@@ -29,8 +29,6 @@ public class Robot extends RobotBase {
@Override
public void startCompetition() {
robotInit();
DriverStationModeThread modeThread = new DriverStationModeThread();
int event = WPIUtilJNI.createEvent(false, false);

View File

@@ -17,14 +17,13 @@ import edu.wpi.first.wpilibj2.command.CommandScheduler;
public class Robot extends TimedRobot {
private Command m_autonomousCommand;
private RobotContainer m_robotContainer;
private final RobotContainer m_robotContainer;
/**
* This function is run when the robot is first started up and should be used for any
* initialization code.
*/
@Override
public void robotInit() {
public Robot() {
// Instantiate our RobotContainer. This will perform all our button bindings, and put our
// autonomous chooser on the dashboard.
m_robotContainer = new RobotContainer();

View File

@@ -12,7 +12,7 @@ import edu.wpi.first.wpilibj.internal.DriverStationModeThread;
/** Educational robot base class. */
public class EducationalRobot extends RobotBase {
public void robotInit() {}
public EducationalRobot() {}
public void disabled() {}
@@ -34,8 +34,6 @@ public class EducationalRobot extends RobotBase {
@Override
public void startCompetition() {
robotInit();
DriverStationModeThread modeThread = new DriverStationModeThread();
int event = WPIUtilJNI.createEvent(false, false);

View File

@@ -14,8 +14,7 @@ public class Robot extends EducationalRobot {
* This function is run when the robot is first started up and should be used for any
* initialization code.
*/
@Override
public void robotInit() {}
public Robot() {}
/** This function is run when the robot is enabled. */
@Override

View File

@@ -26,8 +26,7 @@ public class Robot extends TimedRobot {
* This function is run when the robot is first started up and should be used for any
* initialization code.
*/
@Override
public void robotInit() {
public Robot() {
m_chooser.setDefaultOption("Default Auto", kDefaultAuto);
m_chooser.addOption("My Auto", kCustomAuto);
SmartDashboard.putData("Auto choices", m_chooser);

View File

@@ -24,8 +24,7 @@ public class Robot extends TimedRobot {
* This function is run when the robot is first started up and should be used for any
* initialization code.
*/
@Override
public void robotInit() {
public Robot() {
m_chooser.setDefaultOption("Default Auto", kDefaultAuto);
m_chooser.addOption("My Auto", kCustomAuto);
SmartDashboard.putData("Auto choices", m_chooser);

View File

@@ -17,8 +17,7 @@ public class Robot extends TimedRobot {
* This function is run when the robot is first started up and should be used for any
* initialization code.
*/
@Override
public void robotInit() {}
public Robot() {}
@Override
public void robotPeriodic() {}

View File

@@ -38,14 +38,7 @@ public class Robot extends TimesliceRobot {
// Total usage: 5 ms (robot) + 2 ms (controller 1) + 2 ms (controller 2)
// = 9 ms -> 90% allocated
}
/**
* This function is run when the robot is first started up and should be used for any
* initialization code.
*/
@Override
public void robotInit() {
m_chooser.setDefaultOption("Default Auto", kDefaultAuto);
m_chooser.addOption("My Auto", kCustomAuto);
SmartDashboard.putData("Auto choices", m_chooser);

View File

@@ -34,13 +34,6 @@ public class Robot extends TimesliceRobot {
// 9 ms / 10 ms -> 90% allocated
}
/**
* This function is run when the robot is first started up and should be used for any
* initialization code.
*/
@Override
public void robotInit() {}
@Override
public void robotPeriodic() {}

View File

@@ -17,14 +17,13 @@ import edu.wpi.first.wpilibj2.command.CommandScheduler;
public class Robot extends TimedRobot {
private Command m_autonomousCommand;
private RobotContainer m_robotContainer;
private final RobotContainer m_robotContainer;
/**
* This function is run when the robot is first started up and should be used for any
* initialization code.
*/
@Override
public void robotInit() {
public Robot() {
// Instantiate our RobotContainer. This will perform all our button bindings, and put our
// autonomous chooser on the dashboard.
m_robotContainer = new RobotContainer();

View File

@@ -12,7 +12,7 @@ import edu.wpi.first.wpilibj.internal.DriverStationModeThread;
/** Educational robot base class. */
public class EducationalRobot extends RobotBase {
public void robotInit() {}
public EducationalRobot() {}
public void disabled() {}
@@ -34,8 +34,6 @@ public class EducationalRobot extends RobotBase {
@Override
public void startCompetition() {
robotInit();
DriverStationModeThread modeThread = new DriverStationModeThread();
int event = WPIUtilJNI.createEvent(false, false);

View File

@@ -14,8 +14,7 @@ public class Robot extends EducationalRobot {
* This function is run when the robot is first started up and should be used for any
* initialization code.
*/
@Override
public void robotInit() {}
public Robot() {}
/** This function is run when the robot is enabled. */
@Override

View File

@@ -26,8 +26,7 @@ public class Robot extends TimedRobot {
* This function is run when the robot is first started up and should be used for any
* initialization code.
*/
@Override
public void robotInit() {
public Robot() {
m_chooser.setDefaultOption("Default Auto", kDefaultAuto);
m_chooser.addOption("My Auto", kCustomAuto);
SmartDashboard.putData("Auto choices", m_chooser);