From 9c65ddb138f59d0720b53154cc39c8521b63314b Mon Sep 17 00:00:00 2001 From: Jonah <47046556+jwbonner@users.noreply.github.com> Date: Sun, 1 Oct 2023 15:24:53 -0400 Subject: [PATCH] Throw runtime error when inheriting from `TimedRobot` Replaces compile-time error (which was not clear during failed builds), but does not affect deprecation warning --- .../src/edu/wpi/first/wpilibj/TimedRobot.java | 14 +++++++++++--- .../edu/wpi/first/wpilibj/TimesliceRobot.java | 17 ++++++++++------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/junction/shims/wpilib/src/edu/wpi/first/wpilibj/TimedRobot.java b/junction/shims/wpilib/src/edu/wpi/first/wpilibj/TimedRobot.java index cee8dac1..4e6193ed 100644 --- a/junction/shims/wpilib/src/edu/wpi/first/wpilibj/TimedRobot.java +++ b/junction/shims/wpilib/src/edu/wpi/first/wpilibj/TimedRobot.java @@ -5,11 +5,13 @@ package edu.wpi.first.wpilibj; /** - * @Deprecated The main robot class should inherit from LoggedRobot instead of - * TimedRobot when using AdvantageKit's WPILib shims. + * @Deprecated The main robot class must inherit from LoggedRobot instead of + * TimedRobot when using AdvantageKit's WPILib shims. For more + * details, check the AdvantageKit installation documentation: + * https://github.com/Mechanical-Advantage/AdvantageKit/blob/main/docs/INSTALLATION.md */ @Deprecated -public final class TimedRobot { +public class TimedRobot extends IterativeRobotBase { static class Callback implements Comparable { public Runnable func; public double period; @@ -37,9 +39,15 @@ public int compareTo(Callback rhs) { public static final double kDefaultPeriod = 0.02; protected TimedRobot() { + this(kDefaultPeriod); } protected TimedRobot(double period) { + super(period); + DriverStation.reportError( + "The main robot class must inherit from LoggedRobot when using AdvantageKit's WPILib shims. For more details, check the AdvantageKit installation documentation: https://github.com/Mechanical-Advantage/AdvantageKit/blob/main/docs/INSTALLATION.md\n\n*** EXITING DUE TO INVALID ADVANTAGEKIT INSTALLATION, SEE ABOVE. ***", + false); + System.exit(1); } public void close() { diff --git a/junction/shims/wpilib/src/edu/wpi/first/wpilibj/TimesliceRobot.java b/junction/shims/wpilib/src/edu/wpi/first/wpilibj/TimesliceRobot.java index 39a7b908..7c456fdc 100644 --- a/junction/shims/wpilib/src/edu/wpi/first/wpilibj/TimesliceRobot.java +++ b/junction/shims/wpilib/src/edu/wpi/first/wpilibj/TimesliceRobot.java @@ -5,14 +5,17 @@ package edu.wpi.first.wpilibj; /** - * @Deprecated The main robot class should inherit from LoggedRobot instead of - * TimesliceRobot when using AdvantageKit's WPILib shims. + * @Deprecated The main robot class must inherit from LoggedRobot instead of + * TimesliceRobot when using AdvantageKit's WPILib shims. For more + * details, check the AdvantageKit installation documentation: + * https://github.com/Mechanical-Advantage/AdvantageKit/blob/main/docs/INSTALLATION.md */ @Deprecated -public final class TimesliceRobot { - public TimesliceRobot(double robotPeriodicAllocation, double controllerPeriod) { - } +public class TimesliceRobot extends TimedRobot { + public TimesliceRobot(double robotPeriodicAllocation, double controllerPeriod) { + super(); + } - public void schedule(Runnable func, double allocation) { - } + public void schedule(Runnable func, double allocation) { + } } \ No newline at end of file