Go to Post P.S. I'm not boring! - Matt Krass [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

 
Reply
Thread Tools Rating: Thread Rating: 4 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 01-18-2012, 10:10 AM
twiggzee twiggzee is offline
Registered User
FRC #3502 (Octo-(PI)-Rates)
Team Role: Mentor
 
Join Date: Mar 2011
Rookie Year: 2011
Location: Tallahassee, FL
Posts: 55
twiggzee is an unknown quantity at this point
Unresponsive Code... Help Please?

Hello,

This year we've switched to Java. We decided to go nuts and try out the new command based template. I depoloyed our first crack at drive code onto last year's robot with cRio has been re-imaged to the latest. The driver station indicates it has code but the joysticks are unresponsive. Can someone take a look to see if there are any obvious problems?

Here is a link to our Google code repository
http://code.google.com/p/2012-first-...iloctopirates/

The last few lines in Netbeans output window show this:
[cRIO] Default IterativeRobot.disabledInit() method... Overload me!
[cRIO] Default IterativeRobot.disabledContinuous() method... Overload me!
[cRIO] Default IterativeRobot.disabledPeriodic() method... Overload me!
[cRIO] java.lang.NullPointerException
[cRIO] at edu.wpi.first.wpilibj.templates.pleasework.teleopI nit(pleasework.java:55)
[cRIO] at edu.wpi.first.wpilibj.IterativeRobot.startCompetit ion(IterativeRobot.java:137)
[cRIO] at edu.wpi.first.wpilibj.RobotBase.startApp(RobotBase .java:156)
[cRIO] in virtual method #10 of javax.microedition.midlet.MIDlet(bci=17)
[cRIO] at javax.microedition.midlet.MIDletTunnelImpl.callSta rtApp(64)
[cRIO] at com.sun.squawk.imp.MIDletMainWrapper.main(110)
[cRIO] in virtual method #95 of com.sun.squawk.Klass(bci=25)
[cRIO] at com.sun.squawk.Isolate.run(1506)
[cRIO] at java.lang.Thread.run(231)
[cRIO] in virtual method #47 of com.sun.squawk.VMThread(bci=42)
[cRIO] in static method #3 of com.sun.squawk.VM(bci=6)
[cRIO] WARNING: Robots don't quit!
[cRIO] ---> The startCompetition() method (or methods called by it) should have handled the exception above.
__________________
Wendy
Team 3502
Reply With Quote
  #2   Spotlight this post!  
Unread 01-18-2012, 10:16 AM
davidthefat davidthefat is offline
Alumni
AKA: David Yoon
FRC #0589 (Falkons)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2010
Location: California
Posts: 792
davidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud of
Re: Unresponsive Code... Help Please?

Quote:
Originally Posted by twiggzee View Post
Hello,

This year we've switched to Java. We decided to go nuts and try out the new command based template. I depoloyed our first crack at drive code onto last year's robot with cRio has been re-imaged to the latest. The driver station indicates it has code but the joysticks are unresponsive. Can someone take a look to see if there are any obvious problems?

Here is a link to our Google code repository
http://code.google.com/p/2012-first-...iloctopirates/

The last few lines in Netbeans output window show this:
[cRIO] Default IterativeRobot.disabledInit() method... Overload me!
[cRIO] Default IterativeRobot.disabledContinuous() method... Overload me!
[cRIO] Default IterativeRobot.disabledPeriodic() method... Overload me!
[cRIO] java.lang.NullPointerException
[cRIO] at edu.wpi.first.wpilibj.templates.pleasework.teleopI nit(pleasework.java:55)
[cRIO] at edu.wpi.first.wpilibj.IterativeRobot.startCompetit ion(IterativeRobot.java:137)
[cRIO] at edu.wpi.first.wpilibj.RobotBase.startApp(RobotBase .java:156)
[cRIO] in virtual method #10 of javax.microedition.midlet.MIDlet(bci=17)
[cRIO] at javax.microedition.midlet.MIDletTunnelImpl.callSta rtApp(64)
[cRIO] at com.sun.squawk.imp.MIDletMainWrapper.main(110)
[cRIO] in virtual method #95 of com.sun.squawk.Klass(bci=25)
[cRIO] at com.sun.squawk.Isolate.run(1506)
[cRIO] at java.lang.Thread.run(231)
[cRIO] in virtual method #47 of com.sun.squawk.VMThread(bci=42)
[cRIO] in static method #3 of com.sun.squawk.VM(bci=6)
[cRIO] WARNING: Robots don't quit!
[cRIO] ---> The startCompetition() method (or methods called by it) should have handled the exception above.
You never constructed the "Sweeper" object.
__________________
Do not say what can or cannot be done, but, instead, say what must be done for the task at hand must be accomplished.
Reply With Quote
  #3   Spotlight this post!  
Unread 01-18-2012, 02:08 PM
theprgramerdude theprgramerdude is offline
WPI Freshman
AKA: Alex
FRC #2503 (Warrior Robotics)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2008
Location: Brainerd, Minnesota
Posts: 347
theprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud of
Re: Unresponsive Code... Help Please?

I haven't looked at the code, but whenever you have a null pointer exception, it usually means you're trying to use something that you, like david said, haven't initialized yet.
__________________
Attending: MN Duluth Regional
Reply With Quote
  #4   Spotlight this post!  
Unread 01-18-2012, 05:17 PM
codedr codedr is offline
Registered User
FRC #0537
Team Role: Mentor
 
Join Date: Mar 2010
Rookie Year: 2009
Location: Wisconsin
Posts: 68
codedr will become famous soon enoughcodedr will become famous soon enough
Re: Unresponsive Code... Help Please?

One the variables referenced at line 55 in pleasework.java is NULL.

> [cRIO] java.lang.NullPointerException
> [cRIO] at edu.wpi.first.wpilibj.templates.pleasework.teleopI nit(pleasework.java:55)
Reply With Quote
  #5   Spotlight this post!  
Unread 01-18-2012, 05:28 PM
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: Unresponsive Code... Help Please?

Instead of:

Code:
Sweeper sweep;
It's best to have:

Code:
Sweeper sweep = Sweeper.getInstance();
Looking through your code, you don't have any getInstance() methods in Sweeper, which means you may not everything you need to have a "singleton class."

A singleton is a class that ensure that only one instance of it is ever created. The getInstance() method should check to see if a Sweeper has already been created. If it has, return that instance, if not, create a new one.

There are examples of how to make a getInstance() method to ensure your subsystems classes are all singletons. These examples can be found in the WPILib Cookbook.
__________________
In life, what you give, you keep. What you fail to give, you lose forever...
Reply With Quote
  #6   Spotlight this post!  
Unread 01-19-2012, 12:31 PM
twiggzee twiggzee is offline
Registered User
FRC #3502 (Octo-(PI)-Rates)
Team Role: Mentor
 
Join Date: Mar 2011
Rookie Year: 2011
Location: Tallahassee, FL
Posts: 55
twiggzee is an unknown quantity at this point
Re: Unresponsive Code... Help Please?

Still no luck, how exactly do you initalize a command? the cookbook says it's supposed to happen automatically when the joystick is pressed...

David, I have this in Sweeper.java. is this not "constructed" as you say:
public class Sweeper extends Subsystem {
Victor sweep;
public void initDefaultCommand() {
setDefaultCommand(new SweepStop());
}
public Sweeper(){
sweep = new Victor(RobotMap.sweeperMotor);
}
}

Since my last post I added a getInstance method to the DriveTrain subsystem as Mr Lim's suggested. I also got rid of all subsystems except for the DriveSystem and the commands pertaining to that just to rule out any conflicts. This includes the Sweeper subsystem and commands.

line 55 in pleasework.java is this, doesn't that need to be there?

public void teleopInit() {
autonomousCommand.cancel();
}
i commented it out to just to give it a try and it gets rid of the null pointer but still no movement in the robot.

Now, the last few lines in Netbeans' output window show:
[cRIO] Default IterativeRobot.disabledInit() method... Overload me!
[cRIO] Default IterativeRobot.disabledContinuous() method... Overload me!
[cRIO] Default IterativeRobot.disabledPeriodic() method... Overload me!
[cRIO] teleopInit
[cRIO] edu.wpi.first.wpilibj.util.AllocationException: PWM channel 2 on module 1 is already allocated
[cRIO] at edu.wpi.first.wpilibj.PWM.initPWM(PWM.java:t edu.wpi.first.wpilibj.RobotDrive.<init>(RobotDrive .java:110)
[cRIO] at edu.wpi.first.wpilibj.templates.subsystems.DriveTr ain.<init>(DriveTrain.java:41)
[cRIO] at edu.wpi.first.wpilibj.templates.subsystems.DriveTr ain.getInstance(DriveTrain.java:30)
[cRIO] at edu.wpi.first.wpilibj.templates.commands.DriveWith Joy.<init>(DriveWithJoy.java:27)
[cRIO] at edu.wpi.first.wpilibj.templates.subsystems.DriveTr ain.initDeat edu.wpi.first.wpilibj.templates.pleasework.teleopP eriodic(pleasework.java:70)
[cRIO] at edu.wpi.first.wpilibj.IterativeRobot.startCompetit ion(IterativeRobot.java:145)
[cRIO] at edu.wpi.first.wpilibj.RobotBase.startApp(RobotBase .java:156)
[cRIO] in virtual method #10 of javax.microedition.midlet.MIDlet(bci=17)
[cRIO] at javax.microedition.midlet.MIDletTunnelImpl.callSta rtApp(64)
[cRIO] at com.sun.squawk.imp.MIDletMainWrapper.main(110)
[cRIO] in virtual method #95 of com.sun.squawk.Klass(bci=25)
[cRIO] at com.sun.squawk.Isolate.run(1506)
[cRIO] at java.lang.Thread.run(231)
[cRIO] in virtual method #47 of com.sun.squawk.VMThread(bci=42)
[cRIO] in static method #3 of com.sun.squawk.VM(bci=6)
[cRIO] WARNING: Robots don't quit!
[cRIO] ---> The startCompetition() method (or methods called by it) should have handled the exception above.
[cRIO] Robot Drive... Output not updated often enough.
[cRIO] Robot Drive... Output not updated often enough.
__________________
Wendy
Team 3502
Reply With Quote
  #7   Spotlight this post!  
Unread 01-19-2012, 07:58 PM
Patrickwhite's Avatar
Patrickwhite Patrickwhite is offline
May the North be with you
FRC #0610 (The Coyotes)
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Toronto
Posts: 88
Patrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of light
Re: Unresponsive Code... Help Please?

That error suggests that you are trying to initialize two things to the same PWM port. If all you have left are the drive system and sweeper subsystems, I would hazard a guess that either they are both trying to access PWM channel 2, or that somehow one of them (the one that uses PWM channel 2) is being initialized twice (the sort of scenario the singleton class is meant to prevent). Look through your getInstances to make sure they can only run the constructor once, make sure your constructors are private, and make sure there aren't any accidental calls to constructors outside of the subsystem classes.
__________________
while(!going.isTough());
tough.exit();

What will we do tonight, Warfa?
The same thing we do every night, Patrick. Sit and wait for Electrical.
Reply With Quote
  #8   Spotlight this post!  
Unread 01-19-2012, 08:04 PM
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: Unresponsive Code... Help Please?

Patrick's suggestion above is a good start.

Also it's possible you are trying to create more than one instance of your Sweeper.

Check your code to ensure you are NEVER trying to create an instance of the Sweeper OUTSIDE of your getInstance() method.

If you have:

Sweeper sweep = new Sweeper();

anywhere else in your code, you need to replace it with:

Sweeper sweep = Sweeper.getInstance();

If you try and create multiple Sweepers by running new Sweeper() more than once, you will get the error error you described. The getInstance() method should prevent that from ever happening.
__________________
In life, what you give, you keep. What you fail to give, you lose forever...
Reply With Quote
  #9   Spotlight this post!  
Unread 01-25-2012, 01:56 PM
twiggzee twiggzee is offline
Registered User
FRC #3502 (Octo-(PI)-Rates)
Team Role: Mentor
 
Join Date: Mar 2011
Rookie Year: 2011
Location: Tallahassee, FL
Posts: 55
twiggzee is an unknown quantity at this point
Re: Unresponsive Code... Help Please?

Just an update: I found a new version of the cookbook and followed the examples again and it worked this time. Our robot drives now!

The difference was that the previous version of the cookbook was telling us to declare another object (m_drive) in the command file. in the new cookbook that's not there. i took it out of my code and it worked. that would explain why i was getting an error from it trying to access the same PWM port twice...

whew...
__________________
Wendy
Team 3502
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 08:30 AM.

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