right.whenReleased(1, new OpenClaw());
}
- public double getForwardSpeed() {
+ public double getForward() {
return right.getY();
}
- public double getTwistSpeed() {
+ public double getTwist() {
return right.getTwist();
}
}
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.commands.*;
+import org.usfirst.frc.team3501.robot.autons.*;
import org.usfirst.frc.team3501.robot.subsystems.*;
public class Robot extends IterativeRobot {
public static OI oi;
- Command autonomousCommand;
+ private SendableChooser autoChooser;
+
+ private Command autonomousCommand;
public void robotInit() {
oi = new OI();
- double time = 1.2;
- double speed = 0.7;
- autonomousCommand = new DriveForward(time, speed);
+ chooseAuto();
}
public void disabledPeriodic() {
}
public void autonomousInit() {
+ autonomousCommand = (Command) autoChooser.getSelected();
autonomousCommand.start();
}
public void teleopPeriodic() {
Scheduler.getInstance().run();
-
-
}
public void testPeriodic() {
LiveWindow.run();
}
+
+ private void chooseAuto() {
+ autoChooser = new SendableChooser();
+
+ autoChooser.addDefault("Drive over step", new DriveOverStep());
+ autoChooser.addObject("Drive past step", new DrivePastStep());
+
+ SmartDashboard.putData("Auto Mode", autoChooser);
+ }
}
import edu.wpi.first.wpilibj.DoubleSolenoid.Value;
public class RobotMap {
+ // Driver Station
public static final int LEFT_JOYSTICK_PORT = 0, RIGHT_JOYSTICK_PORT = 1;
- public static final double MIN_DRIVE_JOYSTICK_INPUT = 0.1;
+ public static final double MIN_DRIVE_JOYSTICK_INPUT = 0.1,
+ MIN_ARM_JOYSTICK_INPUT = 0.1;
+ // 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
public static final int CLAW_FORWARD_CHANNEL = 0, CLAW_REVERSE_CHANNEL = 1;
public static final Value OPEN = Value.kForward, CLOSED = Value.kReverse;
+
+ // Arm
+ public static final int LEFT_WINCH_ADDRESS = 2, RIGHT_WINCH_ADDRESS = 7;
+
+ // 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;
}
--- /dev/null
+package org.usfirst.frc.team3501.robot.autons;
+
+import org.usfirst.frc.team3501.robot.RobotMap;
+import org.usfirst.frc.team3501.robot.commands.CommandBase;
+
+public class DriveOverStep extends CommandBase {
+
+ private double speed;
+
+ public DriveOverStep() {
+ super("DriveOverStep");
+ requires(drivetrain);
+
+ setTimeout(RobotMap.OVER_STEP_TIME);
+ this.speed = RobotMap.OVER_STEP_SPEED;
+ }
+
+ protected void execute() {
+ drivetrain.goForward(speed);
+ }
+
+ protected boolean isFinished() {
+ return isTimedOut();
+ }
+
+ protected void end() {
+ drivetrain.stop();
+ }
+}
--- /dev/null
+package org.usfirst.frc.team3501.robot.autons;
+
+import org.usfirst.frc.team3501.robot.RobotMap;
+import org.usfirst.frc.team3501.robot.commands.CommandBase;
+
+public class DrivePastStep extends CommandBase {
+
+ private double speed;
+
+ public DrivePastStep() {
+ super("DrivePastStep");
+ requires(drivetrain);
+
+ setTimeout(RobotMap.PAST_STEP_TIME);
+ this.speed = RobotMap.PAST_STEP_SPEED;
+ }
+
+ protected void execute() {
+ drivetrain.goForward(speed);
+ }
+
+ protected boolean isFinished() {
+ return isTimedOut();
+ }
+
+ protected void end() {
+ drivetrain.stop();
+ }
+}
+++ /dev/null
-package org.usfirst.frc.team3501.robot.commands;
-
-public class DriveForward extends CommandBase {
-
- private double speed;
-
- public DriveForward(double time, double speed) {
- super("DriveForward");
- requires(drivetrain);
-
- setTimeout(time);
- this.speed = speed;
- }
-
- protected void execute() {
- drivetrain.goForward(speed);
- }
-
- protected boolean isFinished() {
- return isTimedOut();
- }
-
- protected void end() {
- drivetrain.stop();
- }
-}
}
protected void execute() {
- drivetrain.drive(oi.getForwardSpeed(), oi.getTwistSpeed());
+ drivetrain.drive(oi.getForward(), oi.getTwist());
}
protected boolean isFinished() {
package org.usfirst.frc.team3501.robot.subsystems;
+import org.usfirst.frc.team3501.robot.RobotMap;
+
+import edu.wpi.first.wpilibj.CANJaguar;
import edu.wpi.first.wpilibj.command.Subsystem;
-/**
- *
- */
public class Arm extends Subsystem {
-
- // Put methods for controlling this subsystem
- // here. Call these from Commands.
- public void initDefaultCommand() {
- // Set the default command for a subsystem here.
- //setDefaultCommand(new MySpecialCommand());
+ private CANJaguar left, right;
+
+ public Arm() {
+ left = new CANJaguar(RobotMap.LEFT_WINCH_ADDRESS);
+ right = new CANJaguar(RobotMap.RIGHT_WINCH_ADDRESS);
+ }
+
+ public void set(double speed) {
+ left.set(-speed);
+ right.set(speed);
+ }
+
+ public void moveLeft(double speed) {
+ left.set(speed);
+ right.set(0);
}
+
+ public void moveRight(double speed) {
+ right.set(speed);
+ left.set(0);
+ }
+
+ public double getSpeedFromJoystick(double speed) {
+ if (Math.abs(speed) < RobotMap.MIN_ARM_JOYSTICK_INPUT)
+ speed = 0;
+
+ return speed;
+ }
+
+ public void initDefaultCommand() {}
}
package org.usfirst.frc.team3501.robot.subsystems;
import org.usfirst.frc.team3501.robot.RobotMap;
-import org.usfirst.frc.team3501.robot.commands.*;
import edu.wpi.first.wpilibj.DoubleSolenoid;
import edu.wpi.first.wpilibj.command.Subsystem;
public class Claw extends Subsystem {
- private final DoubleSolenoid piston;
+ private DoubleSolenoid piston;
public Claw() {
piston = new DoubleSolenoid(
RobotMap.CLAW_FORWARD_CHANNEL, RobotMap.CLAW_REVERSE_CHANNEL);
}
- public void initDefaultCommand() {
- setDefaultCommand(new CloseClaw());
- }
-
public void open() {
piston.set(RobotMap.OPEN);
}
public void close() {
piston.set(RobotMap.CLOSED);
}
-}
+ public void initDefaultCommand() {}
+}
package org.usfirst.frc.team3501.robot.subsystems;
import org.usfirst.frc.team3501.robot.RobotMap;
+import org.usfirst.frc.team3501.robot.commands.DriveWithJoysticks;
import edu.wpi.first.wpilibj.CANJaguar;
import edu.wpi.first.wpilibj.RobotDrive;
public class Drivetrain extends Subsystem {
- RobotDrive robotDrive;
+ private RobotDrive robotDrive;
public Drivetrain() {
CANJaguar frontLeft = new CANJaguar(RobotMap.FRONT_LEFT_ADDRESS);
return (x + Math.signum(x) * Math.sqrt(Math.abs(x))) / 2;
}
- public void initDefaultCommand() {}
+ public void initDefaultCommand() {
+ setDefaultCommand(new DriveWithJoysticks());
+ }
}
--- /dev/null
+package org.usfirst.frc.team3501.robot.subsystems;
+
+import edu.wpi.first.wpilibj.Compressor;
+import edu.wpi.first.wpilibj.command.Subsystem;
+
+public class Pneumatics extends Subsystem {
+
+ private Compressor compressor;
+
+ public Pneumatics() {
+ compressor = new Compressor();
+ }
+
+ public void start() {
+ compressor.start();
+ }
+
+ public void stop() {
+ compressor.stop();
+ }
+
+ public void initDefaultCommand() {}
+}
+