Error with joystick range when deploying robot code

When deploying my robot code to our robot, I have an error mentioning the index of Joystick. This is my first time using a flight stick to control a drivetrain, so the code might not be set up correctly. The text below is what shows up in the console as soon as I deploy code, and the code builds successfully but doesn’t work after that. Even after deploying the code, the driverstation says that there is no robot code. I was wondering what I needed to do to fix it.

(I can’t figure out how to upload the entire code to github so I was only able to upload src/main/)

********** Robot program starting **********
NT: server: client CONNECTED: 10.68.94.174 port 55564
Unhandled exception: java.lang.IllegalArgumentException: Joystick index is out of range, should be 0-3
Error at frc.robot.RobotContainer.(RobotContainer.java:44): Unhandled exception: java.lang.IllegalArgumentException: Joystick index is out of range, should be 0-3
at edu.wpi.first.wpilibj.DriverStation.getStickButton(DriverStation.java:434)
at edu.wpi.first.wpilibj.GenericHID.getRawButton(GenericHID.java:91)
at edu.wpi.first.wpilibj2.command.button.JoystickButton.get(JoystickButton.java:36)
The robot program quit unexpectedly. This is usually due to a code error.
The above stacktrace can help determine where the error occurred.
See https://wpilib.org/stacktrace for more information.
The startCompetition() method (or methods called by it) should have handled the exception above.
from: edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:395)

at edu.wpi.first.wpilibj2.command.button.Trigger$2.(Trigger.java:142)
at edu.wpi.first.wpilibj2.command.button.Trigger.whileActiveContinuous(Trigger.java:139)
at edu.wpi.first.wpilibj2.command.button.Trigger.whileActiveContinuous(Trigger.java:170)
at edu.wpi.first.wpilibj2.command.button.Button.whileHeld(Button.java:98)
at frc.robot.RobotContainer.(RobotContainer.java:44)
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.startRobot(RobotBase.java:463)
at frc.robot.Main.main(Main.java:23)
Warning at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:388): The robot program quit unexpectedly. This is usually due to a code error.
The above stacktrace can help determine where the error occurred.
See https://wpilib.org/stacktrace for more information.
Error at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:395): The startCompetition() method (or methods called by it) should have handled the exception above.
NT: server: client CONNECTED: 10.68.94.11 port 50938
[phoenix-diagnostics] Server shutdown cleanly. (dur:10|0)
[phoenix] Library shutdown cleanly
[phoenix-diagnostics] Server shutdown cleanly. (dur:10|0)

A fatal error has been detected by the Java Runtime Environment:

SIGSEGV (0xb) at pc=0xb6e3e3d8, pid=4695, tid=4701

JRE version: OpenJDK Runtime Environment (11.0.12.5) (build 11.0.12.5-frc+0-2022-11.0.12u5-1)

Java VM: OpenJDK Client VM (11.0.12.5-frc+0-2022-11.0.12u5-1, mixed mode, concurrent mark sweep gc, linux-)

[thread 4735 also had an error]

Problematic frame:

C [libc.so.6+0x6c3d8]

No core dump will be written. Core dumps have been disabled. To enable core dumping, try “ulimit -c unlimited” before starting Java again

An error report file with more information is saved as:

/tmp/hs_err_pid4695.log

[thread 4733 also had an error]

This indicates that somewhere you are setting up a JoystickButton with an invalid joystick index. The error message is actually incorrect, the joystick number can be from 0-5, not 0-3, but you are passing a stick number outside that range when creating the button. We’d have to see your RobotContainer source code to help further.

The source is linked above. They’re using a value of 6, which spears to be a test value (sequential numbers in the constants class file)

That’s your issue, your constants defines CONTROLLER as 6.

Can’t be higher than 3.

5, actually (the error message is incorrect)

Do you need indices 0-4 for something else? If not try using the driver station to change the index of your controller and test the new index.

@Peter_Johnson @NewtonCrosby @samar I managed to upload the entire code here:

https://github.com/IcedJavaRobotics/2022-Rapid-React

I changed the values for JOYSTICK and CONTROLLER but I haven’t had a chance to test the new code yet.

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