Advertisement
Undefinedmaster

Robot

Aug 28th, 2015
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.95 KB | None | 0 0
  1. package org.usfirst.frc.team2834.robot;
  2.  
  3. import edu.wpi.first.wpilibj.Compressor;
  4. import edu.wpi.first.wpilibj.IterativeRobot;
  5. import edu.wpi.first.wpilibj.Joystick;
  6. import edu.wpi.first.wpilibj.RobotDrive;
  7. import edu.wpi.first.wpilibj.RobotDrive.MotorType;
  8. import edu.wpi.first.wpilibj.Solenoid;
  9. import edu.wpi.first.wpilibj.Victor;
  10.  
  11. /**
  12.  * The VM is configured to automatically run this class, and to call the
  13.  * functions corresponding to each mode, as described in the IterativeRobot
  14.  * documentation. If you change the name of this class or the package after
  15.  * creating this project, you must also update the manifest file in the resource
  16.  * directory.
  17.  */
  18. public class Robot extends IterativeRobot {
  19.     Joystick gamepad = new Joystick(0);
  20.     RobotDrive motors = new RobotDrive(0,1,2,3);
  21.     //Victor cannonLift = new Victor(4);
  22.     Compressor c = new Compressor(0);
  23.     Compressor d = new Compressor(1);
  24.     Solenoid shoot = new Solenoid(1);
  25.     Solenoid lift1 = new Solenoid(2);
  26.  
  27.    
  28.     /**
  29.      * This function is run when the robot is first started up and should be
  30.      * used for any initialization code.
  31.      */
  32.     public void robotInit() {
  33.     //----------------Changes below this line-------------------------------
  34.         //If the robot ends up backwards switch the next two lines for the two below them
  35.         motors.setInvertedMotor(MotorType.kFrontLeft, true);
  36.         motors.setInvertedMotor(MotorType.kRearLeft, true);
  37.         motors.setInvertedMotor(MotorType.kFrontRight, true);
  38.         motors.setInvertedMotor(MotorType.kRearRight, true);
  39.     //----------------Changes above this line-------------------------------
  40.         c.start();
  41.         d.start();
  42.     }
  43.  
  44.     /**
  45.      * This function is called periodically during autonomous
  46.      */
  47.     public void autonomousPeriodic() {
  48.  
  49.     }
  50.  
  51.     /**
  52.      * This function is called periodically during operator control
  53.      */
  54.     public void teleopPeriodic() {
  55.        
  56.         // Sebastian originally told us the cannon would be lifted with motors...
  57.         /*motors.arcadeDrive(gamepad.getRawAxis(1), gamepad.getRawAxis(4));
  58.         // 'y' button
  59.         if (gamepad.getRawButton(4)){
  60.             cannonLift.set(0.5);
  61.         }
  62.         // 'a' button
  63.         else if (gamepad.getRawButton(1)){
  64.             cannonLift.set(-0.5);
  65.         }
  66.         else{
  67.             cannonLift.set(0);
  68.         }*/
  69.        
  70.         motors.arcadeDrive(gamepad.getRawAxis(1), gamepad.getRawAxis(4));
  71.         // 'y' button; lift cannon
  72.         if (gamepad.getRawButton(4)){
  73.             lift1.set(true);
  74.             shoot.set(false);
  75.         }
  76.         // 'a' button; shoot cannon
  77.         else if (gamepad.getRawButton(1)){
  78.  
  79.             lift1.set(false);
  80.             shoot.set(true);
  81.         }
  82.     // do nothing?
  83.         else{
  84.             lift2.set(false);
  85.             lift1.set(false);
  86.             shoot.set(false);
  87.         }
  88.        
  89.     }
  90.    
  91.     /**
  92.      * This function is called periodically during test mode
  93.      */
  94.     public void testPeriodic() {
  95.    
  96.     }
  97.    
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement