Advertisement
Guest User

Drive Train Mk 2

a guest
Feb 21st, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.53 KB | None | 0 0
  1. package org.usfirst.frc.team4827.robot;
  2.  
  3. import edu.wpi.first.wpilibj.IterativeRobot;
  4. import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
  5. import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
  6. import edu.wpi.first.wpilibj.Joystick;
  7. import edu.wpi.first.wpilibj.RobotDrive;
  8. import edu.wpi.first.wpilibj.*;
  9. import edu.wpi.first.wpilibj.Talon;
  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.    
  20.     RobotDrive myDrive;
  21.     Joystick left, right;
  22.     Joystick button;
  23.     Victor lift=new Victor(5);
  24.     Talon shooter=new Talon(6);
  25.     Talon picker=new Talon(7);
  26.     XboxController xbox;
  27.  
  28.     final String defaultAuto = "Default";
  29.     final String customAuto = "My Auto";
  30.     String autoSelected;
  31.     SendableChooser<String> chooser = new SendableChooser<>();
  32.  
  33.     /**
  34.      * This function is run when the robot is first started up and should be
  35.      * used for any initialization code.
  36.      */
  37.     @Override
  38.     public void robotInit() {
  39.         myDrive = new RobotDrive(0,1,2, 3);
  40.                
  41.         left = new Joystick(0);
  42.        
  43.         //XboxController xbox = new XboxController(1);
  44.         right = new Joystick(1);
  45.    
  46.            
  47.         chooser.addDefault("Default Auto", defaultAuto);
  48.         chooser.addObject("My Auto", customAuto);
  49.         SmartDashboard.putData("Auto choices", chooser);
  50.     }
  51.    
  52.     /**
  53.      * This autonomous (along with the chooser code above) shows how to select
  54.      * between different autonomous modes using the dashboard. The sendable
  55.      * chooser code works with the Java SmartDashboard. If you prefer the
  56.      * LabVIEW Dashboard, remove all of the chooser code and uncomment the
  57.      * getString line to get the auto name from the text box below the Gyro
  58.      *
  59.      * You can add additional auto modes by adding additional comparisons to the
  60.      * switch structure below with additional strings. If using the
  61.      * SendableChooser make sure to add them to the chooser code above as well.
  62.      */
  63.     @Override
  64.     public void autonomousInit() {
  65.         autoSelected = chooser.getSelected();
  66.         // autoSelected = SmartDashboard.getString("Auto Selector",
  67.         // defaultAuto);
  68.         System.out.println("Auto selected: " + autoSelected);
  69.     }
  70.  
  71.     /**
  72.      * This function is called periodically during autonomous
  73.      */
  74.     @Override
  75.     public void autonomousPeriodic() {
  76.         switch (autoSelected) {
  77.         case customAuto:
  78.             // Put custom auto code here
  79.             break;
  80.         case defaultAuto:
  81.         default:
  82.             // Put default auto code here
  83.             break;
  84.         }
  85.     }
  86.    
  87.     //public void operatorControl() {
  88.         //while (isOperatorControl() && isEnabled()) {
  89.             //myDrive.tankDrive(left, right);;
  90.             //Timer.delay(0.01);
  91. //      }
  92.     //}
  93.    
  94.     /**
  95.      * This function is called periodically during operator control
  96.      */
  97.     @Override
  98.     public void teleopPeriodic() {
  99.         while (isOperatorControl()&&isEnabled()){
  100.             myDrive.tankDrive(left, right);//left.getAxis(Joystick.AxisType.kY), left.getAxis(Joystick.AxisType.kX));
  101.            
  102.                 if(left.getRawButton(3)){
  103.                     lift.set(0.5);
  104.                 }else{ lift.set(0.0);
  105.                 }
  106.                
  107.                 if(left.getRawButton(1)){
  108.                     picker.set(0.5);
  109.                 }else{ picker.set(0.0);
  110.                
  111.                 //if(left.getRawAxis(3)){
  112.                     //shooter.set(1.0);
  113.                 //}else{ shooter.set(0.0);
  114.                
  115.                 }
  116.                
  117.                 }
  118.             }  
  119.         //}
  120.  
  121.     /**
  122.      * This function is called periodically during test mode
  123.      */
  124.     @Override
  125.     public void testPeriodic() {
  126.     }
  127. }
  128. //}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement