Go to Post They see us come into school looking like zombies, and they know that some people start smelling like chain lube and such...but for the most part, they don't realize that for a lot of us, there is a deep commitment to our team that we do a very large amount of work for that team. - JakeGallagher [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 03-03-2013, 16:51
Mr.Roboto3335's Avatar
Mr.Roboto3335 Mr.Roboto3335 is offline
Wait, What?
AKA: Jimmy
FRC #3335 (Cy-Borgs)
Team Role: Programmer
 
Join Date: Nov 2011
Rookie Year: 2011
Location: Texas
Posts: 47
Mr.Roboto3335 is an unknown quantity at this point
Code not working

I'm having some trouble with my code. Everytime I try to upload it keeps on showing this:
[cRIO] FPGA Hardware GUID: 0xa14c11bde4bb64aef6a86fc52a294cd9
[cRIO] FPGA Software GUID: 0xa14c11bde4bb64aef6a86fc52a294cd9
[cRIO] java.lang.NullPointerException: Null motor provided
[cRIO] at edu.wpi.first.wpilibj.RobotDrive.<init>(RobotDrive .java:139)
[cRIO] at edu.wpi.first.wpilibj.templates.RobotTemplate.Robo tDriveInit(RobotTemplate.java:67)
[cRIO] at edu.wpi.first.wpilibj.templates.RobotTemplate.robo tInit(RobotTemplate.java:41)
[cRIO] at edu.wpi.first.wpilibj.IterativeRobot.startCompetit ion(IterativeRobot.java:72)
[cRIO] at edu.wpi.first.wpilibj.RobotBase.startApp(RobotBase .java:169)
[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.


Code:
Code:
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved.                             */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project.                                                               */
/*----------------------------------------------------------------------------*/

package edu.wpi.first.wpilibj.templates;


import edu.wpi.first.wpilibj.DriverStationLCD;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Servo;
import edu.wpi.first.wpilibj.SpeedController;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.camera.AxisCamera;


public class RobotTemplate extends IterativeRobot 
{   

    private Joystick leftStick;
    private Joystick rightStick;
    private Joystick shootStick;
    private SpeedController ShooterFront;
    private SpeedController ShooterBack;        
    private SpeedController Left;
    private SpeedController Right;
    private RobotDrive drive;
    private AxisCamera camera;
    private Servo servo;
    private DriverStationLCD lcd = DriverStationLCD.getInstance();
    
    public void robotInit() 
    {
        
      JoystickInit();
      RobotDriveInit();
      TalonInit();
      ServoInit();
      VictorInit();
      
      
      getWatchdog().setExpiration(0.1); 
        lcd.println(DriverStationLCD.Line.kUser2, 1, "Enabled!");
        lcd.updateLCD();
    }
    
    public void VictorInit()
    {
       ShooterFront = new Victor(4);
       ShooterBack = new Victor(3);
    }
    
    public void JoystickInit()
    {
        leftStick = new Joystick(1);
        rightStick = new Joystick(2); 
        shootStick = new Joystick(3);
    } 
    
    public void RobotDriveInit()
    {
        drive = new RobotDrive(Left, Right);
    }
        
    public void TalonInit()
    {
        Left = new Talon(1);
        Right = new Talon(2);
    }
    
    public void ServoInit()
    {
        servo = new Servo(7);
    }
    
    public void autonomousInit()
    {
        getWatchdog().setEnabled(true);
        lcd.println(DriverStationLCD.Line.kUser2, 1, "Autonomous!");
        lcd.updateLCD();
    }
    
    public void autonomousPeriodic()
    {
        
    }

    public void teleopInit()
    {
        getWatchdog().setEnabled(true);
        lcd.println(DriverStationLCD.Line.kUser2, 1, "Teleop!");
        lcd.updateLCD();
    }
    long x = 1;
    public void teleopContinuous()
    {
        
    }
    
    public void teleopPeriodic() 
    {
         AxisCamera.getInstance().writeCompression(0);
         AxisCamera.getInstance().writeResolution(AxisCamera.ResolutionT.k320x240);
         AxisCamera.getInstance().writeBrightness(10);
         
         drive.tankDrive(-leftStick.getY(), -rightStick.getY());
         
         if(shootStick.getRawButton(1))
    {
             servo.setAngle(30);
    }
         
         else
    {
             servo.setAngle(0);
    }
         
         if(shootStick.getRawButton(6))
    {
             ShooterFront.set(100);
             ShooterBack.set(100);
    }
        else if(shootStick.getRawButton(7))
    {
             ShooterFront.set(0);
             ShooterBack.set(0);
    }
 }

    public void testPeriodic() 
    {

    }
}
__________________
Wait, what?
Reply With Quote
  #2   Spotlight this post!  
Unread 03-03-2013, 17:09
xForceDee's Avatar
xForceDee xForceDee is offline
Registered User
AKA: Bart Kerfeld
FRC #4239 (Warpspeed)
Team Role: College Student
 
Join Date: Dec 2012
Rookie Year: 2012
Location: Minnesota
Posts: 58
xForceDee is a splendid one to beholdxForceDee is a splendid one to beholdxForceDee is a splendid one to beholdxForceDee is a splendid one to beholdxForceDee is a splendid one to beholdxForceDee is a splendid one to behold
Re: Code not working

A possible problem would be that your RobotDrive is getting a null pointer because it is trying to use motors that are still null. If that is the case, the solution is simple, just move the RobotDriveInit method below the TalonInit method. Let me know if that works.
Reply With Quote
  #3   Spotlight this post!  
Unread 03-03-2013, 17:32
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,590
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Code not working

Quote:
Originally Posted by xForceDee View Post
A possible problem would be that your RobotDrive is getting a null pointer because it is trying to use motors that are still null.
That's exactly the problem.
Reply With Quote
  #4   Spotlight this post!  
Unread 03-03-2013, 18:03
Mr.Roboto3335's Avatar
Mr.Roboto3335 Mr.Roboto3335 is offline
Wait, What?
AKA: Jimmy
FRC #3335 (Cy-Borgs)
Team Role: Programmer
 
Join Date: Nov 2011
Rookie Year: 2011
Location: Texas
Posts: 47
Mr.Roboto3335 is an unknown quantity at this point
Re: Code not working

It works! Thank you!
__________________
Wait, what?
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 12:47.

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