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

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);}
       
    	   
    	   
       }
       
        
       
   
}
   

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.

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.

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.

These screen shots might help

http://wpilib.screenstepslive.com/s/4485/m/13809/l/242586-building-and-downloading-a-robot-project-to-the-roborio

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

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.

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.

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

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.