Go to Post I in all sincerity thoroughly enjoy the way that programming for FIRST makes me want to bash my head against a wall. - pogenwurst [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 19-02-2016, 07:55
nlt5 nlt5 is offline
Registered User
FRC #5676
 
Join Date: Feb 2016
Location: Michigan
Posts: 23
nlt5 is an unknown quantity at this point
Code problems

Hi Everyone,
if someone has time can you please take a look at our code. When we compile this the driver station shows no robot code. Currently we are only trying to use the drivetrain41 and the shootermotors. The other code is written so that we can test those items when they are ready. Do I need to comment them out when they are not connected? For example the servos are not plugged into the rio yet will that cause a problem?

Thank you very much

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

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.buttons.*;
import edu.wpi.first.wpilibj.Servo;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.DoubleSolenoid;


/**
 * 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 {
    RobotDrive DriveTrain41;
    RobotDrive shootermotors;
    Servo launchleft;
    Servo launchright;
    DoubleSolenoid pickerpiston;
    DoubleSolenoid armpiston;
    Joystick xboxcontroller;
    JoystickButton abutton;
    JoystickButton bbutton;
    JoystickButton xbutton;
    JoystickButton ybutton;
    JoystickButton leftbumper;
    JoystickButton rightbumper;
    JoystickButton lefttrigger;
    JoystickButton righttrigger;
    
    int autoloopcounter;
    
	
    /**
     * This function is run when the robot is first started up and should be
     * used for any initialization code.
     */
    public void robotInit() {
        DriveTrain41 = new RobotDrive(0,1,2,3);
        shootermotors = new RobotDrive(4,5);
        launchleft = new Servo(6);
        launchright = new Servo(7);
        xboxcontroller = new Joystick(0);
        pickerpiston = new DoubleSolenoid(0,1);
        armpiston = new DoubleSolenoid(2,3);
        righttrigger = new JoystickButton(xboxcontroller,2);
        lefttrigger = new JoystickButton(xboxcontroller,3);
        abutton = new JoystickButton(xboxcontroller,6);
        bbutton = new JoystickButton(xboxcontroller,7);
        xbutton = new JoystickButton(xboxcontroller,8);
        ybutton = new JoystickButton(xboxcontroller,9);
        leftbumper = new JoystickButton(xboxcontroller,10);
        rightbumper = new JoystickButton(xboxcontroller,11);
        DriveTrain41.setInvertedMotor(RobotDrive.MotorType.kFrontRight, true);
    	DriveTrain41.setInvertedMotor(RobotDrive.MotorType.kRearRight, true);
    	DriveTrain41.setInvertedMotor(RobotDrive.MotorType.kFrontLeft, true);
    	DriveTrain41.setInvertedMotor(RobotDrive.MotorType.kRearLeft, true);
    	shootermotors.setInvertedMotor(RobotDrive.MotorType.kFrontRight, true);

    }
    
	/**
	 * This autonomous (along with the chooser code above) shows how to select between different autonomous modes
	 * using the dashboard. The sendable chooser code works with the Java SmartDashboard. If you prefer the LabVIEW
	 * Dashboard, remove all of the chooser code and uncomment the getString line to get the auto name from the text box
	 * below the Gyro
	 *
	 * You can add additional auto modes by adding additional comparisons to the switch structure below with additional strings.
	 * If using the SendableChooser make sure to add them to the chooser code above as well.
	 */
    public void autonomousPeriodic() {
    	if(autoloopcounter < 100) //Check if we've completed 100 loops (approximately 2 seconds)
		{
			DriveTrain41.drive(-0.5, 0.0); 	// drive forwards half speed
			autoloopcounter++;
			} else {
			DriveTrain41.drive(0.0, 0.0); 	// stop robot
		}
    }
    /**
     * This function is called once each time the robot enters tele-operated mode
     */
    
    public void teleopInit() {
    	
        
    }
    
    /**
     * This function is called periodically during operator control
     */ 
    
    public void teleopPeriodic() {
        DriveTrain41.arcadeDrive(xboxcontroller);
       
        
 /**
  * This will turn the shooter motors on and off
  */
       if (xboxcontroller.getRawButton(8)) {
    	   shootermotors.drive(1,0);}
       else if (xboxcontroller.getRawButton(9)){
    	   shootermotors.drive(0,0);}
 /**
  * This will control the left servo on the robot      
  */
       
       if (xboxcontroller.getRawButton(11)) {
    	   launchleft.set(1.0);}
       else if (xboxcontroller.getRawButton(2)){
    	   launchleft.set(0.0);}
 /**
  * This will control the right servo on the robot    
  */
       if (xboxcontroller.getRawButton(10)) {
    	   launchright.set(1.0);}
       else if (xboxcontroller.getRawButton(3)){
    	   launchright.set(0.0);}
       
  /**
   * This will control the piston on the ramp to pick up the ball
   */
       
       if (xboxcontroller.getRawButton(6)) {
    	   pickerpiston.set(DoubleSolenoid.Value.kForward);}
       else if (xboxcontroller.getRawButton(7)) {
    	   pickerpiston.set(DoubleSolenoid.Value.kReverse);}
       
       else {pickerpiston.set(DoubleSolenoid.Value.kOff);}
       
       
       
       if (xboxcontroller.getRawButton(12)) {
    	   armpiston.set(DoubleSolenoid.Value.kForward);}
       else if (xboxcontroller.getRawButton(13)) {
    	   armpiston.set(DoubleSolenoid.Value.kReverse);}
       
       else {armpiston.set(DoubleSolenoid.Value.kOff);}
       
    	   
    	   
       }
       
        
       
   
}
Reply With Quote
  #2   Spotlight this post!  
Unread 19-02-2016, 08:03
EmileH's Avatar
EmileH EmileH is offline
it's not a water game, ok?
AKA: Emile Hamwey
FRC #1058 (The PVC Pirates) & SLFF (NE Way You Want It)
Team Role: Programmer
 
Join Date: Dec 2014
Rookie Year: 2011
Location: New England
Posts: 536
EmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant future
Re: Code problems

After you send your code to the robot, is there a message or error code that appears in the message window at the right of the DS? If so, it could be an exception or code crash, and the robot is trying to give you details about it. If there is anything there, post it here and we could try to help you understand it.
__________________
2016-present: High School Student, FRC 1058 PVC Pirates
2016: RiverRage 20 Champions, Battle of the Bay 3 Champions

2013-2015: Middle School Student, FRC 3467 Windham Windup
Reply With Quote
  #3   Spotlight this post!  
Unread 19-02-2016, 08:05
nlt5 nlt5 is offline
Registered User
FRC #5676
 
Join Date: Feb 2016
Location: Michigan
Posts: 23
nlt5 is an unknown quantity at this point
Re: Code problems

I am away from the ds currently but I will try to run it again when I can and look at the error report then post that error.
Reply With Quote
  #4   Spotlight this post!  
Unread 19-02-2016, 08:07
EmileH's Avatar
EmileH EmileH is offline
it's not a water game, ok?
AKA: Emile Hamwey
FRC #1058 (The PVC Pirates) & SLFF (NE Way You Want It)
Team Role: Programmer
 
Join Date: Dec 2014
Rookie Year: 2011
Location: New England
Posts: 536
EmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant future
Re: Code problems

Great. Also, when deploying from Eclipse, check and see if there is a message in the Eclipse console that states whether or not the code deployed correctly (this should be the blue and orange text that appears at the bottom of Eclipse when deploying code). That could tell you if the code even made it to the robot in the first place.
__________________
2016-present: High School Student, FRC 1058 PVC Pirates
2016: RiverRage 20 Champions, Battle of the Bay 3 Champions

2013-2015: Middle School Student, FRC 3467 Windham Windup
Reply With Quote
  #5   Spotlight this post!  
Unread 19-02-2016, 08:57
Beeker's Avatar
Beeker Beeker is offline
Registered User
AKA: Joe
FRC #4377 (BC. Blaze)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Michigan
Posts: 7
Beeker is an unknown quantity at this point
Re: Code problems

These screen shots might help

http://wpilib.screenstepslive.com/s/...to-the-roborio
Reply With Quote
  #6   Spotlight this post!  
Unread 19-02-2016, 09:14
nlt5 nlt5 is offline
Registered User
FRC #5676
 
Join Date: Feb 2016
Location: Michigan
Posts: 23
nlt5 is an unknown quantity at this point
Re: Code problems

we have been able to run a code on the robot i.e. the getting started but we are having trouble with our current code that we are trying to use.

Thank you though
Reply With Quote
  #7   Spotlight this post!  
Unread 19-02-2016, 14:06
nlt5 nlt5 is offline
Registered User
FRC #5676
 
Join Date: Feb 2016
Location: Michigan
Posts: 23
nlt5 is an unknown quantity at this point
Re: Code problems

So the build is successful in eclipse then when we look at the DS there is no robot code. The error as far as I can tell is in the robotmain and it reads an unhandled exception.
Reply With Quote
  #8   Spotlight this post!  
Unread 19-02-2016, 14:21
Jared's Avatar
Jared Jared is offline
Registered User
no team
Team Role: Programmer
 
Join Date: Aug 2013
Rookie Year: 2012
Location: Connecticut
Posts: 602
Jared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond repute
Re: Code problems

Can you copy and paste the entire error message? We need to know what the exception was and where it happened to be able to help you.
Reply With Quote
  #9   Spotlight this post!  
Unread 19-02-2016, 14:39
nlt5 nlt5 is offline
Registered User
FRC #5676
 
Join Date: Feb 2016
Location: Michigan
Posts: 23
nlt5 is an unknown quantity at this point
Re: Code problems

here is the error.
unhandled exception: Java.lang.nullpointer exception @
edu.wpi.RobotDrive.set invertedMotor(robot drive.java:706
org.us.first.robotinit(robot.java:61
edu.wpi first interativerobot.startCompetition(iterititiveRobot. java:72
edu.wpi RobotBase.main(RobotBase.java:241
Reply With Quote
  #10   Spotlight this post!  
Unread 19-02-2016, 15:17
EmileH's Avatar
EmileH EmileH is offline
it's not a water game, ok?
AKA: Emile Hamwey
FRC #1058 (The PVC Pirates) & SLFF (NE Way You Want It)
Team Role: Programmer
 
Join Date: Dec 2014
Rookie Year: 2011
Location: New England
Posts: 536
EmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant future
Re: Code problems

It looks like where you are setting an inverted motor (line 706 of your robot drive class), you are referencing a motor or some object that doesn't exist. NullPointerExceptions are errors that get thrown when you are trying to call something but it returns null.
__________________
2016-present: High School Student, FRC 1058 PVC Pirates
2016: RiverRage 20 Champions, Battle of the Bay 3 Champions

2013-2015: Middle School Student, FRC 3467 Windham Windup
Reply With Quote
  #11   Spotlight this post!  
Unread 20-02-2016, 23:14
Justin Buist Justin Buist is offline
Registered User
FRC #4003 (TriSonics)
Team Role: Mentor
 
Join Date: Feb 2015
Rookie Year: 2015
Location: Allendale, MI
Posts: 22
Justin Buist is an unknown quantity at this point
Re: Code problems

Quote:
Originally Posted by EmileH View Post
It looks like where you are setting an inverted motor (line 706 of your robot drive class), you are referencing a motor or some object that doesn't exist. NullPointerExceptions are errors that get thrown when you are trying to call something but it returns null.
RobotDrive is part of WPILibJ so it isn't "their" class. Line 706 in that class references the front right motor. In the posted code from Robot.java line 61 references the rear left motor so there might be a discrepancy between what was posted and what was actually run.

Either way the problem is in this line:

DriveTrain41 = new RobotDrive(0,1,2,3);

One of those pins doesn't actually map to a Talon. That could be a programming or wiring 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 22:16.

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