everything done except mapping buttons to actions
authorLogan Howard <logan@oflogan.com>
Fri, 17 Apr 2015 03:00:51 +0000 (20:00 -0700)
committerLogan Howard <logan@oflogan.com>
Fri, 17 Apr 2015 03:00:51 +0000 (20:00 -0700)
src/org/usfirst/frc/team3501/robot/OI.java
src/org/usfirst/frc/team3501/robot/Robot.java
src/org/usfirst/frc/team3501/robot/RobotMap.java
src/org/usfirst/frc/team3501/robot/commands/DriveWithJoysticks.java
src/org/usfirst/frc/team3501/robot/commands/MoveArm.java [new file with mode: 0644]
src/org/usfirst/frc/team3501/robot/subsystems/Arm.java
src/org/usfirst/frc/team3501/robot/subsystems/Drivetrain.java
src/org/usfirst/frc/team3501/robot/subsystems/Pneumatics.java

index 0b8fa0755904bfe29ecefae66038f4e5e7bec95d..6a245583c57421768c4c10482d3803cac2d228f4 100644 (file)
@@ -3,7 +3,7 @@ package org.usfirst.frc.team3501.robot;
 import org.usfirst.frc.team3501.robot.commands.*;
 
 public class OI {
-    public Joystick left, right;
+    private Joystick left, right;
 
     public OI() {
         left  = new Joystick(RobotMap.LEFT_JOYSTICK_PORT);
@@ -13,11 +13,15 @@ public class OI {
         right.whenReleased(1, new OpenClaw());
     }
 
-    public double getForward() {
+    public double getForwardL() {
+        return left.getY();
+    }
+
+    public double getForwardR() {
         return right.getY();
     }
 
-    public double getTwist() {
+    public double getTwistR() {
         return right.getTwist();
     }
 }
index b5ac5b7a98a13dd563a37dfbe2e9e504cd165755..23a43b7812daab2e2bfe1d188ebfcb025f998b7c 100644 (file)
@@ -13,9 +13,11 @@ import org.usfirst.frc.team3501.robot.subsystems.*;
 
 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 Pneumatics pneumatics;
 
        public static OI oi;
 
@@ -26,6 +28,12 @@ public class Robot extends IterativeRobot {
     public void robotInit() {
                oi = new OI();
 
+               drivetrain = new Drivetrain();
+               arm        = new Arm();
+               claw       = new Claw();
+
+               pneumatics = new Pneumatics();
+
                chooseAuto();
     }
 
@@ -34,6 +42,8 @@ public class Robot extends IterativeRobot {
        }
 
     public void autonomousInit() {
+        pneumatics.start();
+
         autonomousCommand = (Command) autoChooser.getSelected();
         autonomousCommand.start();
     }
@@ -43,6 +53,8 @@ public class Robot extends IterativeRobot {
     }
 
     public void teleopInit() {
+        pneumatics.start();
+
         autonomousCommand.cancel();
     }
 
@@ -54,6 +66,10 @@ public class Robot extends IterativeRobot {
         LiveWindow.run();
     }
 
+    public void disabledInit() {
+        pneumatics.stop();
+    }
+
     private void chooseAuto() {
         autoChooser = new SendableChooser();
 
index bfb2bea698ec249228da2ef910e76660268ebce6..3ce51bf176aade4e46c2c6cc5647fabbb020ba1e 100644 (file)
@@ -3,27 +3,27 @@ package org.usfirst.frc.team3501.robot;
 import edu.wpi.first.wpilibj.DoubleSolenoid.Value;
 
 public class RobotMap {
-    // Driver Station
+    // driver station
     public static final int LEFT_JOYSTICK_PORT = 0, RIGHT_JOYSTICK_PORT = 1;
 
     public static final double MIN_DRIVE_JOYSTICK_INPUT = 0.1,
                                MIN_ARM_JOYSTICK_INPUT   = 0.1;
 
-    // Drivetrain
+    // drivetrain
     public static final int FRONT_LEFT_ADDRESS = 4, FRONT_RIGHT_ADDRESS = 5,
                             REAR_LEFT_ADDRESS  = 3, REAR_RIGHT_ADDRESS  = 6;
 
     public static final double MAX_DRIVE_SPEED = 0.7;
 
-    // Claw
+    // claw
     public static final int CLAW_FORWARD_CHANNEL = 0, CLAW_REVERSE_CHANNEL = 1;
 
     public static final Value OPEN = Value.kForward, CLOSED = Value.kReverse;
 
-    // Arm
+    // arm
     public static final int LEFT_WINCH_ADDRESS = 2, RIGHT_WINCH_ADDRESS = 7;
 
-    // Auton
+    // auton
     public static final double OVER_STEP_TIME = 1.2, OVER_STEP_SPEED = 0.7,
                                PAST_STEP_TIME = 1.5, PAST_STEP_SPEED = 0.5;
 }
index 500bad953e33000ad9c29fa9a890c64d29ed0f86..cda6cdd7f35cd96a9d6d3592a0f63c33d7634aac 100644 (file)
@@ -8,7 +8,7 @@ public class DriveWithJoysticks extends CommandBase {
     }
 
     protected void execute() {
-        drivetrain.drive(oi.getForward(), oi.getTwist());
+        drivetrain.drive(oi.getForwardR(), oi.getTwistR());
     }
 
     protected boolean isFinished() {
diff --git a/src/org/usfirst/frc/team3501/robot/commands/MoveArm.java b/src/org/usfirst/frc/team3501/robot/commands/MoveArm.java
new file mode 100644 (file)
index 0000000..f0865af
--- /dev/null
@@ -0,0 +1,17 @@
+package org.usfirst.frc.team3501.robot.commands;
+
+public class MoveArm extends CommandBase {
+
+    public MoveArm() {
+        super("MoveArm");
+        requires(arm);
+    }
+
+    protected void execute() {
+        arm.setFromJoystick(oi.getForwardL());
+    }
+
+    protected boolean isFinished() {
+        return false;
+    }
+}
index 8cfcf9b6411a646b9caaa78aae909fda25292964..f42de1dfa0670af331e3521b4d5574f4c53efdf5 100644 (file)
@@ -1,6 +1,7 @@
 package org.usfirst.frc.team3501.robot.subsystems;
 
 import org.usfirst.frc.team3501.robot.RobotMap;
+import org.usfirst.frc.team3501.robot.commands.MoveArm;
 
 import edu.wpi.first.wpilibj.CANJaguar;
 import edu.wpi.first.wpilibj.command.Subsystem;
@@ -19,6 +20,10 @@ public class Arm extends Subsystem {
         right.set(speed);
     }
 
+    public void setFromJoystick(double speed) {
+        set(getSpeedFromJoystick(speed));
+    }
+
     public void moveLeft(double speed) {
         left.set(speed);
         right.set(0);
@@ -36,6 +41,7 @@ public class Arm extends Subsystem {
         return speed;
     }
 
-    public void initDefaultCommand() {}
+    public void initDefaultCommand() {
+        setDefaultCommand(new MoveArm());
+    }
 }
-
index 5dd39abb4a716f1bf8a7729b57696371281ec823..72428e4a7ca5e757f42529fbac5adc98c906e5f4 100644 (file)
@@ -51,4 +51,3 @@ public class Drivetrain extends Subsystem {
         setDefaultCommand(new DriveWithJoysticks());
     }
 }
-
index 8a831d5bfd96dcd9c2f7aff9debf622f14cb8723..270758ed4f6d220fb2007017123e2a9d07cadf6b 100644 (file)
@@ -21,4 +21,3 @@ public class Pneumatics extends Subsystem {
 
     public void initDefaultCommand() {}
 }
-