|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
java.lang.NullPointerException
We have been trying to figure out the new CAN Talon libraries given to us this season. After looking through numerous examples, we cannot get around this error:
Code:
ERROR 1 ERROR Unhandled exception: java.lang.NullPointerException at [org.usfirst.frc.team967.robot.subsystems.DriveSubsystem.arcadeDrive(DriveSubsystem.java:27), org.usfirst.frc.team967.robot.commands.TeleOp_ArcadeDrive.execute(TeleOp_ArcadeDrive.java:23), edu.wpi.first.wpilibj.command.Command.run(Command.java:243), edu.wpi.first.wpilibj.command.Scheduler.run(Scheduler.java:206), org.usfirst.frc.team967.robot.Robot.teleopPeriodic(Robot.java:109), edu.wpi.first.wpilibj.IterativeRobot.startCompetition(IterativeRobot.java:130), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.java:247)] edu.wpi.first.wpilibj.RobotBase.main(RobotBase.java:249) Error at edu.wpi.first.wpilibj.RobotBase.main(RobotBase.java:249): ERROR Unhandled exception: java.lang.NullPointerException at [org.usfirst.frc.team967.robot.subsystems.DriveSubsystem.arcadeDrive(DriveSubsystem.java:27), org.usfirst.frc.team967.robot.commands.TeleOp_ArcadeDrive.execute(TeleOp_ArcadeDrive.java:23), edu.wpi.first.wpilibj.command.Command.run(Command.java:243), edu.wpi.first.wpilibj.command.Scheduler.run(Scheduler.java:206), org.usfirst.frc.team967.robot.Robot.teleopPeriodic(Robot.java:109), edu.wpi.first.wpilibj.IterativeRobot.startCompetition(IterativeRobot.java:130), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.java:247)] WARNING: Robots don't quit! ---> The startCompetition() method (or methods called by it) should have handled the exception above. ➔ Launching «'/usr/local/frc/JRE/bin/java' '-Djava.library.path=/usr/local/frc/lib/' '-jar' '/home/lvuser/FRCUserProgram.jar'» ********** Robot program starting ********** NT: server: client CONNECTED: 10.9.67.144 port 56534 Default IterativeRobot.robotPeriodic() method... Overload me! The robot code will build and deploy correctly, and shows no errors. However when you enable the robot, the robot code drops out after a couple seconds and the above error appears. Thanks, Any help is appreciated Team 967 |
|
#2
|
|||
|
|||
|
Re: java.lang.NullPointerException
Looks like you are instantiating your CANTalons in RobotMap.init, but I don't see any calls to that method. You probably want to call that from your Robot class on startup.
I'm don't think RobotMap is really the right place for the CANTalons, but that's a whole different issue unrelated to the error. |
|
#3
|
||||
|
||||
|
Re: java.lang.NullPointerException
Line 27, as of commit d16c532, cannot possibly throw a NullPointerException:
Code:
if((xAxis< deadBand) && (xAxis > -deadBand)){ xAxis=0;}
Edit: Ben's right. You declare the speed controllers in RobotMap, but never call init() so they're always going to be null. Last edited by SamCarlberg : 17-01-2017 at 21:51. |
|
#4
|
|||
|
|||
|
Re: java.lang.NullPointerException
We are very sorry about the code not being up to date on the github, we were messing with the code to get rid of the error. We have updated that now.
As far as the CAN Talons being instantiated in Robot Map, we are calling them in the DriveSubsystem.java file Thanks for the quick responses, hope that helps |
|
#5
|
||||
|
||||
|
Re: java.lang.NullPointerException
The issue is that when your subsystems are initialized, they get their values for all the RobotMap variables before those variables have been initialized. So you can either
What you're basically doing is: Code:
Object a = null; Object b = a; // set b to the _current_ value of a, which is null a = new Object(); ... b.doSomething(); // null pointer exception! Last edited by SamCarlberg : 17-01-2017 at 22:16. |
|
#6
|
|||
|
|||
|
Thank you very much. We were able to figure out our issue. We appreciate the help and the quick responses.
Team 967 |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|