Java Code Help

My team and I are running SparkMaxs on a CAN bus along with a few TalonSRXs. When enabling the code it runs for a few seconds and then shuts down. These errors constantly show up. These include:

  • Watchdog not fed within 0.020000s
  • Loop time of 0.02s overrun
  • Warning at edu.wpi.first.wpilibj.IterativeRobotBase.printLoopOverrunMessage(IterativeRobotBase.java:273): Loop time of 0.02s overrun
  • DifferentialDrive… Output not updated often enough.
  • Error at edu.wpi.first.wpilibj.MotorSafety.check(MotorSafety.java:101): DifferentialDrive… Output not updated often enough.
    *Unhandled exception: java.lang.NullPointerException
  • Robots should not quit, but yours did!
  • Warning at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:274): Robots should not quit, but yours did!
  • The startCompetition() method (or methods called by it) should have handled the exception above.

I am also getting errors that say the Maxs firmware is outdated despite updating them to the current firmware, 1.0.385.

Here is my code. https://github.com/NaomieWyckoff/2019-Code

Tear it apart and teach me more. What is happening that could be causing these problems.

One issue is you aren’t checking the return value of CvSink.grabFrame()… if it returns zero the frame isn’t valid.

Nothing really stood out to me as what’s going wrong, looking at the source of that MotorSafety class the NullPointerException looks like it’s happening on the stopMotors() function. Though, there is a Null pointer check when the class is instantiated so not sure what’s happening there.

Just as a side note:
From the wpilib compressor docs:

Class for operating a compressor connected to a PCM (Pneumatic Control Module). The PCM will automatically run in closed loop mode by default whenever a Solenoid object is created. For most cases, a Compressor object does not need to be instantiated or used in a robot program. This class is only required in cases where the robot program needs a more detailed status of the compressor or to enable/disable closed loop control.

I’m not sure that this PCM really leans into the problem you’re seeing, but it’s something you can tidy up.

Edit to add:
So basically, when you instantiate your DoubleSolenoid your compressor will automatically start up.

You never initialize _gamepad2 that I can see, but try to use it in teleopPeriodic. That should crash instantly though

I initialized the _gamepad2 and it worked! Thank you!

2 posts were split to a new topic: Javascript Help