Go to Post Looks like it will be to your advantage to keep the Refs happy. Remember, Donuts go a long way toward that end! - billbo911 [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: 3 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 15-01-2015, 11:03
Yonatan Rubin Yonatan Rubin is offline
Registered User
FRC #2212
 
Join Date: Jan 2015
Location: Gedera Israel
Posts: 1
Yonatan Rubin is an unknown quantity at this point
Unhandled exception instantiating robot

when I try to run the code on roboRio the driver station write:

ERROR Unhandled exception instantiating robot org.usfirst.frc.team2212.robot.Robot java.lang.ExceptionInInitializerError at [java.lang.Class.forName0(Native Method), java.lang.Class.forName(Class.java:259), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.jav a:197)]

can anybody help me understand what does it mean and how could I solve it?

Last edited by Yonatan Rubin : 15-01-2015 at 11:14.
Reply With Quote
  #2   Spotlight this post!  
Unread 15-01-2015, 11:05
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,725
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Unhandled exception instantiating robot

Quote:
Originally Posted by Yonatan Rubin View Post
when I try to get code on robot the driver station write:

ERROR Unhandled exception instantiating robot org.usfirst.frc.team2212.robot.Robot java.lang.ExceptionInInitializerError at [java.lang.Class.forName0(Native Method), java.lang.Class.forName(Class.java:259), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.jav a:197)]

can anybody help me understand what does it mean and how could I solve it?
Can you post the code from your Robot class?
Reply With Quote
  #3   Spotlight this post!  
Unread 15-01-2015, 11:18
Ozuru's Avatar
Ozuru Ozuru is offline
It's always the programmer's fault.
no team
 
Join Date: May 2013
Rookie Year: 2010
Location: Earth
Posts: 268
Ozuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to behold
Re: Unhandled exception instantiating robot

Read the error code. It's telling you to look at a line in your Robot.java - pastebin your robot.java.
Reply With Quote
  #4   Spotlight this post!  
Unread 15-01-2015, 19:43
dash121 dash121 is offline
Registered User
FRC #4085
 
Join Date: Oct 2014
Location: Reynoldsburg Ohio
Posts: 23
dash121 is an unknown quantity at this point
Re: Unhandled exception instantiating robot

Quote:
Originally Posted by Ozuru View Post
Read the error code. It's telling you to look at a line in your Robot.java - pastebin your robot.java.
I am having the same problem. The specific error that is given "ERROR Unhandled exception: java.lang.NullPointerException at [edu.wpi.first.wpilibj.PWM.startLiveWindowMode(PWM. java:484), org.usfirst.frc.team4085.robot.Robot.teleopPeriodi c(Robot.java:117), edu.wpi.first.wpilibj.IterativeRobot.startCompetit ion(IterativeRobot.java:150), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.jav a:234)]"

Can you help me?

Code:
package org.usfirst.frc.team4085.robot;

import java.io.IOException;

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.BuiltInAccelerometer;
import edu.wpi.first.wpilibj.PowerDistributionPanel;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable;
import edu.wpi.first.wpilibj.Talon;


import org.usfirst.frc.team4085.robot.commands.ExampleCommand;
import org.usfirst.frc.team4085.robot.subsystems.ExampleSubsystem;

import edu.wpi.first.wpilibj.*;

/**
 * The VM is configured to automatically run this class, and to call the
 * functions corresponding to each mode, as described in the IterativeRobot
 * documentation. If you change the name of this class or the package after
 * creating this project, you must also update the manifest file in the resource
 * directory.
 */
public class Robot extends IterativeRobot {

	public static final ExampleSubsystem exampleSubsystem = new ExampleSubsystem();
	public static OI oi;

    Command autonomousCommand;
    Joystick lstick = new Joystick(0);
    Joystick rstick = new Joystick(1);
    PowerDistributionPanel PDP = new PowerDistributionPanel();
    BuiltInAccelerometer Accel = new BuiltInAccelerometer();
    LiveWindow Window = new LiveWindow();
    Talon Left = new Talon(0);
    Talon Right = new Talon(1);
    RobotDrive chassis = new RobotDrive(Left,Right);
    SmartDashboard smart = new SmartDashboard();

    /**
     * This function is run when the robot is first started up and should bDahe
     * used for any initialization code.
     */
    public void robotInit() {
		oi = new OI();
        // instantiate the command used for the autonomous period
        autonomousCommand = new ExampleCommand();
    }
	
	public void disabledPeriodic() {
		Scheduler.getInstance().run();
	}

    public void autonomousInit() {
        // schedule the autonomous command (example)
        if (autonomousCommand != null) autonomousCommand.start();
    }

    /**
     * This function is called periodically during autonomous
     */
    public void autonomousPeriodic() {
        Scheduler.getInstance().run();
    }

    
	public void teleopInit() {
		// This makes sure that the autonomous stops running when
        // teleop starts running. If you want the autonomous to 
        // continue until interrupted by another command, remove
        // this line or comment it out.
        if (autonomousCommand != null) autonomousCommand.cancel();
    }

    /**
     * This function is called when the disabled button is hit.
     * You can use it to reset subsystems before shutting down.
     */
    public void disabledInit(){

    }

    /**
     * This function is called periodically during operator control
     */
    @SuppressWarnings({"static-access" })
	public void teleopPeriodic() {
        Scheduler.getInstance().run();
        double counter = 0.0;
        while(isEnabled())
        {
        	smart.putNumber("Timer", counter++);
        }
        while(true)
        {
        	
        	chassis.setSafetyEnabled(false);
        	
        	chassis.tankDrive(lstick, rstick);
        	
        	
        	smart.putNumber("The X Axis", Accel.getX());
        	
        	
        	smart.putNumber("The Y Axis", Accel.getY());
        	smart.putNumber("The Z Axis", Accel.getZ());
        	smart.putNumber("The Temp of the roboRIO", PDP.getTemperature());
        	smart.putNumber("This is the test", smart.getNumber("Put a number here", 1));
        	
        	
        	Window.setEnabled(isEnabled());
        	Left.startLiveWindowMode();
        	Right.startLiveWindowMode();
        	Accel.startLiveWindowMode();
        	PDP.startLiveWindowMode();
        	
        	
        	smart.putNumber("Total Current", PDP.getTotalCurrent());
        	smart.putNumber("Total Energy", PDP.getTotalEnergy());
        	smart.putNumber(" Total Power", PDP.getTotalPower());
        	smart.putNumber("Match Time", Timer.getMatchTime());

        	
        	int inChar = 0;
            System.out.println("Enter a Character:");
            try {
                inChar = System.in.read();
                System.out.print("You entered ");
                System.out.println(inChar);
            }
            catch (IOException e){
                System.out.println("Error reading from user");
            }
            
            int outChar = 5;
				if (inChar == outChar ){
					System.out.println("Hello World");
				}
				else
				{
					System.out.println("Not J");
				}
        }
			}
        	
     
    
    /**
     * This function is called periodically during test mode
     */
    public void testPeriodic() {
        LiveWindow.run();
    }
}
Reply With Quote
  #5   Spotlight this post!  
Unread 15-01-2015, 22:00
Team3266Spencer's Avatar
Team3266Spencer Team3266Spencer is offline
Team Captain and Lead Programmer
AKA: Spencer Lanman
FRC #3266 (Robots-R-US)
Team Role: Programmer
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Richmond, Indiana
Posts: 280
Team3266Spencer is an unknown quantity at this point
Re: Unhandled exception instantiating robot

Quote:
Originally Posted by dash121 View Post
I am having the same problem. The specific error that is given "ERROR Unhandled exception: java.lang.NullPointerException at [edu.wpi.first.wpilibj.PWM.startLiveWindowMode(PWM. java:484), org.usfirst.frc.team4085.robot.Robot.teleopPeriodi c(Robot.java:117), edu.wpi.first.wpilibj.IterativeRobot.startCompetit ion(IterativeRobot.java:150), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.jav a:234)]"

Can you help me?

Code:
package org.usfirst.frc.team4085.robot;

import java.io.IOException;

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.BuiltInAccelerometer;
import edu.wpi.first.wpilibj.PowerDistributionPanel;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable;
import edu.wpi.first.wpilibj.Talon;


import org.usfirst.frc.team4085.robot.commands.ExampleCommand;
import org.usfirst.frc.team4085.robot.subsystems.ExampleSubsystem;

import edu.wpi.first.wpilibj.*;

/**
 * The VM is configured to automatically run this class, and to call the
 * functions corresponding to each mode, as described in the IterativeRobot
 * documentation. If you change the name of this class or the package after
 * creating this project, you must also update the manifest file in the resource
 * directory.
 */
public class Robot extends IterativeRobot {

	public static final ExampleSubsystem exampleSubsystem = new ExampleSubsystem();
	public static OI oi;

    Command autonomousCommand;
    Joystick lstick = new Joystick(0);
    Joystick rstick = new Joystick(1);
    PowerDistributionPanel PDP = new PowerDistributionPanel();
    BuiltInAccelerometer Accel = new BuiltInAccelerometer();
    LiveWindow Window = new LiveWindow();
    Talon Left = new Talon(0);
    Talon Right = new Talon(1);
    RobotDrive chassis = new RobotDrive(Left,Right);
    SmartDashboard smart = new SmartDashboard();

    /**
     * This function is run when the robot is first started up and should bDahe
     * used for any initialization code.
     */
    public void robotInit() {
		oi = new OI();
        // instantiate the command used for the autonomous period
        autonomousCommand = new ExampleCommand();
    }
	
	public void disabledPeriodic() {
		Scheduler.getInstance().run();
	}

    public void autonomousInit() {
        // schedule the autonomous command (example)
        if (autonomousCommand != null) autonomousCommand.start();
    }

    /**
     * This function is called periodically during autonomous
     */
    public void autonomousPeriodic() {
        Scheduler.getInstance().run();
    }

    
	public void teleopInit() {
		// This makes sure that the autonomous stops running when
        // teleop starts running. If you want the autonomous to 
        // continue until interrupted by another command, remove
        // this line or comment it out.
        if (autonomousCommand != null) autonomousCommand.cancel();
    }

    /**
     * This function is called when the disabled button is hit.
     * You can use it to reset subsystems before shutting down.
     */
    public void disabledInit(){

    }

    /**
     * This function is called periodically during operator control
     */
    @SuppressWarnings({"static-access" })
	public void teleopPeriodic() {
        Scheduler.getInstance().run();
        double counter = 0.0;
        while(isEnabled())
        {
        	smart.putNumber("Timer", counter++);
        }
        while(true)
        {
        	
        	chassis.setSafetyEnabled(false);
        	
        	chassis.tankDrive(lstick, rstick);
        	
        	
        	smart.putNumber("The X Axis", Accel.getX());
        	
        	
        	smart.putNumber("The Y Axis", Accel.getY());
        	smart.putNumber("The Z Axis", Accel.getZ());
        	smart.putNumber("The Temp of the roboRIO", PDP.getTemperature());
        	smart.putNumber("This is the test", smart.getNumber("Put a number here", 1));
        	
        	
        	Window.setEnabled(isEnabled());
        	Left.startLiveWindowMode();
        	Right.startLiveWindowMode();
        	Accel.startLiveWindowMode();
        	PDP.startLiveWindowMode();
        	
        	
        	smart.putNumber("Total Current", PDP.getTotalCurrent());
        	smart.putNumber("Total Energy", PDP.getTotalEnergy());
        	smart.putNumber(" Total Power", PDP.getTotalPower());
        	smart.putNumber("Match Time", Timer.getMatchTime());

        	
        	int inChar = 0;
            System.out.println("Enter a Character:");
            try {
                inChar = System.in.read();
                System.out.print("You entered ");
                System.out.println(inChar);
            }
            catch (IOException e){
                System.out.println("Error reading from user");
            }
            
            int outChar = 5;
				if (inChar == outChar ){
					System.out.println("Hello World");
				}
				else
				{
					System.out.println("Not J");
				}
        }
			}
        	
     
    
    /**
     * This function is called periodically during test mode
     */
    public void testPeriodic() {
        LiveWindow.run();
    }
}
I'm not sure about the exception that was thrown but there should not be while(isEnabled()) and while(true) loops inside of your teleopPeriodic method! This function is called periodically and so it is already part of a loop. Therefore you should write the code knowing its going to be called every ~30 ms. Also, you should not be trying to read user input on the rRIO.
__________________
2012: Buckeye Regional, Queen City Regional, Human Player
2013: Queen City Regional, Buckeye Regional, Crossroads Regional
Shooter Operator
2014: Crossroads Regional, Queen City Regional
Catapult Operator
2015: Georgia Southern Classic Regional (Winner), Queen City Regional
Chainsaw Operator
Want to talk? TeamSpeak: team3266.noip.me
Reply With Quote
  #6   Spotlight this post!  
Unread 16-01-2015, 07:54
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 990
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Unhandled exception instantiating robot

Quote:
Originally Posted by dash121 View Post
I am having the same problem. The specific error that is given "ERROR Unhandled exception: java.lang.NullPointerException at [edu.wpi.first.wpilibj.PWM.startLiveWindowMode(PWM. java:484), org.usfirst.frc.team4085.robot.Robot.teleopPeriodi c(Robot.java:117), edu.wpi.first.wpilibj.IterativeRobot.startCompetit ion(IterativeRobot.java:150), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.jav a:234)]"
I'm having difficulty figuring out what exactly you are trying to do with this code. It is using the Command based template, but then you have manually altered the TeleopPeriodic method to do a number of strange things. Why are you trying to get user console input on the roboRIO? What are you trying to accomplish with the LiveWindow code? Why are you suppressing the warming that would have told you your code was broken before you ran it?
Reply With Quote
  #7   Spotlight this post!  
Unread 16-01-2015, 09:53
fsilberberg fsilberberg is offline
WPILib Developer
AKA: Fred Silberberg
FRC #0190
Team Role: Alumni
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Redmond
Posts: 148
fsilberberg has a spectacular aura aboutfsilberberg has a spectacular aura aboutfsilberberg has a spectacular aura about
Re: Unhandled exception instantiating robot

Quote:
Originally Posted by dash121 View Post
I am having the same problem. The specific error that is given "ERROR Unhandled exception: java.lang.NullPointerException at [edu.wpi.first.wpilibj.PWM.startLiveWindowMode(PWM. java:484), org.usfirst.frc.team4085.robot.Robot.teleopPeriodi c(Robot.java:117), edu.wpi.first.wpilibj.IterativeRobot.startCompetit ion(IterativeRobot.java:150), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.jav a:234)]"

Can you help me?

Code:
                Window.setEnabled(isEnabled());
        	Left.startLiveWindowMode();
        	Right.startLiveWindowMode();
        	Accel.startLiveWindowMode();
        	PDP.startLiveWindowMode();
This is not how you put objects to the LiveWindow. See the examples on using LiveWindow here: http://wpilib.screenstepslive.com/s/...ode-livewindow.
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 18:02.

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