![]() |
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) 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 |
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. |
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. |
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 |
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; |
Re: java.lang.NullPointerException
Thank you very much. We were able to figure out our issue. We appreciate the help and the quick responses.
Team 967 |
| All times are GMT -5. The time now is 21:48. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi