Ramsete controller error and code crash

Hello. We are a veteran team that is switching from LabVIEW to Java for this season. We’ve had numerous iterations of code in the last couple of weeks, with increasing levels of success. That is encouraging, as we’re making progress in learning the language.

We have attempted to customize the trajectory-following code using the Ramsete Controller WPILib example. (This is not the command-based example, but the Timed Robot example.) We’ve added a Constants class, and customized the drivetrain to make it match our hardware.

However, we’ve run into a hurdle that is giving us trouble. The code builds fine. But, we are receiving errors, and the code crashes on the RoboRio. Specifically, the RioLog shows:

ERROR  1  Unhandled exception: java.lang.NullPointerException  frc.robot.Robot.autonomousPeriodic(Robot.java:119)

this is followed by the messages:

ERROR  1  The startCompetition() method (or methods called by it) should have handled the exception above.  edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:352)

and

Warning at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:350): Robots should not quit, but yours did!

If I am reading the initial error correctly, it is having to do with line 119 in Robot.java, which is:

var refChassisSpeeds = m_ramseteController.calculate(m_drive.getPose(), desiredPose);

I understand the code is crashing, I think I know where, but I do not understand why or how I can begin to fix this. We’ve tried. Any help is appreciated!

You never initialize m_ramseteController. You declare it on line 45, but never assign to it, so it’s still null.

3 Likes

Thank you.

Our team is completely new to Pathweaver, although we’re fairly set on maintaining use of TimedRobot. Is there an equivalent tutorial for Timed Robot like the one in the wpilib documentation?
Thank you!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.