View Single Post
  #3   Spotlight this post!  
Unread 24-01-2015, 13:16
DeeWBee DeeWBee is offline
Registered User
FRC #3630
 
Join Date: Feb 2011
Location: Breck
Posts: 3
DeeWBee is an unknown quantity at this point
Re: Reboot roboRio After Uploading Code [Java]

This code is dirt simple so I doubt it's a code issue but here you go. We've had this issue from the beginning even with sample code.


Code:
package org.usfirst.frc.team3630.robot;
//import the necessary packages for each class 
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.RobotDrive; 
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.DigitalInput; 
import edu.wpi.first.wpilibj.Talon;


/**
 * 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 {
	//Declare and name the drive train object  
	RobotDrive driveTrain; 
	
	//Declare and name the two joystick objects 
	Joystick leftStick; 
	Joystick rightStick; 
	
	//Declare and name the two front bumper objects 
	DigitalInput leftBumper; 
	DigitalInput rightBumper;
	
	//Declare and name the four motor controllers for the drive train 
	Talon frontLeft; 
	Talon rearLeft; 
	Talon frontRight;
	Talon rearRight; 
	
	
    /**
     * This function is run when the robot is first started up and should be
     * used for any initialization code.
     */
    public void robotInit() {
    	//Construct the two joystick objects 
    	leftStick = new Joystick(1);
    	rightStick = new Joystick(2); 
    	
    	//Construct the two front bumper objects 
    	rightBumper = new DigitalInput(0);
    	leftBumper = new DigitalInput(1); 
    	
    	//Construct the four motor controller objects 
    	frontLeft = new Talon(1);
    	rearLeft = new Talon(2);
    	frontRight = new Talon(3);
    	rearRight = new Talon(4); 
    	
    	//Construct the drive train object 
    	driveTrain = new RobotDrive(frontLeft, rearLeft, frontRight, rearRight); 
    	
    	//Invert the right motors in the drive train 
    	driveTrain.setInvertedMotor(RobotDrive.MotorType.kFrontRight, true);
    	driveTrain.setInvertedMotor(RobotDrive.MotorType.kRearRight, true);
    
    }

    /**
     * This function is called periodically during autonomous
     */
    public void autonomousPeriodic() {

    }

    /**
     * This function is called periodically during operator control
     */
    public void teleopPeriodic() {
    	//Define the drive train as mecanum
    	driveTrain.mecanumDrive_Cartesian(leftStick.getX(), leftStick.getY(), rightStick.getX(), 0);
        
    	//If the right bumper is hit, stop the right motors 
    	if(rightBumper.get() == false) {
        	frontRight.set(0);
        	rearRight.set(0);
        }
    	
    	//If the left bumper is hit, stop the left motors 
    	if(leftBumper.get() == false) {
    		frontLeft.set(0);
    		rearLeft.set(0); 
    	}
    }
    
    /**
     * This function is called periodically during test mode
     */
    public void testPeriodic() {
    
    }
    
}