oops tab -> spaces
[ozzloy@gmail.com/3501-spark-go] / src / org / usfirst / frc / team3501 / robot / Robot.java
index 68770bb4819d35f1debc60c463d8c1aade4076d2..c9c43d42f118444400680bb701d1cc9ceea5fdf0 100644 (file)
@@ -5,33 +5,53 @@ import edu.wpi.first.wpilibj.IterativeRobot;
 import edu.wpi.first.wpilibj.command.Command;
 import edu.wpi.first.wpilibj.command.Scheduler;
 import edu.wpi.first.wpilibj.livewindow.LiveWindow;
+import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
+import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
 
+import org.usfirst.frc.team3501.robot.autons.*;
 import org.usfirst.frc.team3501.robot.commands.*;
 import org.usfirst.frc.team3501.robot.subsystems.*;
+import org.usfirst.frc.team3501.util.AutonData;
 
 public class Robot extends IterativeRobot {
 
-       public static final Drivetrain drivetrain = new Drivetrain();
-       public static final Arm               arm = new Arm();
-       public static final Claw             claw = new Claw();
+    public static Drivetrain drivetrain;
+    public static Arm arm;
+    public static Claw claw;
 
-       public static OI oi;
+    public static Pneumatics pneumatics;
 
-    Command autonomousCommand;
+    public static OI oi;
+
+    public static AutonData autonData;
+
+    private SendableChooser autonChooser;
+    private Command autonomousCommand;
 
     public void robotInit() {
-               oi = new OI();
+        drivetrain = new Drivetrain();
+        arm        = new Arm();
+        claw       = new Claw();
+
+        pneumatics = new Pneumatics();
+
+        autonData = new AutonData();
+
+        oi = new OI();
 
-               double time = 1.2;
-               double speed = 0.7;
-        autonomousCommand = new DriveForward(time, speed);
+        chooseAuto();
     }
 
-       public void disabledPeriodic() {
-               Scheduler.getInstance().run();
-       }
+    public void disabledPeriodic() {
+        Scheduler.getInstance().run();
+    }
 
     public void autonomousInit() {
+        schedule(new TurnOnCompressor());
+
+        autonData.update();
+
+        autonomousCommand = (Command) autonChooser.getSelected();
         autonomousCommand.start();
     }
 
@@ -40,16 +60,31 @@ public class Robot extends IterativeRobot {
     }
 
     public void teleopInit() {
-        autonomousCommand.cancel();
+        schedule(new TurnOnCompressor());
+
+        if (autonomousCommand != null)
+            autonomousCommand.cancel();
     }
 
     public void teleopPeriodic() {
         Scheduler.getInstance().run();
-
-
     }
 
     public void testPeriodic() {
         LiveWindow.run();
     }
+
+    private void chooseAuto() {
+        autonChooser = new SendableChooser();
+
+        autonChooser.addDefault("Pick up container", new ContainerOverStep());
+        autonChooser.addObject("Drive over step",    new DriveOverStep());
+        autonChooser.addObject("Drive past step",    new DrivePastStep());
+
+        SmartDashboard.putData("Auto Mode", autonChooser);
+    }
+
+    private void schedule(Command c) {
+        Scheduler.getInstance().add(c);
+    }
 }