Go to Post You can't derail a thread that had no "rails" to begin with. - bkahl [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Spotlight this post!  
Unread 16-02-2013, 22:49
arithehun arithehun is offline
Registered User
AKA: Ari Falkner
FRC #3024
Team Role: Programmer
 
Join Date: Feb 2011
Rookie Year: 2011
Location: Ashland, Oregon
Posts: 27
arithehun is an unknown quantity at this point
Re: CANNotInitializedException

Also, you cannot define a jaguar inside of a code block (in this case, your "try" block, and then use it anywhere outside of the block. Outside of any method, but inside your class, type (you may have already done this):

Code:
CANJaguar armMotor;
Then, change your code that you displayed to this:
(Basically remove the CANJaguar variable marker):

Code:
public void robotInit(){
     try {
          armMotor = new CANJaguar (4,       CANJaguar.ControlMode.kPosition);
     } catch (CANTimeoutException ex){
          ex.printStackTrace();
}
Essentially, what is happening is that you're not initializing your global CANJaguar variable. How Java works is that it allows global and local variables of the same name. So the Jaguar that you're initializing isn't the same one that you're using at line 70. You made a new Jaguar also called "armMotor" and initialized that one. Because it had a conflicting name, Java resolved this by "hiding" the global variable from that function. The armMotor inside robotInit() was discarded after robotInit ended. The other armMotor that you defined elsewhere was never touched. By removing the CANJaguar reference, you're not creating a new variable anymore but instead initializing the existing global one, which is what you intended on doing.
Reply With Quote
 


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 11:09.

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