Hello, we are getting an error in driverstation as well as WPILIB. when I programmed the joystick button number there were no errors then when I tried to use it in driver station my entire code crashed from hitting the one button. The error is Warning at edu.wpi.first.wpilibj.DriverStation.reportJoystickUnpluggedWarning(DriverStation.java:1246): Joystick Button 1 on port 0 not available, check if controller is plugged in . it is plugged in but is not working. Any help would be greatly appreciated
If you go to the USB tab do you see the controller on port 0?
Yup, it’s the joystick in port 0. When I go to click the shooter button I programmed it bombs the robot code for a few seconds until it reboots and this will keep happening if I press the trigger button on the joystick.
Is there more error info being output? I’ve gotten that controller warning before (when testing out our code with only 1 controller in since we normally use 2) and the code doesn’t crash, there may be something else going on.
Here was the total error log when I deployed the code…
-
T: server: client CONNECTED: 10.84.22.219 port 55605
-
Joystick Button 1 on port 0 not available, check if controller is plugged in
-
Warning at edu.wpi.first.wpilibj.DriverStation.reportJoystickUnpluggedWarning(DriverStation.java:1246): Joystick Button 1 on port 0 not available, check if controller is plugged in
-
Joystick Button 1 on port 0 not available, check if controller is plugged in
-
Warning at edu.wpi.first.wpilibj.DriverStation.reportJoystickUnpluggedWarning(DriverStation.java:1246): Joystick Button 1 on port 0 not available, check if controller is plugged in
-
NT: server: client CONNECTED: 10.84.22.219 port 55654
-
NT: server: client CONNECTED: 10.84.22.219 port 55672
-
Info roboRIO: Game data update “” received by Robot
-
Info roboRIO: Game data update “8422” received by Robot
-
DifferentialDrive… Output not updated often enough.
-
Error at edu.wpi.first.wpilibj.MotorSafety.check(MotorSafety.java:96): DifferentialDrive… Output not updated often enough.
-
CTR: Firm Vers could not be retrieved. Use Phoenix Tuner to check ID and firmware(CRF) version.
-
Unhandled exception: java.lang.NullPointerException
from: java.base/java.util.Collections.disjoint(Unknown Source)
at: at java.base/java.util.Collections.disjoint(Unknown Source)
at: at edu.wpi.first.wpilibj2.command.CommandScheduler.schedule(CommandScheduler.java:183)
at: at edu.wpi.first.wpilibj2.command.CommandScheduler.schedule(CommandScheduler.java:214)
at: at edu.wpi.first.wpilibj2.command.Command.schedule(Command.java:242)
at: at edu.wpi.first.wpilibj2.command.button.Trigger$2.run(Trigger.java:132)
at: at edu.wpi.first.wpilibj2.command.CommandScheduler.run(CommandScheduler.java:260)
at: at frc.robot.Robot.robotPeriodic(Robot.java:55)
at: at edu.wpi.first.wpilibj.IterativeRobotBase.loopFunc(IterativeRobotBase.java:270)
at: at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:117)
at: at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:335)
at: at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:407)
at: at frc.robot.Main.main(Main.java:23)
-
Error at java.base/java.util.Collections.disjoint(Unknown Source): Unhandled exception: java.lang.NullPointerException
-
at java.base/java.util.Collections.disjoint(Unknown Source)
-
at edu.wpi.first.wpilibj2.command.CommandScheduler.schedule(CommandScheduler.java:183)
-
at edu.wpi.first.wpilibj2.command.CommandScheduler.schedule(CommandScheduler.java:214)
-
at edu.wpi.first.wpilibj2.command.Command.schedule(Command.java:242)
-
at edu.wpi.first.wpilibj2.command.button.Trigger$2.run(Trigger.java:132)
-
at edu.wpi.first.wpilibj2.command.CommandScheduler.run(CommandScheduler.java:260)
-
at frc.robot.Robot.robotPeriodic(Robot.java:55)
-
at edu.wpi.first.wpilibj.IterativeRobotBase.loopFunc(IterativeRobotBase.java:270)
-
at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:117)
-
at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:335)
-
at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:407)
-
at frc.robot.Main.main(Main.java:23)
-
Robots should not quit, but yours did!
-
Warning at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:350): Robots should not quit, but yours did!
-
The startCompetition() method (or methods called by it) should have handled the exception above.
-
Error at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:352): The startCompetition() method (or methods called by it) should have handled the exception above.
-
Loop time of 0.02s overrun
-
Warning at edu.wpi.first.wpilibj.IterativeRobotBase.printLoopOverrunMessage(IterativeRobotBase.java:301): Loop time of 0.02s overrun
-
[phoenix] Library shutdown cleanly
-
[phoenix-diagnostics] Server shutdown cleanly. (dur:302|0)
-
********** Robot program starting **********
-
NT: server: client CONNECTED: 10.84.22.219 port 55703
-
NT: server: client CONNECTED: 10.84.22.219 port 55707
-
Loop time of 0.02s overrun
-
Warning at edu.wpi.first.wpilibj.IterativeRobotBase.printLoopOverrunMessage(IterativeRobotBase.java:301): Loop time of 0.02s overrun
-
SmartDashboard.updateValues(): 0.009267s
disabledInit(): 0.000993s
disablePeriodic(): 0.001108s
robotPeriodic(): 0.028995s
LiveWindow.updateValues(): 0.215514s
Shuffleboard.update(): 0.000321s -
Warning at edu.wpi.first.wpilibj.Tracer.lambda$printEpochs$0(Tracer.java:63): SmartDashboard.updateValues(): 0.009267s
-
disabledInit(): 0.000993s
-
disablePeriodic(): 0.001108s
-
robotPeriodic(): 0.028995s
-
LiveWindow.updateValues(): 0.215514s
-
Shuffleboard.update(): 0.000321s
-
Loop time of 0.02s overrun
-
Warning at edu.wpi.first.wpilibj.IterativeRobotBase.printLoopOverrunMessage(IterativeRobotBase.java:301): Loop time of 0.02s overrun
-
SmartDashboard.updateValues(): 0.000091s
disablePeriodic(): 0.000211s
robotPeriodic(): 0.026926s
LiveWindow.updateValues(): 0.000716s
Shuffleboard.update(): 0.000052s -
Warning at edu.wpi.first.wpilibj.Tracer.lambda$printEpochs$0(Tracer.java:63): SmartDashboard.updateValues(): 0.000091s
-
disablePeriodic(): 0.000211s
-
robotPeriodic(): 0.026926s
-
LiveWindow.updateValues(): 0.000716s
-
Shuffleboard.update(): 0.000052s
-
[phoenix] Library initialization is complete.
-
[phoenix-diagnostics] Server 1.8.6 (Jan 8 2021,20:09:49) running on port: 1250
-
Unhandled exception: java.lang.NullPointerException
-
Error at java.base/java.util.Collections.disjoint(Unknown Source): Unhandled exception: java.lang.NullPointerException
-
at java.base/java.util.Collections.disjoint(Unknown Source)
-
at edu.wpi.first.wpilibj2.command.CommandScheduler.schedule(CommandScheduler.java:183)
-
at edu.wpi.first.wpilibj2.command.CommandScheduler.schedule(CommandScheduler.java:214)
-
at edu.wpi.first.wpilibj2.command.Command.schedule(Command.java:242)
-
at edu.wpi.first.wpilibj2.command.button.Trigger$2.run(Trigger.java:132)
-
at edu.wpi.first.wpilibj2.command.CommandScheduler.run(CommandScheduler.java:260)
-
at frc.robot.Robot.robotPeriodic(Robot.java:55)
-
at edu.wpi.first.wpilibj.IterativeRobotBase.loopFunc(IterativeRobotBase.java:270)
-
at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:117)
-
at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:335)
-
at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:407)
-
at frc.robot.Main.main(Main.java:23)
-
Robots should not quit, but yours did!
-
Warning at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:350): Robots should not quit, but yours did!
-
The startCompetition() method (or methods called by it) should have handled the exception above.
-
Error at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:352): The startCompetition() method (or methods called by it) should have handled the exception above.
-
Loop time of 0.02s overrun
-
Warning at edu.wpi.first.wpilibj.IterativeRobotBase.printLoopOverrunMessage(IterativeRobotBase.java:301): Loop time of 0.02s overrun
-
[phoenix] Library shutdown cleanly
-
[phoenix-diagnostics] Server shutdown cleanly. (dur:161|0)
-
********** Robot program starting **********
-
NT: server: client CONNECTED: 10.84.22.219 port 55766
-
NT: server: client CONNECTED: 10.84.22.219 port 55770
-
Loop time of 0.02s overrun
-
Warning at edu.wpi.first.wpilibj.IterativeRobotBase.printLoopOverrunMessage(IterativeRobotBase.java:301): Loop time of 0.02s overrun
-
SmartDashboard.updateValues(): 0.009259s
disabledInit(): 0.000998s
disablePeriodic(): 0.000974s
robotPeriodic(): 0.028587s
LiveWindow.updateValues(): 0.156959s
Shuffleboard.update(): 0.000340s -
Warning at edu.wpi.first.wpilibj.Tracer.lambda$printEpochs$0(Tracer.java:63): SmartDashboard.updateValues(): 0.009259s
-
disabledInit(): 0.000998s
-
disablePeriodic(): 0.000974s
-
robotPeriodic(): 0.028587s
-
LiveWindow.updateValues(): 0.156959s
-
Shuffleboard.update(): 0.000340s
-
[phoenix] Library initialization is complete.
-
[phoenix-diagnostics] Server 1.8.6 (Jan 8 2021,20:09:49) running on port: 1250
-
DifferentialDrive… Output not updated often enough.
-
Error at edu.wpi.first.wpilibj.MotorSafety.check(MotorSafety.java:96): DifferentialDrive… Output not updated often enough.
-
Loop time of 0.02s overrun
-
Warning at edu.wpi.first.wpilibj.IterativeRobotBase.printLoopOverrunMessage(IterativeRobotBase.java:301): Loop time of 0.02s overrun
-
CommandScheduler loop overrun
-
buttons.run(): 0.000023s
Shooter.periodic(): 0.000013s
DriveBase.periodic(): 0.000057s
DriveWithJoystick.execute(): 0.043094s -
Warning at edu.wpi.first.wpilibj.Tracer.lambda$printEpochs$0(Tracer.java:63): buttons.run(): 0.000023s
-
Shooter.periodic(): 0.000013s
-
DriveBase.periodic(): 0.000057s
-
DriveWithJoystick.execute(): 0.043094s
-
teleopPeriodic(): 0.000340s
SmartDashboard.updateValues(): 0.000113s
robotPeriodic(): 0.062045s
LiveWindow.updateValues(): 0.000706s
Shuffleboard.update(): 0.000024s -
Warning at edu.wpi.first.wpilibj.Tracer.lambda$printEpochs$0(Tracer.java:63): teleopPeriodic(): 0.000340s
-
SmartDashboard.updateValues(): 0.000113s
-
robotPeriodic(): 0.062045s
-
LiveWindow.updateValues(): 0.000706s
-
Shuffleboard.update(): 0.000024s
While you are getting your Joystick warning, which is a bit odd, it does appear to just be a warning, and not what’s killing your robot, or at least not directly. Slightly lower down is Unhandled exception: java.lang.NullPointerException
. Which likely means you are not initializing some object before using it. Based on your symptom, its probably in, or related to, whatever command your button triggers.
Could you share your entire code. Preferably as a GitHub Repository.
How did you test your code so that you knew your ‘joystick button number’ were correct before? Is this the same joystick you were using on your DS as before? Also, looking at the USB tab on the controller, (test your controller here to make sure all are working) try to click on the button that you wanted to use and see which button the DS sees it as. Unless you’re using an ‘xbox controller’, many controllers might not be mapping the same buttons to the same place and you might have to just change your button number.
I tested on driver station when I pressed the trigger on the joystick and it lit up as button number 1, it is also numbered as button number 1 on the joystick itself.
Ok, so I think your issue may be your trying to cast your ShootBall
object to a Command
, https://github.com/pillagerhuskyhowlers/2021-Practice-code-2.0/blob/03b8626a2a0de1f0367d4780bd4fd88eed67a9b3/RobotContainer.java#L66. I am not a Java Developer so I am not super familiar with how Casting/Converting of Object Types works in Java, but its possible this is like technically working as far as compiling, but when it actually runs, the new “faux-Command” object is missing all the back-end plumbing a Command normally has and thus is blowing up when you actually try to schedule it.
I assume you created your ShootBall Class manually, but there is an “automated” way to add new Commands and Subsystems with all the proper default boilerplate/templating built into the VS Code Plugin by right-clicking the package you want the new Command or Subsystem in and selecting Create a new class/command and following the prompts at the top to select type of class Command (new)
most likely in your case, and then Give it a name ie. ShootBall
. That will handle making sure your new Command is setup with all the methods and type inheritance it needs without worrying about it much yourself.
I recommend reading over the Command-Based section of the WPILib Documentation for how Commands and the Command Scheduler are meant to operate and be structured.
I actually created the command the way you suggested and listed but still to no luck
Could you put your updated code in your github repo so I can track it and see what changes you made?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.