Go to Post Impressive. A harsh reminder of the kind of force that FRC bots exert. - Racer26 [more]
Home
Go Back   Chief Delphi > Other > FIRST Tech Challenge
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 22-11-2016, 23:41
Fedoros Fedoros is offline
Registered User
FTC #7232
 
Join Date: Nov 2015
Location: Minnesota, United States
Posts: 3
Fedoros is an unknown quantity at this point
[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
Reply With Quote
  #2   Spotlight this post!  
Unread 23-11-2016, 12:00
Christopher149 Christopher149 is offline
Registered User
FRC #0857 (Superior Roboworks) FTC 10723 (SnowBots)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2007
Location: Houghton, MI
Posts: 1,098
Christopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond repute
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.
__________________
2015-present: FTC 10723 mentor
2012-present: 857 mentor
2008-2011: 857 student

2015: Industrial Design, Excellence in Engineering, District Finalist, Archimedes Division (#6 alliance captain)
2014: Judges Award, District Engineering Inspiration, District Finalist, Galileo Division

Reply With Quote
  #3   Spotlight this post!  
Unread 26-11-2016, 14:43
godkane godkane is offline
Registered User
FRC #3875
 
Join Date: Jan 2014
Location: Grand Rapids, MI
Posts: 11
godkane is an unknown quantity at this point
Re: [FTC]: Android Studio NullPointerException on TeleOp Init

Line 49 is weird without a function declaration.
Reply With Quote
  #4   Spotlight this post!  
Unread 30-11-2016, 12:47
JohnMMcD JohnMMcD is offline
Registered User
AKA: John McDonnell
FTC #5873 (Dragon Terminators)
Team Role: Mentor
 
Join Date: Jul 2015
Rookie Year: 2010
Location: CT
Posts: 13
JohnMMcD is an unknown quantity at this point
Re: [FTC]: Android Studio NullPointerException on TeleOp Init

Quote:
Originally Posted by Fedoros View Post
From what I've gathered, there are many, many different problems which could give this error.
In my experience, the NullPointerException is almost always caused by invoking an object's methods before initializing the object via the hardware map. The object might be a motor, servo, sensor, etc. -- anything that gets initialized via hardwareMap.get().

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.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 16:56.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi