Go to Post Why is it considered shameful to do the smart thing? As the saying goes, "I don't make the rules, I just live by them." - Chris Hibner [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 Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 26-01-2012, 19:19
kingkurry kingkurry is offline
Registered User
FRC #4067
 
Join Date: Jan 2012
Location: Maryland
Posts: 20
kingkurry is an unknown quantity at this point
Output not updated often enough error

Yesterday, or maybe the day before, all our code stopped working. We had a robot that was fully drivable with the joysticks. However, now any code we run starts throwing exceptions, no matter how simple.

For example, when we attempt to run code as simple as this:

Code:
package edu.wpi.first.wpilibj.templates;


import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Jaguar;



public class RobotTemplate extends IterativeRobot {
    Joystick left;
    Joystick right; 
    
    RobotDrive robot; 
    public void robotInit() {
        Joystick left = new Joystick(1);
        Joystick right = new Joystick(2);
        
        RobotDrive robot = new RobotDrive(1,2,3,4);
        

    }

    /**
     * This function is called periodically during autonomous
     */
    public void autonomousPeriodic() {

    }

    /**
     * This function is called periodically during operator control
     */
    public void teleopPeriodic() {
        robot.tankDrive(left, right);
    }
    
}
It throws this exception when we put it into teleop mode

Code:
java.lang.NullPointerException
[cRIO]     at edu.wpi.first.wpilibj.templates.RobotTemplate.teleopPeriodic(RobotTemplate.java:43)
[cRIO]     at edu.wpi.first.wpilibj.IterativeRobot.startCompetition(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.callStartApp(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.
[cRIO] Robot Drive... Output not updated often enough.
[cRIO] Robot Drive... Output not updated often enough.
The "[cRIO] Robot Drive... Output not updated often enough." output goes on forever.

We are testing this code without any motors attached to the jaguars since our team is working on the frame. Could this be an issue?

Also, one of our other programmers was trying his hand at programming on this. I am not 100% sure what he did, but this problem is persisting throughout all new projects we create. Do these errors indicate that he may have mistakenly modified the API's we received from first?
Reply With Quote
  #2   Spotlight this post!  
Unread 27-01-2012, 10:28
derekwhite's Avatar
derekwhite derekwhite is offline
Java Virtual Machine Hacker
no team (FIRST@Oracle)
Team Role: Programmer
 
Join Date: May 2009
Rookie Year: 2009
Location: Burlington, MA
Posts: 127
derekwhite is on a distinguished road
Re: Output not updated often enough error

the "Output not updated often enough error" message is a secondary problem. That message will print when your robot apps stops working for any reason.

The Key is in the stack trace:
java.lang.NullPointerException
[cRIO] at edu.wpi.first.wpilibj.templates.RobotTemplate.tele opPeriodic(RobotTemplate.java:43)

So at line 43 of RobotTemplate.java the app tried to do something with a pointer that was null. Like call a method or reference a field.

In your code the suspect pointer is "robot". Which you'd think was initialized in robotInit(), but that is actually a local variable that is hiding the field "robot". So the field is still null.

The NetBeans editor may have given you a yellow warning on that line. It can sometimes nag too much, but you should always look at the warning by hovering the mouse over the yellow triangle.
Reply With Quote
  #3   Spotlight this post!  
Unread 27-01-2012, 15:01
ProgrammerMatt ProgrammerMatt is offline
Programmer-Electrical-Mechanical
FRC #0228 (Gus)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Southington
Posts: 138
ProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really nice
Re: Output not updated often enough error

Just a heads up..
When you put this before your init: P.S you can declare 2 things in one line just use commas,

Code:
Joystick left;
Joystick right;
Joystick left, right;
You don't have to put it again you put:
Code:
Joystick left = new Joystick(1);
Joystick right = new Joystick(2);
You already declared left as a joystick you dont have to do it again, just saying.

You dident declare an axis for driving
Code:
robot.tankDrive(left.getY(),right.getY());

Last edited by ProgrammerMatt : 27-01-2012 at 15:06.
Reply With Quote
  #4   Spotlight this post!  
Unread 28-01-2012, 19:51
Chiller Chiller is offline
Registered User
AKA: Connor Christie
FRC #4095 (RoXI Robotics)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Wisconsin
Posts: 118
Chiller is on a distinguished road
Re: Output not updated often enough error

In your robotInit instead of:
Code:
Joystick left = new Joystick(1);
Joystick right = new Joystick(2);
        
RobotDrive robot = new RobotDrive(1,2,3,4);
Replace it with:
Code:
left = new Joystick(1);
right = new Joystick(2);
        
robot = new RobotDrive(1,2,3,4);
You already created the object above so right here you just have to initialize it! Your IDE should've given you an error...
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 13:03.

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