|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
[FTC]: Android Studio NullPointerException on TeleOp Init
Recently the build team has finished setting up all of the electronics on our robot so now it's time to test code, aaaaaaand NullPointerException. From what I've gathered, there are many, many different problems which could give this error. Other programs (autonomous and a sensor test) run fine, but whenever I press "Init" on the phone, the app throws the error. I've tried commenting out just about everything I think could be causing the problem, but it still appears. It's likely something wrong in our hardware file because the robot doesn't do much else on initialization, but I can't tell for sure. Thanks in advance to anyone who looks at this code.
Teleop: http://pastebin.com/YpYwXARb RobotHardware: http://pastebin.com/bVq1kHKr |
|
#2
|
|||
|
|||
|
Re: [FTC]: Android Studio NullPointerException on TeleOp Init
Looking at what you posted, you have big chunk of code between start() and loop() that isn't actually in a function (it should all be in loop()). As such, I am curious how your code is compiling as of now. But if you get it into loop(), it should be mostly fine.
A second, smaller issue, is that you never assign a value to buttonPushDelta, but I think Java defaults it to zero. |
|
#3
|
|||
|
|||
|
Re: [FTC]: Android Studio NullPointerException on TeleOp Init
Line 49 is weird without a function declaration.
|
|
#4
|
|||
|
|||
|
Re: [FTC]: Android Studio NullPointerException on TeleOp Init
Quote:
I think that's your problem here, too. The code that's not in a method (lines 49-131) is running as soon at the op mode is instantiated, which is BEFORE the opmode's "init" method is invoked. Since the "init" method initializes the robot via the hardware map, any command such as "robot.driveRight.setPower(right);" will throw a NPE. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|