Skip to content

Commit

Permalink
Throw runtime error when inheriting from TimedRobot
Browse files Browse the repository at this point in the history
Replaces compile-time error (which was not clear during failed builds), but does not affect deprecation warning
  • Loading branch information
jwbonner committed Oct 1, 2023
1 parent ff1af6b commit 9c65ddb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
14 changes: 11 additions & 3 deletions junction/shims/wpilib/src/edu/wpi/first/wpilibj/TimedRobot.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Callback> {
public Runnable func;
public double period;
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
}
}

0 comments on commit 9c65ddb

Please sign in to comment.