Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null pointer exceptions are thrown when any of drivebase, intake, or launcher subsystems are disabled #90

Open
TAKBS2412 opened this issue Mar 12, 2024 · 2 comments

Comments

@TAKBS2412
Copy link
Contributor

Probably low priority, since (hopefully) we won't have to run in competition with subsystems disabled.

Sample intake disabled stacktrace:

Error at java.base/java.util.Objects.requireNonNull(Objects.java:233): Unhandled exception: java.lang.NullPointerException: Parameter requirement in method addRequirements was null when it should not have been!  Check the stacktrace to find the responsible line of code - usually, it is the first line of user-written code indicated in the stacktrace.  Make sure all objects passed to the method in question were properly initialized - note that this may not be obvious if it is being called under dynamically-changing conditions!  Please do not seek additional technical assistance without doing this first!
        at java.base/java.util.Objects.requireNonNull(Objects.java:233)
        at edu.wpi.first.util.ErrorMessages.requireNonNullParam(ErrorMessages.java:27)
        at edu.wpi.first.wpilibj2.command.Command.addRequirements(Command.java:92)
        at frc.team2412.robot.commands.intake.IntakeStopCommand.<init>(IntakeStopCommand.java:11)
        at frc.team2412.robot.util.AutoLogic.registerCommands(AutoLogic.java:54)
        at frc.team2412.robot.util.AutoLogic.<init>(AutoLogic.java:46)
        at frc.team2412.robot.Robot.robotInit(Robot.java:86)
        at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:107)
        at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:365)
        at edu.wpi.first.wpilibj.RobotBase.lambda$startRobot$0(RobotBase.java:433)
        at java.base/java.lang.Thread.run(Thread.java:833)

Sample launcher disabled stacktrace:

Error at java.base/java.util.Objects.requireNonNull(Objects.java:233): Unhandled exception: java.lang.NullPointerException: Parameter requirement in method addRequirements was null when it should not have been!  Check the stacktrace to find the responsible line of code - usually, it is the first line of user-written code indicated in the stacktrace.  Make sure all objects passed to the method in question were properly initialized - note that this may not be obvious if it is being called under dynamically-changing conditions!  Please do not seek additional technical assistance without doing this first!
        at java.base/java.util.Objects.requireNonNull(Objects.java:233)
        at edu.wpi.first.util.ErrorMessages.requireNonNullParam(ErrorMessages.java:27)
        at edu.wpi.first.wpilibj2.command.Command.addRequirements(Command.java:92)
        at frc.team2412.robot.commands.launcher.FullTargetCommand.<init>(FullTargetCommand.java:43)
        at frc.team2412.robot.util.AutoLogic.registerCommands(AutoLogic.java:59)
        at frc.team2412.robot.util.AutoLogic.<init>(AutoLogic.java:46)
        at frc.team2412.robot.Robot.robotInit(Robot.java:86)
        at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:107)
        at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:365)
        at edu.wpi.first.wpilibj.RobotBase.lambda$startRobot$0(RobotBase.java:433)
        at java.base/java.lang.Thread.run(Thread.java:833)

Sample drivebase disabled stacktrace:

Error at frc.team2412.robot.commands.launcher.FullTargetCommand.<init>(FullTargetCommand.java:41): Unhandled exception: java.lang.NullPointerException: Cannot invoke "frc.team2412.robot.subsystems.DrivebaseSubsystem.rotateToAngle(java.util.function.Supplier, boolean)" because "drivebaseSubsystem" is null
        at frc.team2412.robot.commands.launcher.FullTargetCommand.<init>(FullTargetCommand.java:41)
        at frc.team2412.robot.util.AutoLogic.registerCommands(AutoLogic.java:59)
        at frc.team2412.robot.util.AutoLogic.<init>(AutoLogic.java:46)
        at frc.team2412.robot.Robot.robotInit(Robot.java:86)
        at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:107)
        at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:365)
        at edu.wpi.first.wpilibj.RobotBase.lambda$startRobot$0(RobotBase.java:433)
        at java.base/java.lang.Thread.run(Thread.java:833)
@TAKBS2412
Copy link
Contributor Author

One interesting thing for the future would be adding separate tests with different subsystems enabled/disabled (based off our existing simulation test) to catch errors like this in CI.

@jamesdooley4
Copy link
Member

One big cause of this is the call to AutoLogic.initShuffleBoard that instantiates the static commandsMap variable, which instances a bunch of static List variables and the AutoPath items in those lists. Those all assume there's a drivebase subsystem that's already configured PathPlanner, and crash if that's not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants