Add camera, change to arcade drive, front chooser only, minor driving fixes
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / Robot.java
index 7678a7289cc4506c66670c42418b5292fa9a0ef5..2b58d19d22d5f41dfce87d95c7ab1dd98b0fc04c 100644 (file)
@@ -1,14 +1,16 @@
 package org.usfirst.frc.team3501.robot;
 
 import org.usfirst.frc.team3501.robot.commands.driving.SetLowGear;
-import org.usfirst.frc.team3501.robot.commands.intakearm.MoveIntakeArm;
-import org.usfirst.frc.team3501.robot.commands.shooter.ResetCatapult;
+import org.usfirst.frc.team3501.robot.commands.driving.TimeDrive;
 import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
 import org.usfirst.frc.team3501.robot.subsystems.IntakeArm;
 import org.usfirst.frc.team3501.robot.subsystems.Shooter;
 
+import edu.wpi.first.wpilibj.CameraServer;
 import edu.wpi.first.wpilibj.IterativeRobot;
 import edu.wpi.first.wpilibj.command.Scheduler;
+import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
+import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
 
 public class Robot extends IterativeRobot {
   public static OI oi;
@@ -16,6 +18,10 @@ public class Robot extends IterativeRobot {
   public static Shooter shooter;
   public static IntakeArm intakeArm;
 
+  // Sendable Choosers send a drop down menu to the Smart Dashboard.
+  private static SendableChooser frontChooser;
+  private static CameraServer camera;
+
   @Override
   public void robotInit() {
     driveTrain = new DriveTrain();
@@ -23,11 +29,39 @@ public class Robot extends IterativeRobot {
     intakeArm = new IntakeArm();
 
     oi = new OI();
+
+    initializeSendableChooser();
+    addFrontChooserOptions();
+    sendSendableChooserToSmartDashboard();
+
+    camera = CameraServer.getInstance();
+    camera.setQuality(50);
+    camera.startAutomaticCapture("cam0");
+  }
+
+  private void initializeSendableChooser() {
+    frontChooser = new SendableChooser();
+  }
+
+  private void addFrontChooserOptions() {
+    frontChooser.addDefault("Intake", false);
+    frontChooser.addObject("Shooter", true);
+  }
+
+  private void sendSendableChooserToSmartDashboard() {
+    SmartDashboard.putData("PositionChooser", frontChooser);
   }
 
   @Override
   public void autonomousInit() {
-    Scheduler.getInstance().run();
+    // get options chosen from drop down menu
+    boolean flip = (boolean) frontChooser.getSelected();
+
+    if (flip) {
+      driveTrain.toggleFlipped();
+    }
+
+    Scheduler.getInstance().add(new TimeDrive(4, .7));
   }
 
   @Override
@@ -37,13 +71,7 @@ public class Robot extends IterativeRobot {
 
   @Override
   public void teleopInit() {
-    Scheduler.getInstance().add(new SetLowGear()); // Start each match in low
-                                                   // gear
-    Scheduler.getInstance().add(new ResetCatapult()); // Reset catapult at start
-                                                      // of each match.
-
-    Scheduler.getInstance().add(new MoveIntakeArm(Constants.IntakeArm.EXTEND));
-    // Start testing with intake arm extended TODO remove this
+    Scheduler.getInstance().add(new SetLowGear());
   }
 
   @Override