From 57fa3887245d36d35cbd6827666fbc2b6c5cc959 Mon Sep 17 00:00:00 2001 From: Jade Date: Wed, 17 Jul 2024 11:22:39 +0800 Subject: [PATCH] [examples] Prepare for RobotInit deprecation by updating examples (#6623) Co-authored-by: Tyler Veness --- .../edu/wpi/first/vision/package-info.java | 13 +++++----- .../src/main/java/frc/robot/Robot.java | 3 +-- developerRobot/src/main/native/cpp/Robot.cpp | 3 ++- .../native/include/frc/IterativeRobotBase.h | 6 ++--- .../src/test/native/cpp/TimedRobotTest.cpp | 4 +-- .../cpp/examples/AddressableLED/cpp/Robot.cpp | 2 +- .../examples/AddressableLED/include/Robot.h | 2 +- .../examples/AprilTagsVision/cpp/Robot.cpp | 25 ++++++++++--------- .../cpp/examples/ArcadeDrive/cpp/Robot.cpp | 2 -- .../ArcadeDriveXboxController/cpp/Robot.cpp | 2 -- .../main/cpp/examples/ArmBot/cpp/Robot.cpp | 2 +- .../main/cpp/examples/ArmBot/include/Robot.h | 2 +- .../cpp/examples/ArmBotOffboard/cpp/Robot.cpp | 2 +- .../examples/ArmBotOffboard/include/Robot.h | 2 +- .../examples/ArmSimulation/include/Robot.h | 2 +- .../main/cpp/examples/CANPDP/cpp/Robot.cpp | 2 +- .../src/main/cpp/examples/DMA/cpp/Robot.cpp | 2 +- .../DriveDistanceOffboard/cpp/Robot.cpp | 2 +- .../DriveDistanceOffboard/include/Robot.h | 2 +- .../examples/DutyCycleEncoder/cpp/Robot.cpp | 2 +- .../cpp/examples/DutyCycleInput/cpp/Robot.cpp | 2 +- .../include/Robot.h | 2 +- .../ElevatorSimulation/include/Robot.h | 2 +- .../main/cpp/examples/EventLoop/cpp/Robot.cpp | 2 +- .../FlywheelBangBangController/cpp/Robot.cpp | 2 +- .../cpp/examples/Frisbeebot/cpp/Robot.cpp | 2 +- .../cpp/examples/Frisbeebot/include/Robot.h | 2 +- .../main/cpp/examples/GearsBot/cpp/Robot.cpp | 2 +- .../cpp/examples/GearsBot/include/Robot.h | 2 +- .../src/main/cpp/examples/Gyro/cpp/Robot.cpp | 8 +++--- .../examples/GyroDriveCommands/cpp/Robot.cpp | 2 +- .../GyroDriveCommands/include/Robot.h | 2 +- .../cpp/examples/GyroMecanum/cpp/Robot.cpp | 2 +- .../examples/HatchbotInlined/cpp/Robot.cpp | 2 +- .../examples/HatchbotInlined/include/Robot.h | 2 +- .../HatchbotTraditional/cpp/Robot.cpp | 2 +- .../HatchbotTraditional/include/Robot.h | 2 +- .../cpp/examples/HttpCamera/cpp/Robot.cpp | 15 +++++------ .../examples/IntermediateVision/cpp/Robot.cpp | 25 ++++++++++--------- .../MecanumControllerCommand/cpp/Robot.cpp | 2 +- .../MecanumControllerCommand/include/Robot.h | 2 +- .../cpp/examples/MecanumDrive/cpp/Robot.cpp | 2 +- .../cpp/examples/Mechanism2d/cpp/Robot.cpp | 2 +- .../cpp/examples/MotorControl/cpp/Robot.cpp | 2 +- .../cpp/examples/QuickVision/cpp/Robot.cpp | 4 +-- .../RapidReactCommandBot/cpp/Robot.cpp | 2 +- .../include/RapidReactCommandBot.h | 2 +- .../RapidReactCommandBot/include/Robot.h | 2 +- .../cpp/examples/RomiReference/cpp/Robot.cpp | 2 +- .../examples/RomiReference/include/Robot.h | 2 +- .../cpp/examples/SelectCommand/cpp/Robot.cpp | 2 +- .../examples/SelectCommand/include/Robot.h | 2 +- .../cpp/examples/ShuffleBoard/cpp/Robot.cpp | 2 +- .../cpp/Robot.cpp | 2 +- .../main/cpp/examples/Solenoid/cpp/Robot.cpp | 2 +- .../cpp/examples/Solenoid/include/Robot.h | 2 +- .../cpp/examples/StateSpaceArm/cpp/Robot.cpp | 2 +- .../examples/StateSpaceElevator/cpp/Robot.cpp | 2 +- .../examples/StateSpaceFlywheel/cpp/Robot.cpp | 2 +- .../StateSpaceFlywheelSysId/cpp/Robot.cpp | 2 +- .../SwerveControllerCommand/cpp/Robot.cpp | 2 +- .../SwerveControllerCommand/include/Robot.h | 2 +- .../src/main/cpp/examples/SysId/cpp/Robot.cpp | 2 +- .../main/cpp/examples/SysId/include/Robot.h | 2 +- .../main/cpp/examples/TankDrive/cpp/Robot.cpp | 2 +- .../TankDriveXboxController/cpp/Robot.cpp | 2 +- .../cpp/examples/Ultrasonic/cpp/Robot.cpp | 2 +- .../cpp/examples/Ultrasonic/include/Robot.h | 2 +- .../cpp/examples/XRPReference/cpp/Robot.cpp | 2 +- .../cpp/examples/XRPReference/include/Robot.h | 2 +- .../cpp/templates/commandbased/cpp/Robot.cpp | 2 +- .../templates/commandbased/include/Robot.h | 2 +- .../commandbasedskeleton/cpp/Robot.cpp | 2 +- .../commandbasedskeleton/include/Robot.h | 2 +- .../templates/robotbaseskeleton/cpp/Robot.cpp | 4 +-- .../robotbaseskeleton/include/Robot.h | 2 +- .../main/cpp/templates/timed/cpp/Robot.cpp | 2 +- .../main/cpp/templates/timed/include/Robot.h | 2 +- .../cpp/templates/timedskeleton/cpp/Robot.cpp | 2 +- .../templates/timedskeleton/include/Robot.h | 2 +- .../cpp/templates/timeslice/cpp/Robot.cpp | 2 -- .../cpp/templates/timeslice/include/Robot.h | 2 -- .../templates/timesliceskeleton/cpp/Robot.cpp | 1 - .../timesliceskeleton/include/Robot.h | 1 - .../wpi/first/wpilibj/IterativeRobotBase.java | 5 ++-- .../edu/wpi/first/wpilibj/TimedRobotTest.java | 3 --- .../examples/addressableled/Robot.java | 8 +++--- .../examples/apriltagsvision/Robot.java | 4 +-- .../wpilibj/examples/arcadedrive/Robot.java | 4 +-- .../arcadedrivexboxcontroller/Robot.java | 4 +-- .../first/wpilibj/examples/armbot/Robot.java | 5 ++-- .../examples/armbotoffboard/Robot.java | 5 ++-- .../wpilibj/examples/armsimulation/Robot.java | 3 +-- .../first/wpilibj/examples/canpdp/Robot.java | 3 +-- .../wpi/first/wpilibj/examples/dma/Robot.java | 14 +++++------ .../examples/drivedistanceoffboard/Robot.java | 5 ++-- .../examples/dutycycleencoder/Robot.java | 6 ++--- .../examples/dutycycleinput/Robot.java | 5 ++-- .../elevatorexponentialprofile/Robot.java | 3 +-- .../elevatorexponentialsimulation/Robot.java | 3 --- .../examples/elevatorprofiledpid/Robot.java | 3 +-- .../examples/elevatorsimulation/Robot.java | 3 +-- .../elevatortrapezoidprofile/Robot.java | 3 +-- .../first/wpilibj/examples/encoder/Robot.java | 4 +-- .../wpilibj/examples/eventloop/Robot.java | 4 +-- .../flywheelbangbangcontroller/Robot.java | 3 +-- .../wpilibj/examples/frisbeebot/Robot.java | 5 ++-- .../wpilibj/examples/gearsbot/Robot.java | 5 ++-- .../examples/gettingstarted/Robot.java | 8 +----- .../first/wpilibj/examples/gyro/Robot.java | 4 +-- .../examples/gyrodrivecommands/Robot.java | 5 ++-- .../wpilibj/examples/gyromecanum/Robot.java | 16 ++++++------ .../examples/hatchbotinlined/Robot.java | 5 ++-- .../examples/hatchbottraditional/Robot.java | 5 ++-- .../wpilibj/examples/httpcamera/Robot.java | 4 +-- .../examples/intermediatevision/Robot.java | 4 +-- .../mecanumcontrollercommand/Robot.java | 5 ++-- .../wpilibj/examples/mecanumdrive/Robot.java | 18 ++++++------- .../wpilibj/examples/mechanism2d/Robot.java | 8 +++--- .../wpilibj/examples/motorcontrol/Robot.java | 11 ++++---- .../wpilibj/examples/quickvision/Robot.java | 5 ++-- .../RapidReactCommandBot.java | 2 +- .../examples/rapidreactcommandbot/Robot.java | 3 +-- .../wpilibj/examples/romireference/Robot.java | 5 ++-- .../wpilibj/examples/selectcommand/Robot.java | 5 ++-- .../wpilibj/examples/shuffleboard/Robot.java | 6 ++--- .../Robot.java | 6 ++--- .../wpilibj/examples/solenoid/Robot.java | 4 +-- .../wpilibj/examples/statespacearm/Robot.java | 3 +-- .../examples/statespaceelevator/Robot.java | 3 +-- .../examples/statespaceflywheel/Robot.java | 3 +-- .../statespaceflywheelsysid/Robot.java | 3 +-- .../swervecontrollercommand/Robot.java | 5 ++-- .../first/wpilibj/examples/sysid/Robot.java | 3 +-- .../examples/sysid/SysIdRoutineBot.java | 2 +- .../wpilibj/examples/tankdrive/Robot.java | 16 ++++++------ .../tankdrivexboxcontroller/Robot.java | 4 +-- .../wpilibj/examples/ultrasonic/Robot.java | 4 +-- .../wpilibj/examples/xrpreference/Robot.java | 5 ++-- .../wpilibj/templates/commandbased/Robot.java | 5 ++-- .../templates/commandbasedskeleton/Robot.java | 5 ++-- .../educational/EducationalRobot.java | 4 +-- .../wpilibj/templates/educational/Robot.java | 3 +-- .../templates/robotbaseskeleton/Robot.java | 4 +-- .../templates/romicommandbased/Robot.java | 5 ++-- .../romieducational/EducationalRobot.java | 4 +-- .../templates/romieducational/Robot.java | 3 +-- .../wpilibj/templates/romitimed/Robot.java | 3 +-- .../first/wpilibj/templates/timed/Robot.java | 3 +-- .../templates/timedskeleton/Robot.java | 3 +-- .../wpilibj/templates/timeslice/Robot.java | 7 ------ .../templates/timesliceskeleton/Robot.java | 7 ------ .../templates/xrpcommandbased/Robot.java | 5 ++-- .../xrpeducational/EducationalRobot.java | 4 +-- .../templates/xrpeducational/Robot.java | 3 +-- .../wpilibj/templates/xrptimed/Robot.java | 3 +-- 156 files changed, 260 insertions(+), 355 deletions(-) diff --git a/cameraserver/src/main/java/edu/wpi/first/vision/package-info.java b/cameraserver/src/main/java/edu/wpi/first/vision/package-info.java index e4515cbb0e5..d666206c320 100644 --- a/cameraserver/src/main/java/edu/wpi/first/vision/package-info.java +++ b/cameraserver/src/main/java/edu/wpi/first/vision/package-info.java @@ -30,6 +30,12 @@ * private double angleToTote = 0; * private double distanceToTote = 0; * + * public Robot() { + * usbCamera = CameraServer.startAutomaticCapture(0); + * findTotePipeline = new MyFindTotePipeline(); + * findToteThread = new VisionThread(usbCamera, findTotePipeline, this); + * } + * * {@literal @}Override * public void {@link edu.wpi.first.vision.VisionRunner.Listener#copyPipelineOutputs * copyPipelineOutputs(MyFindTotePipeline pipeline)} { @@ -43,13 +49,6 @@ * } * * {@literal @}Override - * public void robotInit() { - * usbCamera = CameraServer.startAutomaticCapture(0); - * findTotePipeline = new MyFindTotePipeline(); - * findToteThread = new VisionThread(usbCamera, findTotePipeline, this); - * } - * - * {@literal @}Override * public void autonomousInit() { * findToteThread.start(); * } diff --git a/developerRobot/src/main/java/frc/robot/Robot.java b/developerRobot/src/main/java/frc/robot/Robot.java index 0263e336983..6cf3f4738d7 100644 --- a/developerRobot/src/main/java/frc/robot/Robot.java +++ b/developerRobot/src/main/java/frc/robot/Robot.java @@ -11,8 +11,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() {} /** This function is run once each time the robot enters autonomous mode. */ @Override diff --git a/developerRobot/src/main/native/cpp/Robot.cpp b/developerRobot/src/main/native/cpp/Robot.cpp index 238697d42bd..6e013599e17 100644 --- a/developerRobot/src/main/native/cpp/Robot.cpp +++ b/developerRobot/src/main/native/cpp/Robot.cpp @@ -5,11 +5,12 @@ #include class Robot : public frc::TimedRobot { + public: /** * This function is run when the robot is first started up and should be * used for any initialization code. */ - void RobotInit() override {} + Robot() {} /** * This function is run once each time the robot enters autonomous mode diff --git a/wpilibc/src/main/native/include/frc/IterativeRobotBase.h b/wpilibc/src/main/native/include/frc/IterativeRobotBase.h index 8329c0b10e7..d730c70c4af 100644 --- a/wpilibc/src/main/native/include/frc/IterativeRobotBase.h +++ b/wpilibc/src/main/native/include/frc/IterativeRobotBase.h @@ -63,10 +63,8 @@ class IterativeRobotBase : public RobotBase { * which will be called when the robot is first powered on. It will be called * exactly one time. * - * Warning: the Driver Station "Robot Code" light and FMS "Robot Ready" - * indicators will be off until RobotInit() exits. Code in RobotInit() that - * waits for enable will cause the robot to never indicate that the code is - * ready, causing the robot to be bypassed in a match. + * Note: This method is functionally identical to the class constructor so + * that should be used instead. */ virtual void RobotInit(); diff --git a/wpilibc/src/test/native/cpp/TimedRobotTest.cpp b/wpilibc/src/test/native/cpp/TimedRobotTest.cpp index 78d18b5b3cc..d639ecce078 100644 --- a/wpilibc/src/test/native/cpp/TimedRobotTest.cpp +++ b/wpilibc/src/test/native/cpp/TimedRobotTest.cpp @@ -48,9 +48,7 @@ class MockRobot : public TimedRobot { std::atomic m_teleopPeriodicCount{0}; std::atomic m_testPeriodicCount{0}; - MockRobot() : TimedRobot{kPeriod} {} - - void RobotInit() override { m_robotInitCount++; } + MockRobot() : TimedRobot{kPeriod} { m_robotInitCount++; } void SimulationInit() override { m_simulationInitCount++; } diff --git a/wpilibcExamples/src/main/cpp/examples/AddressableLED/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/AddressableLED/cpp/Robot.cpp index 97c0925e4ff..70808ab4739 100644 --- a/wpilibcExamples/src/main/cpp/examples/AddressableLED/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/AddressableLED/cpp/Robot.cpp @@ -4,7 +4,7 @@ #include "Robot.h" -void Robot::RobotInit() { +Robot::Robot() { // Default to a length of 60, start empty output // Length is expensive to set, so only set it once, then just update data m_led.SetLength(kLength); diff --git a/wpilibcExamples/src/main/cpp/examples/AddressableLED/include/Robot.h b/wpilibcExamples/src/main/cpp/examples/AddressableLED/include/Robot.h index 488f5e5991c..9f87d160605 100644 --- a/wpilibcExamples/src/main/cpp/examples/AddressableLED/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/examples/AddressableLED/include/Robot.h @@ -12,7 +12,7 @@ class Robot : public frc::TimedRobot { public: - void RobotInit() override; + Robot(); void RobotPeriodic() override; private: diff --git a/wpilibcExamples/src/main/cpp/examples/AprilTagsVision/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/AprilTagsVision/cpp/Robot.cpp index 9f23be34075..b5df25d5973 100644 --- a/wpilibcExamples/src/main/cpp/examples/AprilTagsVision/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/AprilTagsVision/cpp/Robot.cpp @@ -32,6 +32,19 @@ * solution! */ class Robot : public frc::TimedRobot { + public: + Robot() { + // We need to run our vision program in a separate thread. If not, our robot + // program will not run. +#if defined(__linux__) || defined(_WIN32) + std::thread visionThread(VisionThread); + visionThread.detach(); +#else + std::fputs("Vision only available on Linux or Windows.\n", stderr); + std::fflush(stderr); +#endif + } + #if defined(__linux__) || defined(_WIN32) private: @@ -147,18 +160,6 @@ class Robot : public frc::TimedRobot { } } #endif - - void RobotInit() override { - // We need to run our vision program in a separate thread. If not, our robot - // program will not run. -#if defined(__linux__) || defined(_WIN32) - std::thread visionThread(VisionThread); - visionThread.detach(); -#else - std::fputs("Vision only available on Linux or Windows.\n", stderr); - std::fflush(stderr); -#endif - } }; #ifndef RUNNING_FRC_TESTS diff --git a/wpilibcExamples/src/main/cpp/examples/ArcadeDrive/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/ArcadeDrive/cpp/Robot.cpp index 9c8d64064fa..1c3e3564d3d 100644 --- a/wpilibcExamples/src/main/cpp/examples/ArcadeDrive/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/ArcadeDrive/cpp/Robot.cpp @@ -23,9 +23,7 @@ class Robot : public frc::TimedRobot { Robot() { wpi::SendableRegistry::AddChild(&m_robotDrive, &m_leftMotor); wpi::SendableRegistry::AddChild(&m_robotDrive, &m_rightMotor); - } - void RobotInit() override { // We need to invert one side of the drivetrain so that positive voltages // result in both sides moving forward. Depending on how your robot's // gearbox is constructed, you might have to invert the left side instead. diff --git a/wpilibcExamples/src/main/cpp/examples/ArcadeDriveXboxController/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/ArcadeDriveXboxController/cpp/Robot.cpp index 38ff862ab96..416c49c0f18 100644 --- a/wpilibcExamples/src/main/cpp/examples/ArcadeDriveXboxController/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/ArcadeDriveXboxController/cpp/Robot.cpp @@ -23,9 +23,7 @@ class Robot : public frc::TimedRobot { Robot() { wpi::SendableRegistry::AddChild(&m_robotDrive, &m_leftMotor); wpi::SendableRegistry::AddChild(&m_robotDrive, &m_rightMotor); - } - void RobotInit() override { // We need to invert one side of the drivetrain so that positive voltages // result in both sides moving forward. Depending on how your robot's // gearbox is constructed, you might have to invert the left side instead. diff --git a/wpilibcExamples/src/main/cpp/examples/ArmBot/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/ArmBot/cpp/Robot.cpp index 13eb9f9ac46..66f1a891db6 100644 --- a/wpilibcExamples/src/main/cpp/examples/ArmBot/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/ArmBot/cpp/Robot.cpp @@ -7,7 +7,7 @@ #include #include -void Robot::RobotInit() {} +Robot::Robot() {} /** * This function is called every 20 ms, no matter the mode. Use diff --git a/wpilibcExamples/src/main/cpp/examples/ArmBot/include/Robot.h b/wpilibcExamples/src/main/cpp/examples/ArmBot/include/Robot.h index de9c814e752..24056944479 100644 --- a/wpilibcExamples/src/main/cpp/examples/ArmBot/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/examples/ArmBot/include/Robot.h @@ -13,7 +13,7 @@ class Robot : public frc::TimedRobot { public: - void RobotInit() override; + Robot(); void RobotPeriodic() override; void DisabledInit() override; void DisabledPeriodic() override; diff --git a/wpilibcExamples/src/main/cpp/examples/ArmBotOffboard/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/ArmBotOffboard/cpp/Robot.cpp index c4c1661d699..142d59fa6be 100644 --- a/wpilibcExamples/src/main/cpp/examples/ArmBotOffboard/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/ArmBotOffboard/cpp/Robot.cpp @@ -7,7 +7,7 @@ #include #include -void Robot::RobotInit() {} +Robot::Robot() {} /** * This function is called every 20 ms, no matter the mode. Use diff --git a/wpilibcExamples/src/main/cpp/examples/ArmBotOffboard/include/Robot.h b/wpilibcExamples/src/main/cpp/examples/ArmBotOffboard/include/Robot.h index de9c814e752..24056944479 100644 --- a/wpilibcExamples/src/main/cpp/examples/ArmBotOffboard/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/examples/ArmBotOffboard/include/Robot.h @@ -13,7 +13,7 @@ class Robot : public frc::TimedRobot { public: - void RobotInit() override; + Robot(); void RobotPeriodic() override; void DisabledInit() override; void DisabledPeriodic() override; diff --git a/wpilibcExamples/src/main/cpp/examples/ArmSimulation/include/Robot.h b/wpilibcExamples/src/main/cpp/examples/ArmSimulation/include/Robot.h index fdcb5ce7f9a..30d90b6ca58 100644 --- a/wpilibcExamples/src/main/cpp/examples/ArmSimulation/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/examples/ArmSimulation/include/Robot.h @@ -14,7 +14,7 @@ */ class Robot : public frc::TimedRobot { public: - void RobotInit() override {} + Robot() {} void SimulationPeriodic() override; void TeleopInit() override; void TeleopPeriodic() override; diff --git a/wpilibcExamples/src/main/cpp/examples/CANPDP/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/CANPDP/cpp/Robot.cpp index 95a9a0d4121..b22c27cf904 100644 --- a/wpilibcExamples/src/main/cpp/examples/CANPDP/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/CANPDP/cpp/Robot.cpp @@ -13,7 +13,7 @@ */ class Robot : public frc::TimedRobot { public: - void RobotInit() override { + Robot() { // Put the PDP itself to the dashboard frc::SmartDashboard::PutData("PDP", &m_pdp); } diff --git a/wpilibcExamples/src/main/cpp/examples/DMA/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/DMA/cpp/Robot.cpp index 9097d944568..e5f47278731 100644 --- a/wpilibcExamples/src/main/cpp/examples/DMA/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/DMA/cpp/Robot.cpp @@ -25,7 +25,7 @@ class Robot : public frc::TimedRobot { frc::Encoder m_encoder{0, 1}; public: - void RobotInit() override { + Robot() { // Trigger on falling edge of dma trigger output m_dma.SetExternalTrigger(&m_dmaTrigger, false, true); diff --git a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/Robot.cpp index c4c1661d699..142d59fa6be 100644 --- a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/Robot.cpp @@ -7,7 +7,7 @@ #include #include -void Robot::RobotInit() {} +Robot::Robot() {} /** * This function is called every 20 ms, no matter the mode. Use diff --git a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/Robot.h b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/Robot.h index de9c814e752..24056944479 100644 --- a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/Robot.h @@ -13,7 +13,7 @@ class Robot : public frc::TimedRobot { public: - void RobotInit() override; + Robot(); void RobotPeriodic() override; void DisabledInit() override; void DisabledPeriodic() override; diff --git a/wpilibcExamples/src/main/cpp/examples/DutyCycleEncoder/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/DutyCycleEncoder/cpp/Robot.cpp index 3889d1c4dad..9d506f64fcf 100644 --- a/wpilibcExamples/src/main/cpp/examples/DutyCycleEncoder/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/DutyCycleEncoder/cpp/Robot.cpp @@ -20,7 +20,7 @@ class Robot : public frc::TimedRobot { frc::DutyCycleEncoder m_dutyCycleEncoder{0, fullRange, expectedZero}; public: - void RobotInit() override { + Robot() { // If you know the frequency of your sensor, uncomment the following // method, and set the method to the frequency of your sensor. // This will result in more stable readings from the sensor. diff --git a/wpilibcExamples/src/main/cpp/examples/DutyCycleInput/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/DutyCycleInput/cpp/Robot.cpp index 69d41bcfbcb..7be548d7447 100644 --- a/wpilibcExamples/src/main/cpp/examples/DutyCycleInput/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/DutyCycleInput/cpp/Robot.cpp @@ -12,7 +12,7 @@ class Robot : public frc::TimedRobot { frc::DutyCycle m_dutyCycle{m_input}; // Duty cycle input public: - void RobotInit() override {} + Robot() {} void RobotPeriodic() override { // Duty Cycle Frequency in Hz diff --git a/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialSimulation/include/Robot.h b/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialSimulation/include/Robot.h index f10310483d7..4e650b2fb9b 100644 --- a/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialSimulation/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialSimulation/include/Robot.h @@ -14,7 +14,7 @@ */ class Robot : public frc::TimedRobot { public: - void RobotInit() override {} + Robot() {} void RobotPeriodic() override; void SimulationPeriodic() override; void TeleopInit() override; diff --git a/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/include/Robot.h b/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/include/Robot.h index 53f50eabfea..70ff4fae031 100644 --- a/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/include/Robot.h @@ -14,7 +14,7 @@ */ class Robot : public frc::TimedRobot { public: - void RobotInit() override {} + Robot() {} void RobotPeriodic() override; void SimulationPeriodic() override; void TeleopPeriodic() override; diff --git a/wpilibcExamples/src/main/cpp/examples/EventLoop/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/EventLoop/cpp/Robot.cpp index a29d1699528..baab35f888d 100644 --- a/wpilibcExamples/src/main/cpp/examples/EventLoop/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/EventLoop/cpp/Robot.cpp @@ -22,7 +22,7 @@ static const auto KICKER_THRESHOLD = 15_mm; class Robot : public frc::TimedRobot { public: - void RobotInit() override { + Robot() { m_controller.SetTolerance(TOLERANCE.value()); frc::BooleanEvent isBallAtKicker{&m_loop, [&kickerSensor = m_kickerSensor] { diff --git a/wpilibcExamples/src/main/cpp/examples/FlywheelBangBangController/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/FlywheelBangBangController/cpp/Robot.cpp index 6763e7f97c2..88e552198a5 100644 --- a/wpilibcExamples/src/main/cpp/examples/FlywheelBangBangController/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/FlywheelBangBangController/cpp/Robot.cpp @@ -40,7 +40,7 @@ class Robot : public frc::TimedRobot { 0.9 * m_feedforward.Calculate(setpoint)); } - void RobotInit() override { + Robot() { // Add bang-bang controler to SmartDashboard and networktables. frc::SmartDashboard::PutData("BangBangControler", &m_bangBangControler); } diff --git a/wpilibcExamples/src/main/cpp/examples/Frisbeebot/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/Frisbeebot/cpp/Robot.cpp index c7eab485a5d..580decec83e 100644 --- a/wpilibcExamples/src/main/cpp/examples/Frisbeebot/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/Frisbeebot/cpp/Robot.cpp @@ -7,7 +7,7 @@ #include #include -void Robot::RobotInit() {} +Robot::Robot() {} /** * This function is called every 20 ms, no matter the mode. Use diff --git a/wpilibcExamples/src/main/cpp/examples/Frisbeebot/include/Robot.h b/wpilibcExamples/src/main/cpp/examples/Frisbeebot/include/Robot.h index a82f2ac63b0..b670df4cd8b 100644 --- a/wpilibcExamples/src/main/cpp/examples/Frisbeebot/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/examples/Frisbeebot/include/Robot.h @@ -11,7 +11,7 @@ class Robot : public frc::TimedRobot { public: - void RobotInit() override; + Robot(); void RobotPeriodic() override; void DisabledInit() override; void DisabledPeriodic() override; diff --git a/wpilibcExamples/src/main/cpp/examples/GearsBot/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/GearsBot/cpp/Robot.cpp index c7eab485a5d..580decec83e 100644 --- a/wpilibcExamples/src/main/cpp/examples/GearsBot/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/GearsBot/cpp/Robot.cpp @@ -7,7 +7,7 @@ #include #include -void Robot::RobotInit() {} +Robot::Robot() {} /** * This function is called every 20 ms, no matter the mode. Use diff --git a/wpilibcExamples/src/main/cpp/examples/GearsBot/include/Robot.h b/wpilibcExamples/src/main/cpp/examples/GearsBot/include/Robot.h index a82f2ac63b0..b670df4cd8b 100644 --- a/wpilibcExamples/src/main/cpp/examples/GearsBot/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/examples/GearsBot/include/Robot.h @@ -11,7 +11,7 @@ class Robot : public frc::TimedRobot { public: - void RobotInit() override; + Robot(); void RobotPeriodic() override; void DisabledInit() override; void DisabledPeriodic() override; diff --git a/wpilibcExamples/src/main/cpp/examples/Gyro/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/Gyro/cpp/Robot.cpp index d8af4100acb..5aee5916f9f 100644 --- a/wpilibcExamples/src/main/cpp/examples/Gyro/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/Gyro/cpp/Robot.cpp @@ -18,16 +18,14 @@ class Robot : public frc::TimedRobot { public: Robot() { - wpi::SendableRegistry::AddChild(&m_drive, &m_left); - wpi::SendableRegistry::AddChild(&m_drive, &m_right); - } - - void RobotInit() override { m_gyro.SetSensitivity(kVoltsPerDegreePerSecond); // We need to invert one side of the drivetrain so that positive voltages // result in both sides moving forward. Depending on how your robot's // gearbox is constructed, you might have to invert the left side instead. m_right.SetInverted(true); + + wpi::SendableRegistry::AddChild(&m_drive, &m_left); + wpi::SendableRegistry::AddChild(&m_drive, &m_right); } /** diff --git a/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/cpp/Robot.cpp index c4c1661d699..142d59fa6be 100644 --- a/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/cpp/Robot.cpp @@ -7,7 +7,7 @@ #include #include -void Robot::RobotInit() {} +Robot::Robot() {} /** * This function is called every 20 ms, no matter the mode. Use diff --git a/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/include/Robot.h b/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/include/Robot.h index de9c814e752..24056944479 100644 --- a/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/include/Robot.h @@ -13,7 +13,7 @@ class Robot : public frc::TimedRobot { public: - void RobotInit() override; + Robot(); void RobotPeriodic() override; void DisabledInit() override; void DisabledPeriodic() override; diff --git a/wpilibcExamples/src/main/cpp/examples/GyroMecanum/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/GyroMecanum/cpp/Robot.cpp index 7c589fd268e..e9ee85c8fff 100644 --- a/wpilibcExamples/src/main/cpp/examples/GyroMecanum/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/GyroMecanum/cpp/Robot.cpp @@ -15,7 +15,7 @@ */ class Robot : public frc::TimedRobot { public: - void RobotInit() override { + Robot() { wpi::SendableRegistry::AddChild(&m_robotDrive, &m_frontLeft); wpi::SendableRegistry::AddChild(&m_robotDrive, &m_rearLeft); wpi::SendableRegistry::AddChild(&m_robotDrive, &m_frontRight); diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/Robot.cpp index 72efd400492..d731edc1c90 100644 --- a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/Robot.cpp @@ -9,7 +9,7 @@ #include #include -void Robot::RobotInit() { +Robot::Robot() { // Start recording to data log frc::DataLogManager::Start(); diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/Robot.h b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/Robot.h index a82f2ac63b0..b670df4cd8b 100644 --- a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/Robot.h @@ -11,7 +11,7 @@ class Robot : public frc::TimedRobot { public: - void RobotInit() override; + Robot(); void RobotPeriodic() override; void DisabledInit() override; void DisabledPeriodic() override; diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/Robot.cpp index 72efd400492..d731edc1c90 100644 --- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/Robot.cpp @@ -9,7 +9,7 @@ #include #include -void Robot::RobotInit() { +Robot::Robot() { // Start recording to data log frc::DataLogManager::Start(); diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/Robot.h b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/Robot.h index a82f2ac63b0..b670df4cd8b 100644 --- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/Robot.h @@ -11,7 +11,7 @@ class Robot : public frc::TimedRobot { public: - void RobotInit() override; + Robot(); void RobotPeriodic() override; void DisabledInit() override; void DisabledPeriodic() override; diff --git a/wpilibcExamples/src/main/cpp/examples/HttpCamera/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/HttpCamera/cpp/Robot.cpp index e8b5fe0aa24..327569ddfb0 100644 --- a/wpilibcExamples/src/main/cpp/examples/HttpCamera/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/HttpCamera/cpp/Robot.cpp @@ -15,6 +15,14 @@ * processing. */ class Robot : public frc::TimedRobot { + public: + Robot() { + // We need to run our vision program in a separate thread. If not, our robot + // program will not run. + std::thread visionThread(VisionThread); + visionThread.detach(); + } + private: static void VisionThread() { // Create an HTTP camera. The address will need to be modified to have the @@ -50,13 +58,6 @@ class Robot : public frc::TimedRobot { outputStream.PutFrame(mat); } } - - void RobotInit() override { - // We need to run our vision program in a separate thread. If not, our robot - // program will not run. - std::thread visionThread(VisionThread); - visionThread.detach(); - } }; #ifndef RUNNING_FRC_TESTS diff --git a/wpilibcExamples/src/main/cpp/examples/IntermediateVision/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/IntermediateVision/cpp/Robot.cpp index b61f86d56b9..a65646c3d1f 100644 --- a/wpilibcExamples/src/main/cpp/examples/IntermediateVision/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/IntermediateVision/cpp/Robot.cpp @@ -18,6 +18,19 @@ * processing. */ class Robot : public frc::TimedRobot { + public: + Robot() { + // We need to run our vision program in a separate thread. If not, our robot + // program will not run. +#if defined(__linux__) || defined(_WIN32) + std::thread visionThread(VisionThread); + visionThread.detach(); +#else + std::fputs("Vision only available on Linux or Windows.\n", stderr); + std::fflush(stderr); +#endif + } + #if defined(__linux__) || defined(_WIN32) private: @@ -55,18 +68,6 @@ class Robot : public frc::TimedRobot { } } #endif - - void RobotInit() override { - // We need to run our vision program in a separate thread. If not, our robot - // program will not run. -#if defined(__linux__) || defined(_WIN32) - std::thread visionThread(VisionThread); - visionThread.detach(); -#else - std::fputs("Vision only available on Linux or Windows.\n", stderr); - std::fflush(stderr); -#endif - } }; #ifndef RUNNING_FRC_TESTS diff --git a/wpilibcExamples/src/main/cpp/examples/MecanumControllerCommand/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/MecanumControllerCommand/cpp/Robot.cpp index c4c1661d699..142d59fa6be 100644 --- a/wpilibcExamples/src/main/cpp/examples/MecanumControllerCommand/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/MecanumControllerCommand/cpp/Robot.cpp @@ -7,7 +7,7 @@ #include #include -void Robot::RobotInit() {} +Robot::Robot() {} /** * This function is called every 20 ms, no matter the mode. Use diff --git a/wpilibcExamples/src/main/cpp/examples/MecanumControllerCommand/include/Robot.h b/wpilibcExamples/src/main/cpp/examples/MecanumControllerCommand/include/Robot.h index de9c814e752..24056944479 100644 --- a/wpilibcExamples/src/main/cpp/examples/MecanumControllerCommand/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/examples/MecanumControllerCommand/include/Robot.h @@ -13,7 +13,7 @@ class Robot : public frc::TimedRobot { public: - void RobotInit() override; + Robot(); void RobotPeriodic() override; void DisabledInit() override; void DisabledPeriodic() override; diff --git a/wpilibcExamples/src/main/cpp/examples/MecanumDrive/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/MecanumDrive/cpp/Robot.cpp index eeb9ce13233..84cbf7916b6 100644 --- a/wpilibcExamples/src/main/cpp/examples/MecanumDrive/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/MecanumDrive/cpp/Robot.cpp @@ -13,7 +13,7 @@ */ class Robot : public frc::TimedRobot { public: - void RobotInit() override { + Robot() { wpi::SendableRegistry::AddChild(&m_robotDrive, &m_frontLeft); wpi::SendableRegistry::AddChild(&m_robotDrive, &m_rearLeft); wpi::SendableRegistry::AddChild(&m_robotDrive, &m_frontRight); diff --git a/wpilibcExamples/src/main/cpp/examples/Mechanism2d/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/Mechanism2d/cpp/Robot.cpp index 6d1967fd29f..600f28b3414 100644 --- a/wpilibcExamples/src/main/cpp/examples/Mechanism2d/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/Mechanism2d/cpp/Robot.cpp @@ -30,7 +30,7 @@ class Robot : public frc::TimedRobot { static constexpr double kElevatorMinimumLength = 0.5; public: - void RobotInit() override { + Robot() { m_elevatorEncoder.SetDistancePerPulse(kMetersPerPulse); // publish to dashboard diff --git a/wpilibcExamples/src/main/cpp/examples/MotorControl/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/MotorControl/cpp/Robot.cpp index 7a4325f3714..f3b114edc72 100644 --- a/wpilibcExamples/src/main/cpp/examples/MotorControl/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/MotorControl/cpp/Robot.cpp @@ -33,7 +33,7 @@ class Robot : public frc::TimedRobot { frc::SmartDashboard::PutNumber("Encoder", m_encoder.GetDistance()); } - void RobotInit() override { + Robot() { // Use SetDistancePerPulse to set the multiplier for GetDistance // This is set up assuming a 6 inch wheel with a 360 CPR encoder. m_encoder.SetDistancePerPulse((std::numbers::pi * 6) / 360.0); diff --git a/wpilibcExamples/src/main/cpp/examples/QuickVision/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/QuickVision/cpp/Robot.cpp index aae646f8db3..3044e82352e 100644 --- a/wpilibcExamples/src/main/cpp/examples/QuickVision/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/QuickVision/cpp/Robot.cpp @@ -11,11 +11,11 @@ * Uses the CameraServer class to automatically capture video from a USB webcam * and send it to the FRC dashboard without doing any vision processing. This is * the easiest way to get camera images to the dashboard. Just add this to the - * RobotInit() method in your program. + * robot class constructor. */ class Robot : public frc::TimedRobot { public: - void RobotInit() override { + Robot() { #if defined(__linux__) || defined(_WIN32) frc::CameraServer::StartAutomaticCapture(); #else diff --git a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/Robot.cpp index 06bbe40c9a3..d28c275f8ef 100644 --- a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/Robot.cpp @@ -4,7 +4,7 @@ #include "Robot.h" -void Robot::RobotInit() { +Robot::Robot() { // Configure default commands and condition bindings on robot startup m_robot.ConfigureBindings(); } diff --git a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/RapidReactCommandBot.h b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/RapidReactCommandBot.h index 0071a83b65d..77f8340e6dc 100644 --- a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/RapidReactCommandBot.h +++ b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/RapidReactCommandBot.h @@ -27,7 +27,7 @@ class RapidReactCommandBot { * Use this method to define bindings between conditions and commands. These * are useful for automating robot behaviors based on button and sensor input. * - *

Should be called during Robot::RobotInit(). + *

Should be called in the robot class constructor. * *

Event binding methods are available on the frc2::Trigger class. */ diff --git a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/Robot.h b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/Robot.h index bab80f7039c..e88daeecef9 100644 --- a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/Robot.h @@ -13,7 +13,7 @@ class Robot : public frc::TimedRobot { public: - void RobotInit() override; + Robot(); void RobotPeriodic() override; void DisabledInit() override; void DisabledPeriodic() override; diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/Robot.cpp index e39a8fd5811..59163407357 100644 --- a/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/Robot.cpp @@ -6,7 +6,7 @@ #include -void Robot::RobotInit() {} +Robot::Robot() {} /** * This function is called every 20 ms, no matter the mode. Use diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/Robot.h b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/Robot.h index eb35fab06dd..f6b09dcc2f3 100644 --- a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/Robot.h @@ -11,7 +11,7 @@ class Robot : public frc::TimedRobot { public: - void RobotInit() override; + Robot(); void RobotPeriodic() override; void DisabledInit() override; void DisabledPeriodic() override; diff --git a/wpilibcExamples/src/main/cpp/examples/SelectCommand/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/SelectCommand/cpp/Robot.cpp index c7eab485a5d..580decec83e 100644 --- a/wpilibcExamples/src/main/cpp/examples/SelectCommand/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/SelectCommand/cpp/Robot.cpp @@ -7,7 +7,7 @@ #include #include -void Robot::RobotInit() {} +Robot::Robot() {} /** * This function is called every 20 ms, no matter the mode. Use diff --git a/wpilibcExamples/src/main/cpp/examples/SelectCommand/include/Robot.h b/wpilibcExamples/src/main/cpp/examples/SelectCommand/include/Robot.h index a82f2ac63b0..b670df4cd8b 100644 --- a/wpilibcExamples/src/main/cpp/examples/SelectCommand/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/examples/SelectCommand/include/Robot.h @@ -11,7 +11,7 @@ class Robot : public frc::TimedRobot { public: - void RobotInit() override; + Robot(); void RobotPeriodic() override; void DisabledInit() override; void DisabledPeriodic() override; diff --git a/wpilibcExamples/src/main/cpp/examples/ShuffleBoard/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/ShuffleBoard/cpp/Robot.cpp index b532bcbf75b..61c5dd44964 100644 --- a/wpilibcExamples/src/main/cpp/examples/ShuffleBoard/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/ShuffleBoard/cpp/Robot.cpp @@ -29,7 +29,7 @@ */ class Robot : public frc::TimedRobot { public: - void RobotInit() override { + Robot() { wpi::SendableRegistry::AddChild(&m_robotDrive, &m_left); wpi::SendableRegistry::AddChild(&m_robotDrive, &m_right); diff --git a/wpilibcExamples/src/main/cpp/examples/SimpleDifferentialDriveSimulation/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/SimpleDifferentialDriveSimulation/cpp/Robot.cpp index fa1cfe1bdb9..8b31c3dd3dd 100644 --- a/wpilibcExamples/src/main/cpp/examples/SimpleDifferentialDriveSimulation/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/SimpleDifferentialDriveSimulation/cpp/Robot.cpp @@ -13,7 +13,7 @@ class Robot : public frc::TimedRobot { public: - void RobotInit() override { + Robot() { m_trajectory = frc::TrajectoryGenerator::GenerateTrajectory( frc::Pose2d{2_m, 2_m, 0_rad}, {}, frc::Pose2d{6_m, 4_m, 0_rad}, frc::TrajectoryConfig(2_mps, 2_mps_sq)); diff --git a/wpilibcExamples/src/main/cpp/examples/Solenoid/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/Solenoid/cpp/Robot.cpp index 88a2dbf242e..25311e82d68 100644 --- a/wpilibcExamples/src/main/cpp/examples/Solenoid/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/Solenoid/cpp/Robot.cpp @@ -7,7 +7,7 @@ #include #include -void Robot::RobotInit() { +Robot::Robot() { // Publish elements to shuffleboard. frc::ShuffleboardTab& tab = frc::Shuffleboard::GetTab("Pneumatics"); tab.Add("Single Solenoid", m_solenoid); diff --git a/wpilibcExamples/src/main/cpp/examples/Solenoid/include/Robot.h b/wpilibcExamples/src/main/cpp/examples/Solenoid/include/Robot.h index 550e949994c..46920ce620f 100644 --- a/wpilibcExamples/src/main/cpp/examples/Solenoid/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/examples/Solenoid/include/Robot.h @@ -35,7 +35,7 @@ class Robot : public frc::TimedRobot { public: - void RobotInit() override; + Robot(); void TeleopPeriodic() override; private: diff --git a/wpilibcExamples/src/main/cpp/examples/StateSpaceArm/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/StateSpaceArm/cpp/Robot.cpp index 01d3db6abe3..8233e7cde89 100644 --- a/wpilibcExamples/src/main/cpp/examples/StateSpaceArm/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/StateSpaceArm/cpp/Robot.cpp @@ -93,7 +93,7 @@ class Robot : public frc::TimedRobot { frc::TrapezoidProfile::State m_lastProfiledReference; public: - void RobotInit() override { + Robot() { // We go 2 pi radians per 4096 clicks. m_encoder.SetDistancePerPulse(2.0 * std::numbers::pi / 4096.0); } diff --git a/wpilibcExamples/src/main/cpp/examples/StateSpaceElevator/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/StateSpaceElevator/cpp/Robot.cpp index 08074f8cf1b..7c8a4613074 100644 --- a/wpilibcExamples/src/main/cpp/examples/StateSpaceElevator/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/StateSpaceElevator/cpp/Robot.cpp @@ -92,7 +92,7 @@ class Robot : public frc::TimedRobot { frc::TrapezoidProfile::State m_lastProfiledReference; public: - void RobotInit() override { + Robot() { // Circumference = pi * d, so distance per click = pi * d / counts m_encoder.SetDistancePerPulse(2.0 * std::numbers::pi * kDrumRadius.value() / 4096.0); diff --git a/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp index b0a9ed3a92f..4e3b7cdd160 100644 --- a/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp @@ -80,7 +80,7 @@ class Robot : public frc::TimedRobot { frc::XboxController m_joystick{kJoystickPort}; public: - void RobotInit() override { + Robot() { // We go 2 pi radians per 4096 clicks. m_encoder.SetDistancePerPulse(2.0 * std::numbers::pi / 4096.0); } diff --git a/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp index 2be14fd49f0..8546f7c0444 100644 --- a/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp @@ -80,7 +80,7 @@ class Robot : public frc::TimedRobot { frc::XboxController m_joystick{kJoystickPort}; public: - void RobotInit() override { + Robot() { // We go 2 pi radians per 4096 clicks. m_encoder.SetDistancePerPulse(2.0 * std::numbers::pi / 4096.0); } diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/Robot.cpp index c4c1661d699..142d59fa6be 100644 --- a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/Robot.cpp @@ -7,7 +7,7 @@ #include #include -void Robot::RobotInit() {} +Robot::Robot() {} /** * This function is called every 20 ms, no matter the mode. Use diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/include/Robot.h b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/include/Robot.h index de9c814e752..24056944479 100644 --- a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/include/Robot.h @@ -13,7 +13,7 @@ class Robot : public frc::TimedRobot { public: - void RobotInit() override; + Robot(); void RobotPeriodic() override; void DisabledInit() override; void DisabledPeriodic() override; diff --git a/wpilibcExamples/src/main/cpp/examples/SysId/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/SysId/cpp/Robot.cpp index 32782b29ae2..2ed3f804f55 100644 --- a/wpilibcExamples/src/main/cpp/examples/SysId/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/SysId/cpp/Robot.cpp @@ -6,7 +6,7 @@ #include -void Robot::RobotInit() {} +Robot::Robot() {} void Robot::RobotPeriodic() { frc2::CommandScheduler::GetInstance().Run(); diff --git a/wpilibcExamples/src/main/cpp/examples/SysId/include/Robot.h b/wpilibcExamples/src/main/cpp/examples/SysId/include/Robot.h index b6142c2405b..c6e5806d9a8 100644 --- a/wpilibcExamples/src/main/cpp/examples/SysId/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/examples/SysId/include/Robot.h @@ -13,7 +13,7 @@ class Robot : public frc::TimedRobot { public: - void RobotInit() override; + Robot(); void RobotPeriodic() override; void DisabledInit() override; void DisabledPeriodic() override; diff --git a/wpilibcExamples/src/main/cpp/examples/TankDrive/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/TankDrive/cpp/Robot.cpp index f7b3e9c6900..91a21979268 100644 --- a/wpilibcExamples/src/main/cpp/examples/TankDrive/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/TankDrive/cpp/Robot.cpp @@ -21,7 +21,7 @@ class Robot : public frc::TimedRobot { frc::Joystick m_rightStick{1}; public: - void RobotInit() override { + Robot() { wpi::SendableRegistry::AddChild(&m_robotDrive, &m_leftMotor); wpi::SendableRegistry::AddChild(&m_robotDrive, &m_rightMotor); diff --git a/wpilibcExamples/src/main/cpp/examples/TankDriveXboxController/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/TankDriveXboxController/cpp/Robot.cpp index 7c0706ef791..6241d3c396e 100644 --- a/wpilibcExamples/src/main/cpp/examples/TankDriveXboxController/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/TankDriveXboxController/cpp/Robot.cpp @@ -20,7 +20,7 @@ class Robot : public frc::TimedRobot { frc::XboxController m_driverController{0}; public: - void RobotInit() override { + Robot() { wpi::SendableRegistry::AddChild(&m_robotDrive, &m_leftMotor); wpi::SendableRegistry::AddChild(&m_robotDrive, &m_rightMotor); diff --git a/wpilibcExamples/src/main/cpp/examples/Ultrasonic/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/Ultrasonic/cpp/Robot.cpp index ac47856ee2e..67c5b719b01 100644 --- a/wpilibcExamples/src/main/cpp/examples/Ultrasonic/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/Ultrasonic/cpp/Robot.cpp @@ -8,7 +8,7 @@ #include #include -void Robot::RobotInit() { +Robot::Robot() { // Add the ultrasonic on the "Sensors" tab of the dashboard // Data will update automatically frc::Shuffleboard::GetTab("Sensors").Add(m_rangeFinder); diff --git a/wpilibcExamples/src/main/cpp/examples/Ultrasonic/include/Robot.h b/wpilibcExamples/src/main/cpp/examples/Ultrasonic/include/Robot.h index 2da0c6ffa5e..9d14ae0ef8b 100644 --- a/wpilibcExamples/src/main/cpp/examples/Ultrasonic/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/examples/Ultrasonic/include/Robot.h @@ -13,7 +13,7 @@ */ class Robot : public frc::TimedRobot { public: - void RobotInit() override; + Robot(); void TeleopPeriodic() override; void TestInit() override; void TestPeriodic() override; diff --git a/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/Robot.cpp index e39a8fd5811..59163407357 100644 --- a/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/Robot.cpp @@ -6,7 +6,7 @@ #include -void Robot::RobotInit() {} +Robot::Robot() {} /** * This function is called every 20 ms, no matter the mode. Use diff --git a/wpilibcExamples/src/main/cpp/examples/XRPReference/include/Robot.h b/wpilibcExamples/src/main/cpp/examples/XRPReference/include/Robot.h index eb35fab06dd..f6b09dcc2f3 100644 --- a/wpilibcExamples/src/main/cpp/examples/XRPReference/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/examples/XRPReference/include/Robot.h @@ -11,7 +11,7 @@ class Robot : public frc::TimedRobot { public: - void RobotInit() override; + Robot(); void RobotPeriodic() override; void DisabledInit() override; void DisabledPeriodic() override; diff --git a/wpilibcExamples/src/main/cpp/templates/commandbased/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/templates/commandbased/cpp/Robot.cpp index c1c1ae64437..6a1eb4beea5 100644 --- a/wpilibcExamples/src/main/cpp/templates/commandbased/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/templates/commandbased/cpp/Robot.cpp @@ -6,7 +6,7 @@ #include -void Robot::RobotInit() {} +Robot::Robot() {} /** * This function is called every 20 ms, no matter the mode. Use diff --git a/wpilibcExamples/src/main/cpp/templates/commandbased/include/Robot.h b/wpilibcExamples/src/main/cpp/templates/commandbased/include/Robot.h index e9d45e7acdd..794e6437a93 100644 --- a/wpilibcExamples/src/main/cpp/templates/commandbased/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/templates/commandbased/include/Robot.h @@ -13,7 +13,7 @@ class Robot : public frc::TimedRobot { public: - void RobotInit() override; + Robot(); void RobotPeriodic() override; void DisabledInit() override; void DisabledPeriodic() override; diff --git a/wpilibcExamples/src/main/cpp/templates/commandbasedskeleton/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/templates/commandbasedskeleton/cpp/Robot.cpp index 32782b29ae2..2ed3f804f55 100644 --- a/wpilibcExamples/src/main/cpp/templates/commandbasedskeleton/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/templates/commandbasedskeleton/cpp/Robot.cpp @@ -6,7 +6,7 @@ #include -void Robot::RobotInit() {} +Robot::Robot() {} void Robot::RobotPeriodic() { frc2::CommandScheduler::GetInstance().Run(); diff --git a/wpilibcExamples/src/main/cpp/templates/commandbasedskeleton/include/Robot.h b/wpilibcExamples/src/main/cpp/templates/commandbasedskeleton/include/Robot.h index 6bdb217a2a5..886f9b9fc49 100644 --- a/wpilibcExamples/src/main/cpp/templates/commandbasedskeleton/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/templates/commandbasedskeleton/include/Robot.h @@ -13,7 +13,7 @@ class Robot : public frc::TimedRobot { public: - void RobotInit() override; + Robot(); void RobotPeriodic() override; void DisabledInit() override; void DisabledPeriodic() override; diff --git a/wpilibcExamples/src/main/cpp/templates/robotbaseskeleton/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/templates/robotbaseskeleton/cpp/Robot.cpp index 0c67d6d7f04..850e2e41800 100644 --- a/wpilibcExamples/src/main/cpp/templates/robotbaseskeleton/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/templates/robotbaseskeleton/cpp/Robot.cpp @@ -11,7 +11,7 @@ #include #include -void Robot::RobotInit() {} +Robot::Robot() {} void Robot::Disabled() {} @@ -22,8 +22,6 @@ void Robot::Teleop() {} void Robot::Test() {} void Robot::StartCompetition() { - RobotInit(); - frc::internal::DriverStationModeThread modeThread; wpi::Event event{false, false}; diff --git a/wpilibcExamples/src/main/cpp/templates/robotbaseskeleton/include/Robot.h b/wpilibcExamples/src/main/cpp/templates/robotbaseskeleton/include/Robot.h index 9b63fb26d77..cb165d0524a 100644 --- a/wpilibcExamples/src/main/cpp/templates/robotbaseskeleton/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/templates/robotbaseskeleton/include/Robot.h @@ -10,7 +10,7 @@ class Robot : public frc::RobotBase { public: - void RobotInit(); + Robot(); void Disabled(); void Autonomous(); void Teleop(); diff --git a/wpilibcExamples/src/main/cpp/templates/timed/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/templates/timed/cpp/Robot.cpp index c248d043593..162037e3e49 100644 --- a/wpilibcExamples/src/main/cpp/templates/timed/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/templates/timed/cpp/Robot.cpp @@ -7,7 +7,7 @@ #include #include -void Robot::RobotInit() { +Robot::Robot() { m_chooser.SetDefaultOption(kAutoNameDefault, kAutoNameDefault); m_chooser.AddOption(kAutoNameCustom, kAutoNameCustom); frc::SmartDashboard::PutData("Auto Modes", &m_chooser); diff --git a/wpilibcExamples/src/main/cpp/templates/timed/include/Robot.h b/wpilibcExamples/src/main/cpp/templates/timed/include/Robot.h index 5677a88fe52..cdf36b8508e 100644 --- a/wpilibcExamples/src/main/cpp/templates/timed/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/templates/timed/include/Robot.h @@ -11,7 +11,7 @@ class Robot : public frc::TimedRobot { public: - void RobotInit() override; + Robot(); void RobotPeriodic() override; void AutonomousInit() override; void AutonomousPeriodic() override; diff --git a/wpilibcExamples/src/main/cpp/templates/timedskeleton/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/templates/timedskeleton/cpp/Robot.cpp index d5b57c2836a..85a862f5f17 100644 --- a/wpilibcExamples/src/main/cpp/templates/timedskeleton/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/templates/timedskeleton/cpp/Robot.cpp @@ -4,7 +4,7 @@ #include "Robot.h" -void Robot::RobotInit() {} +Robot::Robot() {} void Robot::RobotPeriodic() {} void Robot::AutonomousInit() {} diff --git a/wpilibcExamples/src/main/cpp/templates/timedskeleton/include/Robot.h b/wpilibcExamples/src/main/cpp/templates/timedskeleton/include/Robot.h index 062a198f168..8d87e6b5c0f 100644 --- a/wpilibcExamples/src/main/cpp/templates/timedskeleton/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/templates/timedskeleton/include/Robot.h @@ -8,7 +8,7 @@ class Robot : public frc::TimedRobot { public: - void RobotInit() override; + Robot(); void RobotPeriodic() override; void AutonomousInit() override; diff --git a/wpilibcExamples/src/main/cpp/templates/timeslice/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/templates/timeslice/cpp/Robot.cpp index 3dec6eb3657..7f79b234965 100644 --- a/wpilibcExamples/src/main/cpp/templates/timeslice/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/templates/timeslice/cpp/Robot.cpp @@ -23,9 +23,7 @@ Robot::Robot() : frc::TimesliceRobot{5_ms, 10_ms} { // Total usage: // 5 ms (robot) + 2 ms (controller 1) + 2 ms (controller 2) = 9 ms // 9 ms / 10 ms -> 90% allocated -} -void Robot::RobotInit() { m_chooser.SetDefaultOption(kAutoNameDefault, kAutoNameDefault); m_chooser.AddOption(kAutoNameCustom, kAutoNameCustom); frc::SmartDashboard::PutData("Auto Modes", &m_chooser); diff --git a/wpilibcExamples/src/main/cpp/templates/timeslice/include/Robot.h b/wpilibcExamples/src/main/cpp/templates/timeslice/include/Robot.h index aaafdf7df19..82e0ceba0bf 100644 --- a/wpilibcExamples/src/main/cpp/templates/timeslice/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/templates/timeslice/include/Robot.h @@ -12,8 +12,6 @@ class Robot : public frc::TimesliceRobot { public: Robot(); - - void RobotInit() override; void RobotPeriodic() override; void AutonomousInit() override; void AutonomousPeriodic() override; diff --git a/wpilibcExamples/src/main/cpp/templates/timesliceskeleton/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/templates/timesliceskeleton/cpp/Robot.cpp index 10f98dd5656..1a4f064affb 100644 --- a/wpilibcExamples/src/main/cpp/templates/timesliceskeleton/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/templates/timesliceskeleton/cpp/Robot.cpp @@ -23,7 +23,6 @@ Robot::Robot() : frc::TimesliceRobot{5_ms, 10_ms} { // 9 ms / 10 ms -> 90% allocated } -void Robot::RobotInit() {} void Robot::RobotPeriodic() {} void Robot::AutonomousInit() {} diff --git a/wpilibcExamples/src/main/cpp/templates/timesliceskeleton/include/Robot.h b/wpilibcExamples/src/main/cpp/templates/timesliceskeleton/include/Robot.h index 6659bf99c6c..d599e413fe1 100644 --- a/wpilibcExamples/src/main/cpp/templates/timesliceskeleton/include/Robot.h +++ b/wpilibcExamples/src/main/cpp/templates/timesliceskeleton/include/Robot.h @@ -10,7 +10,6 @@ class Robot : public frc::TimesliceRobot { public: Robot(); - void RobotInit() override; void RobotPeriodic() override; void AutonomousInit() override; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/IterativeRobotBase.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/IterativeRobotBase.java index e7869544704..50eddff5fdb 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/IterativeRobotBase.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/IterativeRobotBase.java @@ -97,9 +97,8 @@ protected IterativeRobotBase(double period) { *

Users should override this method for default Robot-wide initialization which will be called * when the robot is first powered on. It will be called exactly one time. * - *

Warning: the Driver Station "Robot Code" light and FMS "Robot Ready" indicators will be off - * until RobotInit() exits. Code in RobotInit() that waits for enable will cause the robot to - * never indicate that the code is ready, causing the robot to be bypassed in a match. + *

Note: This method is functionally identical to the class constructor so that should be used + * instead. */ public void robotInit() {} diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/TimedRobotTest.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/TimedRobotTest.java index 920fb546e8c..da0bd92bdb3 100644 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/TimedRobotTest.java +++ b/wpilibj/src/test/java/edu/wpi/first/wpilibj/TimedRobotTest.java @@ -45,10 +45,7 @@ static class MockRobot extends TimedRobot { MockRobot() { super(kPeriod); - } - @Override - public void robotInit() { m_robotInitCount.addAndGet(1); } diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/addressableled/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/addressableled/Robot.java index 3c5b2f7eb07..16e5321307a 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/addressableled/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/addressableled/Robot.java @@ -15,8 +15,8 @@ import edu.wpi.first.wpilibj.TimedRobot; public class Robot extends TimedRobot { - private AddressableLED m_led; - private AddressableLEDBuffer m_ledBuffer; + private final AddressableLED m_led; + private final AddressableLEDBuffer m_ledBuffer; // Create an LED pattern that will display a rainbow across // all hues at maximum saturation and half brightness @@ -30,8 +30,8 @@ public class Robot extends TimedRobot { private final LEDPattern m_scrollingRainbow = m_rainbow.scrollAtAbsoluteSpeed(MetersPerSecond.of(1), kLedSpacing); - @Override - public void robotInit() { + /** Called once at the beginning of the robot program. */ + public Robot() { // PWM port 9 // Must be a PWM header, not MXP or DIO m_led = new AddressableLED(9); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/apriltagsvision/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/apriltagsvision/Robot.java index 8609cf7e47c..fa827d9afe0 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/apriltagsvision/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/apriltagsvision/Robot.java @@ -30,8 +30,8 @@ *

Be aware that the performance on this is much worse than a coprocessor solution! */ public class Robot extends TimedRobot { - @Override - public void robotInit() { + /** Called once at the beginning of the robot program. */ + public Robot() { var visionThread = new Thread(this::apriltagVisionThreadProc); visionThread.setDaemon(true); visionThread.start(); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/arcadedrive/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/arcadedrive/Robot.java index aa343799a01..43fca7a0bc6 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/arcadedrive/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/arcadedrive/Robot.java @@ -21,13 +21,11 @@ public class Robot extends TimedRobot { new DifferentialDrive(m_leftMotor::set, m_rightMotor::set); private final Joystick m_stick = new Joystick(0); + /** Called once at the beginning of the robot program. */ public Robot() { SendableRegistry.addChild(m_robotDrive, m_leftMotor); SendableRegistry.addChild(m_robotDrive, m_rightMotor); - } - @Override - public void robotInit() { // We need to invert one side of the drivetrain so that positive voltages // result in both sides moving forward. Depending on how your robot's // gearbox is constructed, you might have to invert the left side instead. diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/arcadedrivexboxcontroller/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/arcadedrivexboxcontroller/Robot.java index a376fe0ae48..f4a99c7fb8d 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/arcadedrivexboxcontroller/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/arcadedrivexboxcontroller/Robot.java @@ -21,13 +21,11 @@ public class Robot extends TimedRobot { new DifferentialDrive(m_leftMotor::set, m_rightMotor::set); private final XboxController m_driverController = new XboxController(0); + /** Called once at the beginning of the robot program. */ public Robot() { SendableRegistry.addChild(m_robotDrive, m_leftMotor); SendableRegistry.addChild(m_robotDrive, m_rightMotor); - } - @Override - public void robotInit() { // We need to invert one side of the drivetrain so that positive voltages // result in both sides moving forward. Depending on how your robot's // gearbox is constructed, you might have to invert the left side instead. diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/armbot/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/armbot/Robot.java index c2dc4fcd27c..77edb064a46 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/armbot/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/armbot/Robot.java @@ -17,14 +17,13 @@ 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(); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/armbotoffboard/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/armbotoffboard/Robot.java index 160146c9426..84601c339ed 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/armbotoffboard/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/armbotoffboard/Robot.java @@ -17,14 +17,13 @@ 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(); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/armsimulation/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/armsimulation/Robot.java index 80a11215cd5..761e37b2e14 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/armsimulation/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/armsimulation/Robot.java @@ -13,8 +13,7 @@ public class Robot extends TimedRobot { private final Arm m_arm = new Arm(); private final Joystick m_joystick = new Joystick(Constants.kJoystickPort); - @Override - public void robotInit() {} + public Robot() {} @Override public void simulationPeriodic() { diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/canpdp/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/canpdp/Robot.java index e2b699d2509..796bf0f76e2 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/canpdp/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/canpdp/Robot.java @@ -15,8 +15,7 @@ public class Robot extends TimedRobot { private final PowerDistribution m_pdp = new PowerDistribution(); - @Override - public void robotInit() { + public Robot() { // Put the PDP itself to the dashboard SmartDashboard.putData("PDP", m_pdp); } diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/dma/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/dma/Robot.java index a7b088c735d..fb918ff15e6 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/dma/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/dma/Robot.java @@ -15,22 +15,22 @@ /** This is a sample program showing how to to use DMA to read a sensor. */ public class Robot extends TimedRobot { - private DMA m_dma; - private DMASample m_dmaSample; + private final DMA m_dma; + private final DMASample m_dmaSample; // DMA needs a trigger, can use an output as trigger. // 8 Triggers exist per DMA object, can be triggered on any // DigitalSource. - private DigitalOutput m_dmaTrigger; + private final DigitalOutput m_dmaTrigger; // Analog input to read with DMA - private AnalogInput m_analogInput; + private final AnalogInput m_analogInput; // Encoder to read with DMA - private Encoder m_encoder; + private final Encoder m_encoder; - @Override - public void robotInit() { + /** Called once at the beginning of the robot program. */ + public Robot() { m_dma = new DMA(); m_dmaSample = new DMASample(); m_dmaTrigger = new DigitalOutput(2); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/drivedistanceoffboard/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/drivedistanceoffboard/Robot.java index 4316ad3bdee..7102dac0862 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/drivedistanceoffboard/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/drivedistanceoffboard/Robot.java @@ -17,14 +17,13 @@ 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(); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/dutycycleencoder/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/dutycycleencoder/Robot.java index c3015058281..e352e84076e 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/dutycycleencoder/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/dutycycleencoder/Robot.java @@ -11,12 +11,12 @@ /** This example shows how to use a duty cycle encoder for devices such as an arm or elevator. */ public class Robot extends TimedRobot { - private DutyCycleEncoder m_dutyCycleEncoder; + private final DutyCycleEncoder m_dutyCycleEncoder; private static final double m_fullRange = 1.3; private static final double m_expectedZero = 0; - @Override - public void robotInit() { + /** Called once at the beginning of the robot program. */ + public Robot() { // 2nd parameter is the range of values. This sensor will output between // 0 and the passed in value. // 3rd parameter is the the physical value where you want "0" to be. How diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/dutycycleinput/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/dutycycleinput/Robot.java index c7350b089ba..ca45d031356 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/dutycycleinput/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/dutycycleinput/Robot.java @@ -10,10 +10,9 @@ import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; public class Robot extends TimedRobot { - private DutyCycle m_dutyCycle; + private final DutyCycle m_dutyCycle; - @Override - public void robotInit() { + public Robot() { m_dutyCycle = new DutyCycle(new DigitalInput(0)); } diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorexponentialprofile/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorexponentialprofile/Robot.java index 1bd9c727c43..83958230ec6 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorexponentialprofile/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorexponentialprofile/Robot.java @@ -27,8 +27,7 @@ public class Robot extends TimedRobot { private ExponentialProfile.State m_goal = new ExponentialProfile.State(0, 0); private ExponentialProfile.State m_setpoint = new ExponentialProfile.State(0, 0); - @Override - public void robotInit() { + public Robot() { // Note: These gains are fake, and will have to be tuned for your robot. m_motor.setPID(1.3, 0.0, 0.7); } diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorexponentialsimulation/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorexponentialsimulation/Robot.java index a123414e36a..889fe8e9b32 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorexponentialsimulation/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorexponentialsimulation/Robot.java @@ -17,9 +17,6 @@ public Robot() { super(0.020); } - @Override - public void robotInit() {} - @Override public void robotPeriodic() { // Update the telemetry, including mechanism visualization, regardless of mode. diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorprofiledpid/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorprofiledpid/Robot.java index 670fd7b8ee9..ee37915d67a 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorprofiledpid/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorprofiledpid/Robot.java @@ -36,8 +36,7 @@ public class Robot extends TimedRobot { new ProfiledPIDController(kP, kI, kD, m_constraints, kDt); private final ElevatorFeedforward m_feedforward = new ElevatorFeedforward(kS, kG, kV); - @Override - public void robotInit() { + public Robot() { m_encoder.setDistancePerPulse(1.0 / 360.0 * 2.0 * Math.PI * 1.5); } diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorsimulation/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorsimulation/Robot.java index de39b88a60a..e45ba060918 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorsimulation/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorsimulation/Robot.java @@ -13,8 +13,7 @@ public class Robot extends TimedRobot { private final Joystick m_joystick = new Joystick(Constants.kJoystickPort); private final Elevator m_elevator = new Elevator(); - @Override - public void robotInit() {} + public Robot() {} @Override public void robotPeriodic() { diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatortrapezoidprofile/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatortrapezoidprofile/Robot.java index d451c1377fe..e1ae800421d 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatortrapezoidprofile/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatortrapezoidprofile/Robot.java @@ -27,8 +27,7 @@ public class Robot extends TimedRobot { private TrapezoidProfile.State m_goal = new TrapezoidProfile.State(); private TrapezoidProfile.State m_setpoint = new TrapezoidProfile.State(); - @Override - public void robotInit() { + public Robot() { // Note: These gains are fake, and will have to be tuned for your robot. m_motor.setPID(1.3, 0.0, 0.7); } diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/encoder/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/encoder/Robot.java index 3b715eb8e15..68837135b34 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/encoder/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/encoder/Robot.java @@ -34,8 +34,8 @@ public class Robot extends TimedRobot { */ private final Encoder m_encoder = new Encoder(1, 2, false, CounterBase.EncodingType.k4X); - @Override - public void robotInit() { + /** Called once at the beginning of the robot program. */ + public Robot() { /* * Defines the number of samples to average when determining the rate. * On a quadrature encoder, values range from 1-255; diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/eventloop/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/eventloop/Robot.java index 63efa633519..e75edfe3d19 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/eventloop/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/eventloop/Robot.java @@ -35,8 +35,8 @@ public class Robot extends TimedRobot { private final EventLoop m_loop = new EventLoop(); private final Joystick m_joystick = new Joystick(0); - @Override - public void robotInit() { + /** Called once at the beginning of the robot program. */ + public Robot() { m_controller.setTolerance(TOLERANCE); BooleanEvent isBallAtKicker = diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/flywheelbangbangcontroller/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/flywheelbangbangcontroller/Robot.java index e4732131875..b62c90077af 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/flywheelbangbangcontroller/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/flywheelbangbangcontroller/Robot.java @@ -68,8 +68,7 @@ public class Robot extends TimedRobot { private final FlywheelSim m_flywheelSim = new FlywheelSim(m_plant, m_gearbox); private final EncoderSim m_encoderSim = new EncoderSim(m_encoder); - @Override - public void robotInit() { + public Robot() { // Add bang-bang controler to SmartDashboard and networktables. SmartDashboard.putData(m_bangBangControler); } diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/frisbeebot/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/frisbeebot/Robot.java index a8d2d9888a4..bb8cdc7003c 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/frisbeebot/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/frisbeebot/Robot.java @@ -17,14 +17,13 @@ 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(); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/Robot.java index e9a1ae21209..208a9d4ea91 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/Robot.java @@ -17,14 +17,13 @@ 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(); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gettingstarted/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gettingstarted/Robot.java index 563235c2e1d..5e09be27cc9 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gettingstarted/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gettingstarted/Robot.java @@ -25,17 +25,11 @@ public class Robot extends TimedRobot { private final XboxController m_controller = new XboxController(0); private final Timer m_timer = new Timer(); + /** Called once at the beginning of the robot program. */ public Robot() { SendableRegistry.addChild(m_robotDrive, m_leftDrive); SendableRegistry.addChild(m_robotDrive, m_rightDrive); - } - /** - * This function is run when the robot is first started up and should be used for any - * initialization code. - */ - @Override - public void robotInit() { // We need to invert one side of the drivetrain so that positive voltages // result in both sides moving forward. Depending on how your robot's // gearbox is constructed, you might have to invert the left side instead. diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gyro/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gyro/Robot.java index 7d00c274e57..66a0e6c487c 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gyro/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gyro/Robot.java @@ -36,13 +36,11 @@ public class Robot extends TimedRobot { private final AnalogGyro m_gyro = new AnalogGyro(kGyroPort); private final Joystick m_joystick = new Joystick(kJoystickPort); + /** Called once at the beginning of the robot program. */ public Robot() { SendableRegistry.addChild(m_robotDrive, m_leftDrive); SendableRegistry.addChild(m_robotDrive, m_rightDrive); - } - @Override - public void robotInit() { m_gyro.setSensitivity(kVoltsPerDegreePerSecond); // We need to invert one side of the drivetrain so that positive voltages // result in both sides moving forward. Depending on how your robot's diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gyrodrivecommands/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gyrodrivecommands/Robot.java index bc6ede1b53b..dce5a58ab58 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gyrodrivecommands/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gyrodrivecommands/Robot.java @@ -17,14 +17,13 @@ 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(); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gyromecanum/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gyromecanum/Robot.java index a43523252c4..ff7a2553644 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gyromecanum/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gyromecanum/Robot.java @@ -27,22 +27,17 @@ public class Robot extends TimedRobot { private static final int kGyroPort = 0; private static final int kJoystickPort = 0; - private MecanumDrive m_robotDrive; + private final MecanumDrive m_robotDrive; private final AnalogGyro m_gyro = new AnalogGyro(kGyroPort); private final Joystick m_joystick = new Joystick(kJoystickPort); - @Override - public void robotInit() { + /** Called once at the beginning of the robot program. */ + public Robot() { PWMSparkMax frontLeft = new PWMSparkMax(kFrontLeftChannel); PWMSparkMax rearLeft = new PWMSparkMax(kRearLeftChannel); PWMSparkMax frontRight = new PWMSparkMax(kFrontRightChannel); PWMSparkMax rearRight = new PWMSparkMax(kRearRightChannel); - SendableRegistry.addChild(m_robotDrive, frontLeft); - SendableRegistry.addChild(m_robotDrive, rearLeft); - SendableRegistry.addChild(m_robotDrive, frontRight); - SendableRegistry.addChild(m_robotDrive, rearRight); - // Invert the right side motors. // You may need to change or remove this to match your robot. frontRight.setInverted(true); @@ -51,6 +46,11 @@ public void robotInit() { m_robotDrive = new MecanumDrive(frontLeft::set, rearLeft::set, frontRight::set, rearRight::set); m_gyro.setSensitivity(kVoltsPerDegreePerSecond); + + SendableRegistry.addChild(m_robotDrive, frontLeft); + SendableRegistry.addChild(m_robotDrive, rearLeft); + SendableRegistry.addChild(m_robotDrive, frontRight); + SendableRegistry.addChild(m_robotDrive, rearRight); } /** Mecanum drive is used with the gyro angle as an input. */ diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/hatchbotinlined/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/hatchbotinlined/Robot.java index 4fb6d1b9228..e93c66c119b 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/hatchbotinlined/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/hatchbotinlined/Robot.java @@ -19,14 +19,13 @@ 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(); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/hatchbottraditional/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/hatchbottraditional/Robot.java index 09617df5a5c..f16db21359d 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/hatchbottraditional/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/hatchbottraditional/Robot.java @@ -19,14 +19,13 @@ 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(); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/httpcamera/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/httpcamera/Robot.java index dd4bcda3268..0657499dd4f 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/httpcamera/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/httpcamera/Robot.java @@ -22,8 +22,8 @@ public class Robot extends TimedRobot { Thread m_visionThread; - @Override - public void robotInit() { + /** Called once at the beginning of the robot program. */ + public Robot() { m_visionThread = new Thread( () -> { diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/intermediatevision/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/intermediatevision/Robot.java index e6e8b65ccdd..f50c8a33e45 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/intermediatevision/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/intermediatevision/Robot.java @@ -22,8 +22,8 @@ public class Robot extends TimedRobot { Thread m_visionThread; - @Override - public void robotInit() { + /** Called once at the beginning of the robot program. */ + public Robot() { m_visionThread = new Thread( () -> { diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/mecanumcontrollercommand/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/mecanumcontrollercommand/Robot.java index 527fe3125c5..abc8e1f03d0 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/mecanumcontrollercommand/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/mecanumcontrollercommand/Robot.java @@ -17,14 +17,13 @@ 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(); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/mecanumdrive/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/mecanumdrive/Robot.java index 77aa0cedb71..871ce1e2bc8 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/mecanumdrive/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/mecanumdrive/Robot.java @@ -19,21 +19,16 @@ public class Robot extends TimedRobot { private static final int kJoystickChannel = 0; - private MecanumDrive m_robotDrive; - private Joystick m_stick; + private final MecanumDrive m_robotDrive; + private final Joystick m_stick; - @Override - public void robotInit() { + /** Called once at the beginning of the robot program. */ + public Robot() { PWMSparkMax frontLeft = new PWMSparkMax(kFrontLeftChannel); PWMSparkMax rearLeft = new PWMSparkMax(kRearLeftChannel); PWMSparkMax frontRight = new PWMSparkMax(kFrontRightChannel); PWMSparkMax rearRight = new PWMSparkMax(kRearRightChannel); - SendableRegistry.addChild(m_robotDrive, frontLeft); - SendableRegistry.addChild(m_robotDrive, rearLeft); - SendableRegistry.addChild(m_robotDrive, frontRight); - SendableRegistry.addChild(m_robotDrive, rearRight); - // Invert the right side motors. // You may need to change or remove this to match your robot. frontRight.setInverted(true); @@ -42,6 +37,11 @@ public void robotInit() { m_robotDrive = new MecanumDrive(frontLeft::set, rearLeft::set, frontRight::set, rearRight::set); m_stick = new Joystick(kJoystickChannel); + + SendableRegistry.addChild(m_robotDrive, frontLeft); + SendableRegistry.addChild(m_robotDrive, rearLeft); + SendableRegistry.addChild(m_robotDrive, frontRight); + SendableRegistry.addChild(m_robotDrive, rearRight); } @Override diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/mechanism2d/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/mechanism2d/Robot.java index 264b8ad9fec..034db298c69 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/mechanism2d/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/mechanism2d/Robot.java @@ -33,11 +33,11 @@ public class Robot extends TimedRobot { private final Encoder m_elevatorEncoder = new Encoder(0, 1); private final Joystick m_joystick = new Joystick(0); - private MechanismLigament2d m_elevator; - private MechanismLigament2d m_wrist; + private final MechanismLigament2d m_elevator; + private final MechanismLigament2d m_wrist; - @Override - public void robotInit() { + /** Called once at the beginning of the robot program. */ + public Robot() { m_elevatorEncoder.setDistancePerPulse(kMetersPerPulse); // the main mechanism object diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/motorcontrol/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/motorcontrol/Robot.java index cbb4babbdf0..db79f6d5c7d 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/motorcontrol/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/motorcontrol/Robot.java @@ -26,12 +26,12 @@ public class Robot extends TimedRobot { private static final int kEncoderPortA = 0; private static final int kEncoderPortB = 1; - private PWMSparkMax m_motor; - private Joystick m_joystick; - private Encoder m_encoder; + private final PWMSparkMax m_motor; + private final Joystick m_joystick; + private final Encoder m_encoder; - @Override - public void robotInit() { + /** Called once at the beginning of the robot program. */ + public Robot() { m_motor = new PWMSparkMax(kMotorPort); m_joystick = new Joystick(kJoystickPort); m_encoder = new Encoder(kEncoderPortA, kEncoderPortB); @@ -49,6 +49,7 @@ public void robotPeriodic() { SmartDashboard.putNumber("Encoder", m_encoder.getDistance()); } + /** The teleop periodic function is called every control packet in teleop. */ @Override public void teleopPeriodic() { m_motor.set(m_joystick.getY()); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/quickvision/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/quickvision/Robot.java index a025c5616e7..982e88bc5f7 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/quickvision/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/quickvision/Robot.java @@ -10,11 +10,10 @@ /** * Uses the CameraServer class to automatically capture video from a USB webcam and send it to the * FRC dashboard without doing any vision processing. This is the easiest way to get camera images - * to the dashboard. Just add this to the robotInit() method in your program. + * to the dashboard. Just add this to the robot class constructor. */ public class Robot extends TimedRobot { - @Override - public void robotInit() { + public Robot() { CameraServer.startAutomaticCapture(); } } diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/rapidreactcommandbot/RapidReactCommandBot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/rapidreactcommandbot/RapidReactCommandBot.java index 4c8ffbcd563..a4273a481ae 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/rapidreactcommandbot/RapidReactCommandBot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/rapidreactcommandbot/RapidReactCommandBot.java @@ -42,7 +42,7 @@ public class RapidReactCommandBot { * Use this method to define bindings between conditions and commands. These are useful for * automating robot behaviors based on button and sensor input. * - *

Should be called during {@link Robot#robotInit()}. + *

Should be called in the robot class constructor. * *

Event binding methods are available on the {@link Trigger} class. */ diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/rapidreactcommandbot/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/rapidreactcommandbot/Robot.java index 049798cad6d..bb0e24e5010 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/rapidreactcommandbot/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/rapidreactcommandbot/Robot.java @@ -27,8 +27,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() { // Configure default commands and condition bindings on robot startup m_robot.configureBindings(); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/romireference/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/romireference/Robot.java index 33e12b2bfae..c00593308b9 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/romireference/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/romireference/Robot.java @@ -16,14 +16,13 @@ */ 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(); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/selectcommand/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/selectcommand/Robot.java index 1a89f2cbb66..7bf5f4ce653 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/selectcommand/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/selectcommand/Robot.java @@ -17,14 +17,13 @@ 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(); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/shuffleboard/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/shuffleboard/Robot.java index 436d72685d4..8825b687444 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/shuffleboard/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/shuffleboard/Robot.java @@ -26,10 +26,10 @@ public class Robot extends TimedRobot { private final PWMSparkMax m_elevatorMotor = new PWMSparkMax(2); private final AnalogPotentiometer m_elevatorPot = new AnalogPotentiometer(0); - private GenericEntry m_maxSpeed; + private final GenericEntry m_maxSpeed; - @Override - public void robotInit() { + /** Called once at the beginning of the robot program. */ + public Robot() { SendableRegistry.addChild(m_tankDrive, m_leftDriveMotor); SendableRegistry.addChild(m_tankDrive, m_rightDriveMotor); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/simpledifferentialdrivesimulation/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/simpledifferentialdrivesimulation/Robot.java index 0227c3bfc4a..85953c63579 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/simpledifferentialdrivesimulation/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/simpledifferentialdrivesimulation/Robot.java @@ -28,10 +28,10 @@ public class Robot extends TimedRobot { private final Drivetrain m_drive = new Drivetrain(); private final LTVUnicycleController m_feedback = new LTVUnicycleController(0.020); private final Timer m_timer = new Timer(); - private Trajectory m_trajectory; + private final Trajectory m_trajectory; - @Override - public void robotInit() { + /** Called once at the beginning of the robot program. */ + public Robot() { m_trajectory = TrajectoryGenerator.generateTrajectory( new Pose2d(2, 2, Rotation2d.kZero), diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/solenoid/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/solenoid/Robot.java index 0b791c5120b..d4346f02bc7 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/solenoid/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/solenoid/Robot.java @@ -44,8 +44,8 @@ public class Robot extends TimedRobot { static final int kDoubleSolenoidReverseButton = 3; static final int kCompressorButton = 4; - @Override - public void robotInit() { + /** Called once at the beginning of the robot program. */ + public Robot() { // Publish elements to shuffleboard. ShuffleboardTab tab = Shuffleboard.getTab("Pneumatics"); tab.add("Single Solenoid", m_solenoid); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespacearm/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespacearm/Robot.java index b0314305170..77251079354 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespacearm/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespacearm/Robot.java @@ -101,8 +101,7 @@ public class Robot extends TimedRobot { // A joystick to read the trigger from. private final Joystick m_joystick = new Joystick(kJoystickPort); - @Override - public void robotInit() { + public Robot() { // We go 2 pi radians in 1 rotation, or 4096 counts. m_encoder.setDistancePerPulse(Math.PI * 2 / 4096.0); } diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceelevator/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceelevator/Robot.java index 0e9c045c9ca..f9bd7bf3603 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceelevator/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceelevator/Robot.java @@ -109,8 +109,7 @@ public class Robot extends TimedRobot { // A joystick to read the trigger from. private final Joystick m_joystick = new Joystick(kJoystickPort); - @Override - public void robotInit() { + public Robot() { // Circumference = pi * d, so distance per click = pi * d / counts m_encoder.setDistancePerPulse(Math.PI * 2 * kDrumRadius / 4096.0); } diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceflywheel/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceflywheel/Robot.java index 94566eac348..73226a6af01 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceflywheel/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceflywheel/Robot.java @@ -81,8 +81,7 @@ public class Robot extends TimedRobot { // A joystick to read the trigger from. private final Joystick m_joystick = new Joystick(kJoystickPort); - @Override - public void robotInit() { + public Robot() { // We go 2 pi radians per 4096 clicks. m_encoder.setDistancePerPulse(2.0 * Math.PI / 4096.0); } diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceflywheelsysid/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceflywheelsysid/Robot.java index 3a073fe9d5e..2a9d8f2afa4 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceflywheelsysid/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceflywheelsysid/Robot.java @@ -76,8 +76,7 @@ public class Robot extends TimedRobot { // A joystick to read the trigger from. private final Joystick m_joystick = new Joystick(kJoystickPort); - @Override - public void robotInit() { + public Robot() { // We go 2 pi radians per 4096 clicks. m_encoder.setDistancePerPulse(2.0 * Math.PI / 4096.0); } diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervecontrollercommand/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervecontrollercommand/Robot.java index ab57b74d995..5dba8272e3d 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervecontrollercommand/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervecontrollercommand/Robot.java @@ -17,14 +17,13 @@ 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(); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/sysid/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/sysid/Robot.java index 0b0f1428913..90e18354ed3 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/sysid/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/sysid/Robot.java @@ -23,8 +23,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() { // Configure default commands and condition bindings on robot startup m_robot.configureBindings(); } diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/sysid/SysIdRoutineBot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/sysid/SysIdRoutineBot.java index 93496fdcc37..7537c0bf937 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/sysid/SysIdRoutineBot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/sysid/SysIdRoutineBot.java @@ -31,7 +31,7 @@ public class SysIdRoutineBot { * Use this method to define bindings between conditions and commands. These are useful for * automating robot behaviors based on button and sensor input. * - *

Should be called during {@link Robot#robotInit()}. + *

Should be called in the robot class constructor. * *

Event binding methods are available on the {@link Trigger} class. */ diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/tankdrive/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/tankdrive/Robot.java index a217f51b559..0e9143df89a 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/tankdrive/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/tankdrive/Robot.java @@ -15,18 +15,15 @@ * the code necessary to operate a robot with tank drive. */ public class Robot extends TimedRobot { - private DifferentialDrive m_robotDrive; - private Joystick m_leftStick; - private Joystick m_rightStick; + private final DifferentialDrive m_robotDrive; + private final Joystick m_leftStick; + private final Joystick m_rightStick; private final PWMSparkMax m_leftMotor = new PWMSparkMax(0); private final PWMSparkMax m_rightMotor = new PWMSparkMax(1); - @Override - public void robotInit() { - SendableRegistry.addChild(m_robotDrive, m_leftMotor); - SendableRegistry.addChild(m_robotDrive, m_rightMotor); - + /** Called once at the beginning of the robot program. */ + public Robot() { // We need to invert one side of the drivetrain so that positive voltages // result in both sides moving forward. Depending on how your robot's // gearbox is constructed, you might have to invert the left side instead. @@ -35,6 +32,9 @@ public void robotInit() { m_robotDrive = new DifferentialDrive(m_leftMotor::set, m_rightMotor::set); m_leftStick = new Joystick(0); m_rightStick = new Joystick(1); + + SendableRegistry.addChild(m_robotDrive, m_leftMotor); + SendableRegistry.addChild(m_robotDrive, m_rightMotor); } @Override diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/tankdrivexboxcontroller/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/tankdrivexboxcontroller/Robot.java index c1a850c5f70..6ed1ae1dfce 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/tankdrivexboxcontroller/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/tankdrivexboxcontroller/Robot.java @@ -21,8 +21,8 @@ public class Robot extends TimedRobot { new DifferentialDrive(m_leftMotor::set, m_rightMotor::set); private final XboxController m_driverController = new XboxController(0); - @Override - public void robotInit() { + /** Called once at the beginning of the robot program. */ + public Robot() { SendableRegistry.addChild(m_robotDrive, m_leftMotor); SendableRegistry.addChild(m_robotDrive, m_rightMotor); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ultrasonic/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ultrasonic/Robot.java index edc81ab7244..602e58abe5b 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ultrasonic/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ultrasonic/Robot.java @@ -17,8 +17,8 @@ public class Robot extends TimedRobot { // Creates a ping-response Ultrasonic object on DIO 1 and 2. Ultrasonic m_rangeFinder = new Ultrasonic(1, 2); - @Override - public void robotInit() { + /** Called once at the beginning of the robot program. */ + public Robot() { // Add the ultrasonic on the "Sensors" tab of the dashboard // Data will update automatically Shuffleboard.getTab("Sensors").add(m_rangeFinder); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/xrpreference/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/xrpreference/Robot.java index daf5d32d193..4b908acdd5f 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/xrpreference/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/xrpreference/Robot.java @@ -17,14 +17,13 @@ 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(); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/commandbased/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/commandbased/Robot.java index 8542096ba22..eb8a49f5194 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/commandbased/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/commandbased/Robot.java @@ -17,14 +17,13 @@ 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(); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/commandbasedskeleton/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/commandbasedskeleton/Robot.java index f682ec87bd5..753f54f3623 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/commandbasedskeleton/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/commandbasedskeleton/Robot.java @@ -11,10 +11,9 @@ 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(); } diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/educational/EducationalRobot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/educational/EducationalRobot.java index bb40caae8d2..29c4022dec9 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/educational/EducationalRobot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/educational/EducationalRobot.java @@ -12,7 +12,7 @@ /** Educational robot base class. */ public class EducationalRobot extends RobotBase { - public void robotInit() {} + public EducationalRobot() {} public void disabled() {} @@ -34,8 +34,6 @@ public void test() { @Override public void startCompetition() { - robotInit(); - DriverStationModeThread modeThread = new DriverStationModeThread(); int event = WPIUtilJNI.createEvent(false, false); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/educational/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/educational/Robot.java index 0643977fedf..c210de06f38 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/educational/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/educational/Robot.java @@ -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 diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/robotbaseskeleton/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/robotbaseskeleton/Robot.java index f08986476ac..bc0d9fea031 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/robotbaseskeleton/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/robotbaseskeleton/Robot.java @@ -15,7 +15,7 @@ * 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 void test() {} @Override public void startCompetition() { - robotInit(); - DriverStationModeThread modeThread = new DriverStationModeThread(); int event = WPIUtilJNI.createEvent(false, false); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/romicommandbased/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/romicommandbased/Robot.java index fd393540d79..f6739e96158 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/romicommandbased/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/romicommandbased/Robot.java @@ -17,14 +17,13 @@ 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(); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/romieducational/EducationalRobot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/romieducational/EducationalRobot.java index 5a84915d300..a9a777e42a4 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/romieducational/EducationalRobot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/romieducational/EducationalRobot.java @@ -12,7 +12,7 @@ /** Educational robot base class. */ public class EducationalRobot extends RobotBase { - public void robotInit() {} + public EducationalRobot() {} public void disabled() {} @@ -34,8 +34,6 @@ public void test() { @Override public void startCompetition() { - robotInit(); - DriverStationModeThread modeThread = new DriverStationModeThread(); int event = WPIUtilJNI.createEvent(false, false); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/romieducational/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/romieducational/Robot.java index be58b7270b5..cbec18dd875 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/romieducational/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/romieducational/Robot.java @@ -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 diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/romitimed/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/romitimed/Robot.java index 571bbc3ff52..0328c06d3bb 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/romitimed/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/romitimed/Robot.java @@ -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); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/timed/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/timed/Robot.java index 92b3075ba6b..d8ddbaed236 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/timed/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/timed/Robot.java @@ -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); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/timedskeleton/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/timedskeleton/Robot.java index 4e0a8fea729..4f1c23b10c5 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/timedskeleton/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/timedskeleton/Robot.java @@ -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() {} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/timeslice/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/timeslice/Robot.java index 661a06b75fb..9646e6aac13 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/timeslice/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/timeslice/Robot.java @@ -38,14 +38,7 @@ public Robot() { // 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); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/timesliceskeleton/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/timesliceskeleton/Robot.java index 37ea2b5c34b..a35eab6102d 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/timesliceskeleton/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/timesliceskeleton/Robot.java @@ -34,13 +34,6 @@ public Robot() { // 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() {} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/xrpcommandbased/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/xrpcommandbased/Robot.java index f7950f559e7..2f8147b7439 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/xrpcommandbased/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/xrpcommandbased/Robot.java @@ -17,14 +17,13 @@ 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(); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/xrpeducational/EducationalRobot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/xrpeducational/EducationalRobot.java index 4b44707d7d3..0a6245c0894 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/xrpeducational/EducationalRobot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/xrpeducational/EducationalRobot.java @@ -12,7 +12,7 @@ /** Educational robot base class. */ public class EducationalRobot extends RobotBase { - public void robotInit() {} + public EducationalRobot() {} public void disabled() {} @@ -34,8 +34,6 @@ public void test() { @Override public void startCompetition() { - robotInit(); - DriverStationModeThread modeThread = new DriverStationModeThread(); int event = WPIUtilJNI.createEvent(false, false); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/xrpeducational/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/xrpeducational/Robot.java index 66c28069523..977756d37c3 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/xrpeducational/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/xrpeducational/Robot.java @@ -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 diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/xrptimed/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/xrptimed/Robot.java index f3b6d57d436..9559f54806d 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/xrptimed/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/xrptimed/Robot.java @@ -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);