--- /dev/null
+*.pydevproject
+.metadata
+.gradle
+bin/
+tmp/
+*.tmp
+*.bak
+*.swp
+*~.nib
+local.properties
+.settings/
+.loadpath
+
+# Eclipse Core
+.project
+
+# External tool builders
+.externalToolBuilders/
+
+# Locally stored "Eclipse launch configurations"
+*.launch
+
+# CDT-specific
+.cproject
+
+# JDT-specific (Eclipse Java Development Tools)
+.classpath
+
+# PDT-specific
+.buildpath
+
+# sbteclipse plugin
+.target
+
+# TeXlipse plugin
+.texlipse
+
+# custom stuff that seems unnecessary
+build/
+dist/
+sysProps.xml
--- /dev/null
+# Project specific information
+package=org.usfirst.frc.team3501.robot
+robot.class=${package}.Robot
+simulation.world.file=/usr/share/frcsim/worlds/GearsBotDemo.world
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project name="FRC Deployment" default="deploy">
+
+ <!--
+ The following properties can be defined to override system level
+ settings. These should not be touched unless you know what you're
+ doing. The primary use is to override the wpilib version when
+ working with older robots that can't compile with the latest
+ libraries.
+ -->
+
+ <!-- By default the system version of WPI is used -->
+ <!-- <property name="version" value=""/> -->
+
+ <!-- By default the system team number is used -->
+ <!-- <property name="team-number" value=""/> -->
+
+ <!-- By default the target is set to 10.TE.AM.2 -->
+ <!-- <property name="target" value=""/> -->
+
+ <!-- Any other property in build.properties can also be overridden. -->
+
+ <property file="${user.home}/wpilib/wpilib.properties"/>
+ <property file="build.properties"/>
+ <property file="${user.home}/wpilib/java/${version}/ant/build.properties"/>
+
+ <import file="${wpilib.ant.dir}/build.xml"/>
+
+</project>
--- /dev/null
+package org.usfirst.frc.team3501.robot;
+
+import java.util.HashMap;
+import java.util.stream.IntStream;
+
+import edu.wpi.first.wpilibj.buttons.JoystickButton;
+import edu.wpi.first.wpilibj.command.Command;
+
+public class Joystick extends edu.wpi.first.wpilibj.Joystick {
+
+ private HashMap<Integer, JoystickButton> buttons;
+
+ public Joystick(int port) {
+ super(port);
+
+ IntStream.rangeClosed(1, 12).forEach((b) -> {
+ buttons.put(b, new JoystickButton(this, b));
+ });
+ }
+
+ public void whenPressed(int button, Command c) {
+ buttons.get(button).whenPressed(c);
+ }
+
+ public void whenReleased(int button, Command c) {
+ buttons.get(button).whenReleased(c);
+ }
+}
--- /dev/null
+package org.usfirst.frc.team3501.robot;
+
+import org.usfirst.frc.team3501.robot.commands.*;
+
+public class OI {
+ public Joystick left, right;
+
+ public OI() {
+ left = new Joystick(RobotMap.LEFT_JOYSTICK_PORT);
+ right = new Joystick(RobotMap.RIGHT_JOYSTICK_PORT);
+
+ right.whenPressed(1, new CloseClaw());
+ right.whenReleased(1, new OpenClaw());
+ }
+
+ public double getForwardSpeed() {
+ return right.getY();
+ }
+
+ public double getTwistSpeed() {
+ return right.getTwist();
+ }
+}
--- /dev/null
+
+package org.usfirst.frc.team3501.robot;
+
+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 org.usfirst.frc.team3501.robot.commands.*;
+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 OI oi;
+
+ Command autonomousCommand;
+
+ public void robotInit() {
+ oi = new OI();
+
+ double time = 1.2;
+ double speed = 0.7;
+ autonomousCommand = new DriveForward(time, speed);
+ }
+
+ public void disabledPeriodic() {
+ Scheduler.getInstance().run();
+ }
+
+ public void autonomousInit() {
+ autonomousCommand.start();
+ }
+
+ public void autonomousPeriodic() {
+ Scheduler.getInstance().run();
+ }
+
+ public void teleopInit() {
+ autonomousCommand.cancel();
+ }
+
+ public void teleopPeriodic() {
+ Scheduler.getInstance().run();
+
+
+ }
+
+ public void testPeriodic() {
+ LiveWindow.run();
+ }
+}
--- /dev/null
+package org.usfirst.frc.team3501.robot;
+
+import edu.wpi.first.wpilibj.DoubleSolenoid.Value;
+
+public class RobotMap {
+ 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 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;
+
+ public static final int CLAW_FORWARD_CHANNEL = 0, CLAW_REVERSE_CHANNEL = 1;
+
+ public static final Value OPEN = Value.kForward, CLOSED = Value.kReverse;
+}
--- /dev/null
+package org.usfirst.frc.team3501.robot.commands;
+
+public class CloseClaw extends CommandBase {
+
+ public CloseClaw() {
+ super("CloseClaw");
+ requires(claw);
+ }
+
+ protected void initialize() {
+ claw.close();
+ }
+
+ protected boolean isFinished() {
+ return true;
+ }
+}
--- /dev/null
+package org.usfirst.frc.team3501.robot.commands;
+
+import org.usfirst.frc.team3501.robot.OI;
+import org.usfirst.frc.team3501.robot.Robot;
+import org.usfirst.frc.team3501.robot.subsystems.*;
+
+import edu.wpi.first.wpilibj.command.Command;
+
+public abstract class CommandBase extends Command {
+
+ protected static OI oi;
+
+ protected static Drivetrain drivetrain;
+ protected static Arm arm;
+ protected static Claw claw;
+
+ public CommandBase(String commandName) {
+ super(commandName);
+
+ oi = Robot.oi;
+
+ drivetrain = Robot.drivetrain;
+ arm = Robot.arm;
+ claw = Robot.claw;
+ }
+
+ protected void initialize() {}
+
+ protected void execute() {}
+
+ protected void end() {}
+
+ protected void interrupted() {}
+}
--- /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();
+ }
+}
--- /dev/null
+package org.usfirst.frc.team3501.robot.commands;
+
+public class DriveWithJoysticks extends CommandBase {
+
+ public DriveWithJoysticks() {
+ super("DriveWithJoysticks");
+ requires(drivetrain);
+ }
+
+ protected void execute() {
+ drivetrain.drive(oi.getForwardSpeed(), oi.getTwistSpeed());
+ }
+
+ protected boolean isFinished() {
+ return false;
+ }
+}
--- /dev/null
+package org.usfirst.frc.team3501.robot.commands;
+
+public class OpenClaw extends CommandBase {
+
+ public OpenClaw() {
+ super("OpenClaw");
+ requires(claw);
+ }
+
+ protected void initialize() {
+ claw.open();
+ }
+
+ protected boolean isFinished() {
+ return true;
+ }
+}
--- /dev/null
+package org.usfirst.frc.team3501.robot.subsystems;
+
+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());
+ }
+}
+
--- /dev/null
+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;
+
+ 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);
+ }
+}
+
--- /dev/null
+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.RobotDrive;
+import edu.wpi.first.wpilibj.command.Subsystem;
+
+public class Drivetrain extends Subsystem {
+
+ RobotDrive robotDrive;
+
+ public Drivetrain() {
+ CANJaguar frontLeft = new CANJaguar(RobotMap.FRONT_LEFT_ADDRESS);
+ CANJaguar frontRight = new CANJaguar(RobotMap.FRONT_RIGHT_ADDRESS);
+ CANJaguar rearLeft = new CANJaguar(RobotMap.REAR_LEFT_ADDRESS);
+ CANJaguar rearRight = new CANJaguar(RobotMap.REAR_RIGHT_ADDRESS);
+
+ robotDrive = new RobotDrive(
+ frontLeft, rearLeft,
+ frontRight, rearRight);
+ }
+
+ public void drive(double forward, double twist) {
+ if (Math.abs(forward) < RobotMap.MIN_DRIVE_JOYSTICK_INPUT)
+ forward = 0;
+ if (Math.abs(twist) < RobotMap.MIN_DRIVE_JOYSTICK_INPUT)
+ twist = 0;
+
+ robotDrive.arcadeDrive(
+ RobotMap.MAX_DRIVE_SPEED * adjust(forward),
+ RobotMap.MAX_DRIVE_SPEED * adjust(twist),
+ false);
+ }
+
+ public void goForward(double speed) {
+ robotDrive.arcadeDrive(speed, 0);
+ }
+
+ public void stop() {
+ robotDrive.arcadeDrive(0, 0);
+ }
+
+ // output is avg of `x` and `sqrt(x)`
+ private double adjust(double x) {
+ return (x + Math.signum(x) * Math.sqrt(Math.abs(x))) / 2;
+ }
+
+ public void initDefaultCommand() {}
+}
+