Dual Errors (Github Repositories)

Hello again, and first I wanted to thank the community here for being so helpful on my first post. In my second again I’m met with errors that I have no clue how to remedy. Attached is my code and a stack trace (? I still am very fuzzy about stack traces so this may be the wrong thing), regarding my first error.

Error at java.base/java.util.Objects.requireNonNull(Objects.java:246): Unhandled exception: java.lang.NullPointerException: Parameter joystick in method JoystickButton 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:246)
at edu.wpi.first.wpilibj.util.ErrorMessages.requireNonNullParam(ErrorMessages.java:27)
at edu.wpi.first.wpilibj2.command.button.JoystickButton.(JoystickButton.java:27)
at frc.robot.RobotContainer.configureButtonBindings(RobotContainer.java:60)
at frc.robot.RobotContainer.(RobotContainer.java:39)
at frc.robot.Robot.robotInit(Robot.java:30)
at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:107)
at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:373)
at edu.wpi.first.wpilibj.RobotBase.lambda$startRobot$0(RobotBase.java:443)
at java.base/java.lang.Thread.run(Thread.java:829)

Warning at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:388): The robot program quit unexpectedly. This is usually due to a code error.

Here is my Github: https://github.com/W-Sweet/In_The_End/tree/master/src/main/java/frc/robot

Secondly, I’ve been trying to get my code to work on multiple computer using github repositories, but I keep getting this error:

The terminal process failed to launch: Invalid starting directory “\W-Sweet\RepositoryName”, review your terminal.integrated.cwd setting.

I know this has something to do with the fact that the code doesn’t exist on the computer and that it’s not created as a FRC project, but I’m confused about how to fix it. The only solution I got now, is that I create a new frc project and copy all of my code every time.

Regardless, thank you everyone, and feel free to ask me any questions. Sorry if these may be simple answers.

In RobotContainer, line 60, you’re instantiating a JoystickButton object by passing in a Joystick object that’s null (not yet instantiated) because you call configureButtonBindings before creating the Joystick (XboxController) object

Your issue is that you instantiate your driverJoystick (RobotContainer: line 41 and 46) after you attempt to use it in the method configureButtonBindings() on line 39.

How I Found the Error
I noticed that the java.lang.NullPointerException and realized you probably were forgetting it instantiate it before you were using it. I then look for the line of code that was erroring, which appeared to be

at frc.robot.RobotContainer.configureButtonBindings(RobotContainer.java:60)

according to your error message. I saw that it was failing to use the driverJoystick, so I backtracked to where it was being called.

Additional Comments
You have a lot of duplication in your RobotContainer. I would definitely look through it and remove things that don’t need to appear twice.

1 Like

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