View Single Post
  #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