From: David Date: Fri, 20 Nov 2015 18:37:17 +0000 (-0800) Subject: Merge branch 'master' of challenge-bot.com:repos/3501/2015-FRC-Spark X-Git-Url: http://challenge-bot.com/repos/?a=commitdiff_plain;h=HEAD;hp=c7a54f8e92507c36aeefbd99783e0811402b34b5;p=3501%2F2015-FRC-Spark Merge branch 'master' of challenge-bot.com:repos/3501/2015-FRC-Spark --- diff --git a/.gitignore b/.gitignore index 0686dad..dc8e203 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,10 @@ +<<<<<<< HEAD # -*- mode: gitignore; -*- *~ \#*\# .\#* +======= +>>>>>>> fb376f02820fc8dd8404759e2b45fa582969dc3e *.pydevproject .metadata .gradle @@ -46,4 +49,8 @@ local.properties .texlipse # STS (Spring Tool Suite) +<<<<<<< HEAD .springBeans +======= +.springBeans +>>>>>>> fb376f02820fc8dd8404759e2b45fa582969dc3e diff --git a/src/org/usfirst/frc3501/RiceCatRobot/OI.java b/src/org/usfirst/frc3501/RiceCatRobot/OI.java deleted file mode 100644 index e463ea3..0000000 --- a/src/org/usfirst/frc3501/RiceCatRobot/OI.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.usfirst.frc3501.RiceCatRobot; - -import org.usfirst.frc3501.RiceCatRobot.commands.ToggleClaw; -import org.usfirst.frc3501.RiceCatRobot.commands.ToggleCompressor; - -import edu.wpi.first.wpilibj.Joystick; -import edu.wpi.first.wpilibj.buttons.JoystickButton; - -public class OI { - public static Joystick leftJoystick; - public static Joystick rightJoystick; - public static JoystickButton trigger; - public static JoystickButton toggleCompressor; - public static JoystickButton toggleClaw; - - public OI() { - System.out.println("OI is open"); - leftJoystick = new Joystick(RobotMap.LEFT_STICK_PORT); - rightJoystick = new Joystick(RobotMap.RIGHT_STICK_PORT); - - trigger = new JoystickButton(rightJoystick, RobotMap.TRIGGER_PORT); - - toggleClaw = new JoystickButton(rightJoystick, RobotMap.TOGGLE_PORT); - toggleClaw.whenPressed(new ToggleClaw()); - - toggleCompressor = new JoystickButton(rightJoystick, - RobotMap.TOGGLE_COMPRESSOR_PORT); - toggleCompressor.whenPressed(new ToggleCompressor()); - - } -} diff --git a/src/org/usfirst/frc3501/RiceCatRobot/Robot.java b/src/org/usfirst/frc3501/RiceCatRobot/Robot.java deleted file mode 100644 index 0e4d934..0000000 --- a/src/org/usfirst/frc3501/RiceCatRobot/Robot.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.usfirst.frc3501.RiceCatRobot; - -import org.usfirst.frc3501.RiceCatRobot.subsystems.Arm; -import org.usfirst.frc3501.RiceCatRobot.subsystems.Claw; -import org.usfirst.frc3501.RiceCatRobot.subsystems.DriveTrain; - -import edu.wpi.first.wpilibj.Compressor; -import edu.wpi.first.wpilibj.IterativeRobot; -import edu.wpi.first.wpilibj.Timer; -import edu.wpi.first.wpilibj.command.Scheduler; - -public class Robot extends IterativeRobot { - static Timer timer; - public static OI oi; - public static DriveTrain driveTrain; - public static Arm arm; - public static Claw claw; - public static Compressor compressor; - - public void robotInit() { - RobotMap.init(); - driveTrain = new DriveTrain(); - arm = new Arm(); - claw = new Claw(); - oi = new OI(); - compressor = new Compressor(RobotMap.COMPRESSOR_PORT); - } - - public void autonomousInit() { - } - - public void autonomousPeriodic() { - Scheduler.getInstance().run(); - } - - public void teleopInit() { - System.out.println("running teleopInit"); - } - - public void teleopPeriodic() { - Scheduler.getInstance().run(); - - } - - public void operate() { - driveTrain - .arcadeDrive(OI.rightJoystick.getY(), OI.rightJoystick.getTwist()); - claw.doTriggerAction(); - if (OI.leftJoystick.getRawButton(8)) { - arm.setArmSpeeds(0.3); - } else if (OI.leftJoystick.getRawButton(9)) { - arm.setArmSpeeds(-0.3); - } else if (OI.leftJoystick.getRawButton(6)) { - arm.setLeft(0.3); - } else if (OI.leftJoystick.getRawButton(7)) { - arm.setLeft(-0.3); - } else if (OI.leftJoystick.getRawButton(11)) { - arm.setRight(-0.3); - } else if (OI.leftJoystick.getRawButton(10)) { - arm.setRight(0.3); - } - if (Math.abs(OI.leftJoystick.getY()) < 0.05) { - arm.setArmSpeeds(0); - - } else { - arm.fineTuneControl(OI.leftJoystick.getY()); - } - } -} diff --git a/src/org/usfirst/frc3501/RiceCatRobot/RobotMap.java b/src/org/usfirst/frc3501/RiceCatRobot/RobotMap.java deleted file mode 100644 index 7c6e996..0000000 --- a/src/org/usfirst/frc3501/RiceCatRobot/RobotMap.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.usfirst.frc3501.RiceCatRobot; - -import edu.wpi.first.wpilibj.DoubleSolenoid; -import edu.wpi.first.wpilibj.DoubleSolenoid.Value; - -/** - * The RobotMap is a mapping from the ports sensors and actuators are wired into - * to a variable name. This provides flexibility changing wiring, makes checking - * the wiring easier and significantly reduces the number of magic numbers - * floating around. - */ -public class RobotMap { - public final static int LEFT_STICK_PORT = 0, RIGHT_STICK_PORT = 1; - public final static int TRIGGER_PORT = 1, TOGGLE_PORT = 2, - TOGGLE_COMPRESSOR_PORT = 11; - public static final int DRIVE_FRONT_LEFT = 4, DRIVE_FRONT_RIGHT = 5, - DRIVE_REAR_LEFT = 3, DRIVE_REAR_RIGHT = 6; - public static final int DRIVE_LEFT_A = 3, DRIVE_LEFT_B = 4, - DRIVE_RIGHT_A = 2, DRIVE_RIGHT_B = 1; - - public static final double DISTANCE_PER_PULSE = - ((3.66 / 5.14) * 6 * Math.PI) / 256; - - public static final int ARM_LEFT = 2, ARM_RIGHT = 7; - public static final double ARM_HIGH_SPEED = 0.5, ARM_LOW_SPEED = 0.5; - - // Claw - public static final int SOLENOID_FORWARD = 0, SOLENOID_REVERSE = 1, - MODULE_NUMBER = 0; - public final static Value open = DoubleSolenoid.Value.kForward, - close = DoubleSolenoid.Value.kReverse; - public static double DRIVE_DEAD_ZONE = 0.25; - // Compressor - public static final int COMPRESSOR_PORT = 0; - - public static void init() { - } - - public static enum Direction { - LEFT, RIGHT, DOWN, UP, FORWARD, BACKWARD; - } -} diff --git a/src/org/usfirst/frc3501/RiceCatRobot/auton/MoveForwardFiveFt.java b/src/org/usfirst/frc3501/RiceCatRobot/auton/MoveForwardFiveFt.java new file mode 100644 index 0000000..a67740e --- /dev/null +++ b/src/org/usfirst/frc3501/RiceCatRobot/auton/MoveForwardFiveFt.java @@ -0,0 +1,15 @@ +package org.usfirst.frc3501.RiceCatRobot.auton; + +import org.usfirst.frc3501.RiceCatRobot.commands.MoveDistance; +import org.usfirst.frc3501.RiceCatRobot.robot.Robot; + +import edu.wpi.first.wpilibj.command.CommandGroup; + +public class MoveForwardFiveFt extends CommandGroup{ + + public MoveForwardFiveFt (){ + requires(Robot.driveTrain); + + addSequential(new MoveDistance(60, 0, 0.5)); + } +} diff --git a/src/org/usfirst/frc3501/RiceCatRobot/commands/CloseClaw.java b/src/org/usfirst/frc3501/RiceCatRobot/commands/CloseClaw.java index 2ace9ae..f26f6c3 100644 --- a/src/org/usfirst/frc3501/RiceCatRobot/commands/CloseClaw.java +++ b/src/org/usfirst/frc3501/RiceCatRobot/commands/CloseClaw.java @@ -2,7 +2,7 @@ package org.usfirst.frc3501.RiceCatRobot.commands; import edu.wpi.first.wpilibj.command.Command; -import org.usfirst.frc3501.RiceCatRobot.Robot; +import org.usfirst.frc3501.RiceCatRobot.robot.Robot; /** * diff --git a/src/org/usfirst/frc3501/RiceCatRobot/commands/DriveFor.java b/src/org/usfirst/frc3501/RiceCatRobot/commands/DriveFor.java index e247353..ee6fe26 100644 --- a/src/org/usfirst/frc3501/RiceCatRobot/commands/DriveFor.java +++ b/src/org/usfirst/frc3501/RiceCatRobot/commands/DriveFor.java @@ -1,7 +1,7 @@ package org.usfirst.frc3501.RiceCatRobot.commands; -import org.usfirst.frc3501.RiceCatRobot.Robot; -import org.usfirst.frc3501.RiceCatRobot.RobotMap.Direction; +import org.usfirst.frc3501.RiceCatRobot.robot.Robot; +import org.usfirst.frc3501.RiceCatRobot.robot.RobotMap.Direction; import edu.wpi.first.wpilibj.Timer; import edu.wpi.first.wpilibj.command.Command; diff --git a/src/org/usfirst/frc3501/RiceCatRobot/commands/DriveForTime.java b/src/org/usfirst/frc3501/RiceCatRobot/commands/DriveForTime.java new file mode 100644 index 0000000..f662e4b --- /dev/null +++ b/src/org/usfirst/frc3501/RiceCatRobot/commands/DriveForTime.java @@ -0,0 +1,59 @@ +package org.usfirst.frc3501.RiceCatRobot.commands; + +import org.usfirst.frc3501.RiceCatRobot.Robot; +import org.usfirst.frc3501.RiceCatRobot.RobotMap.Direction; + +import edu.wpi.first.wpilibj.Timer; +import edu.wpi.first.wpilibj.command.Command; + +/** + * This command takes a time in seconds which is how long it should run + * + */ +public class DriveForTime extends Command { + private double seconds; + private Timer timer; + private double speed; + + /*** + * Drive at a fixed speed (speed) for a fixed time (seconds). + * + * @param seconds + * the number of seconds to drive + * @param speed + * a motor value in the range [-1, 1]. Negative numbers are + * interpreted as driving backwards. 0 is stopped. + */ + public DriveForTime(double seconds, double speed) { + this.seconds = seconds; + this.speed = -speed; // note: setMotorSpeeds(-1, -1) would be + // forward full speed, so we take the opposite + // of the input to achieve this. + } + + @Override + protected void initialize() { + this.setTimeout(seconds); + Robot.driveTrain.setMotorSpeeds(speed, speed); + } + + @Override + protected void execute() { + // nothing here because motors are already set + } + + @Override + protected boolean isFinished() { + return this.isTimedOut(); + } + + @Override + protected void end() { + Robot.driveTrain.stop(); + } + + @Override + protected void interrupted() { + end(); + } +} diff --git a/src/org/usfirst/frc3501/RiceCatRobot/commands/MoveArmFor.java b/src/org/usfirst/frc3501/RiceCatRobot/commands/MoveArmFor.java index 4e97d1b..8cdbec2 100644 --- a/src/org/usfirst/frc3501/RiceCatRobot/commands/MoveArmFor.java +++ b/src/org/usfirst/frc3501/RiceCatRobot/commands/MoveArmFor.java @@ -1,8 +1,8 @@ package org.usfirst.frc3501.RiceCatRobot.commands; -import org.usfirst.frc3501.RiceCatRobot.Robot; -import org.usfirst.frc3501.RiceCatRobot.RobotMap; -import org.usfirst.frc3501.RiceCatRobot.RobotMap.Direction; +import org.usfirst.frc3501.RiceCatRobot.robot.Robot; +import org.usfirst.frc3501.RiceCatRobot.robot.RobotMap; +import org.usfirst.frc3501.RiceCatRobot.robot.RobotMap.Direction; import edu.wpi.first.wpilibj.Timer; import edu.wpi.first.wpilibj.command.Command; diff --git a/src/org/usfirst/frc3501/RiceCatRobot/commands/MoveDistance.java b/src/org/usfirst/frc3501/RiceCatRobot/commands/MoveDistance.java new file mode 100644 index 0000000..6608c33 --- /dev/null +++ b/src/org/usfirst/frc3501/RiceCatRobot/commands/MoveDistance.java @@ -0,0 +1,48 @@ +package org.usfirst.frc3501.RiceCatRobot.commands; + +import org.usfirst.frc3501.RiceCatRobot.robot.Robot; +import org.usfirst.frc3501.RiceCatRobot.subsystems.DriveTrain; + +import edu.wpi.first.wpilibj.command.Command; + +public class MoveDistance extends Command { + + double distance, minSpeed, maxSpeed; + + public MoveDistance(double distance, double minSpeed, double maxSpeed) { + requires(Robot.driveTrain); + this.distance = distance; + this.minSpeed = minSpeed; + this.maxSpeed = maxSpeed; + } + + protected void initialize() { + Robot.driveTrain.resetEncoders(); + } + + @Override + protected void execute() { + double speed = 4 * (minSpeed - maxSpeed) * + Math.pow((Robot.driveTrain.getAverageSpeed() / distance - 0.5), 2) + + maxSpeed; + Robot.driveTrain.setMotorSpeeds(speed, speed); + } + + @Override + protected boolean isFinished() { + if (Robot.driveTrain.getLeftDistance() > distance + && Robot.driveTrain.getRightDistance() > distance) + return true; + return false; + } + + @Override + protected void end() { + Robot.driveTrain.stop(); + } + + @Override + protected void interrupted() { + end(); + } +} diff --git a/src/org/usfirst/frc3501/RiceCatRobot/commands/OpenClaw.java b/src/org/usfirst/frc3501/RiceCatRobot/commands/OpenClaw.java index 101ae75..c0d351d 100644 --- a/src/org/usfirst/frc3501/RiceCatRobot/commands/OpenClaw.java +++ b/src/org/usfirst/frc3501/RiceCatRobot/commands/OpenClaw.java @@ -2,7 +2,7 @@ package org.usfirst.frc3501.RiceCatRobot.commands; import edu.wpi.first.wpilibj.command.Command; -import org.usfirst.frc3501.RiceCatRobot.Robot; +import org.usfirst.frc3501.RiceCatRobot.robot.Robot; /** * Opens claw by reversing solenoids. diff --git a/src/org/usfirst/frc3501/RiceCatRobot/commands/ToggleClaw.java b/src/org/usfirst/frc3501/RiceCatRobot/commands/ToggleClaw.java index 32f658f..c85ea77 100644 --- a/src/org/usfirst/frc3501/RiceCatRobot/commands/ToggleClaw.java +++ b/src/org/usfirst/frc3501/RiceCatRobot/commands/ToggleClaw.java @@ -1,6 +1,6 @@ package org.usfirst.frc3501.RiceCatRobot.commands; -import org.usfirst.frc3501.RiceCatRobot.Robot; +import org.usfirst.frc3501.RiceCatRobot.robot.Robot; import edu.wpi.first.wpilibj.command.Command; diff --git a/src/org/usfirst/frc3501/RiceCatRobot/commands/ToggleCompressor.java b/src/org/usfirst/frc3501/RiceCatRobot/commands/ToggleCompressor.java index 64c34f9..3669eaf 100644 --- a/src/org/usfirst/frc3501/RiceCatRobot/commands/ToggleCompressor.java +++ b/src/org/usfirst/frc3501/RiceCatRobot/commands/ToggleCompressor.java @@ -1,6 +1,6 @@ package org.usfirst.frc3501.RiceCatRobot.commands; -import org.usfirst.frc3501.RiceCatRobot.Robot; +import org.usfirst.frc3501.RiceCatRobot.robot.Robot; import edu.wpi.first.wpilibj.command.Command; diff --git a/src/org/usfirst/frc3501/RiceCatRobot/commands/TurnFor.java b/src/org/usfirst/frc3501/RiceCatRobot/commands/TurnFor.java index 4abe13b..580fe06 100644 --- a/src/org/usfirst/frc3501/RiceCatRobot/commands/TurnFor.java +++ b/src/org/usfirst/frc3501/RiceCatRobot/commands/TurnFor.java @@ -1,7 +1,7 @@ package org.usfirst.frc3501.RiceCatRobot.commands; -import org.usfirst.frc3501.RiceCatRobot.Robot; -import org.usfirst.frc3501.RiceCatRobot.RobotMap.Direction; +import org.usfirst.frc3501.RiceCatRobot.robot.Robot; +import org.usfirst.frc3501.RiceCatRobot.robot.RobotMap.Direction; import edu.wpi.first.wpilibj.Timer; import edu.wpi.first.wpilibj.command.Command; diff --git a/src/org/usfirst/frc3501/RiceCatRobot/robot/OI.java b/src/org/usfirst/frc3501/RiceCatRobot/robot/OI.java new file mode 100644 index 0000000..9c391da --- /dev/null +++ b/src/org/usfirst/frc3501/RiceCatRobot/robot/OI.java @@ -0,0 +1,31 @@ +package org.usfirst.frc3501.RiceCatRobot.robot; + +import org.usfirst.frc3501.RiceCatRobot.commands.ToggleClaw; +import org.usfirst.frc3501.RiceCatRobot.commands.ToggleCompressor; + +import edu.wpi.first.wpilibj.Joystick; +import edu.wpi.first.wpilibj.buttons.JoystickButton; + +public class OI { + public static Joystick leftJoystick; + public static Joystick rightJoystick; + public static JoystickButton trigger; + public static JoystickButton toggleCompressor; + public static JoystickButton toggleClaw; + + public OI() { + System.out.println("OI is open"); + leftJoystick = new Joystick(RobotMap.LEFT_STICK_PORT); + rightJoystick = new Joystick(RobotMap.RIGHT_STICK_PORT); + + trigger = new JoystickButton(rightJoystick, RobotMap.TRIGGER_PORT); + + toggleClaw = new JoystickButton(rightJoystick, RobotMap.TOGGLE_PORT); + toggleClaw.whenPressed(new ToggleClaw()); + + toggleCompressor = new JoystickButton(rightJoystick, + RobotMap.TOGGLE_COMPRESSOR_PORT); + toggleCompressor.whenPressed(new ToggleCompressor()); + + } +} diff --git a/src/org/usfirst/frc3501/RiceCatRobot/robot/Robot.java b/src/org/usfirst/frc3501/RiceCatRobot/robot/Robot.java new file mode 100644 index 0000000..e83f800 --- /dev/null +++ b/src/org/usfirst/frc3501/RiceCatRobot/robot/Robot.java @@ -0,0 +1,69 @@ +package org.usfirst.frc3501.RiceCatRobot.robot; + +import org.usfirst.frc3501.RiceCatRobot.subsystems.Arm; +import org.usfirst.frc3501.RiceCatRobot.subsystems.Claw; +import org.usfirst.frc3501.RiceCatRobot.subsystems.DriveTrain; + +import edu.wpi.first.wpilibj.Compressor; +import edu.wpi.first.wpilibj.IterativeRobot; +import edu.wpi.first.wpilibj.Timer; +import edu.wpi.first.wpilibj.command.Scheduler; + +public class Robot extends IterativeRobot { + static Timer timer; + public static OI oi; + public static DriveTrain driveTrain; + public static Arm arm; + public static Claw claw; + public static Compressor compressor; + + public void robotInit() { + RobotMap.init(); + driveTrain = new DriveTrain(); + arm = new Arm(); + claw = new Claw(); + oi = new OI(); + compressor = new Compressor(RobotMap.COMPRESSOR_PORT); + } + + public void autonomousInit() { + } + + public void autonomousPeriodic() { + Scheduler.getInstance().run(); + } + + public void teleopInit() { + System.out.println("running teleopInit"); + } + + public void teleopPeriodic() { + Scheduler.getInstance().run(); + + } + + public void operate() { + driveTrain + .arcadeDrive(OI.rightJoystick.getY(), OI.rightJoystick.getTwist()); + claw.doTriggerAction(); + if (OI.leftJoystick.getRawButton(8)) { + arm.setArmSpeeds(0.3); + } else if (OI.leftJoystick.getRawButton(9)) { + arm.setArmSpeeds(-0.3); + } else if (OI.leftJoystick.getRawButton(6)) { + arm.setLeft(0.3); + } else if (OI.leftJoystick.getRawButton(7)) { + arm.setLeft(-0.3); + } else if (OI.leftJoystick.getRawButton(11)) { + arm.setRight(-0.3); + } else if (OI.leftJoystick.getRawButton(10)) { + arm.setRight(0.3); + } + if (Math.abs(OI.leftJoystick.getY()) < 0.05) { + arm.setArmSpeeds(0); + + } else { + arm.fineTuneControl(OI.leftJoystick.getY()); + } + } +} diff --git a/src/org/usfirst/frc3501/RiceCatRobot/robot/RobotMap.java b/src/org/usfirst/frc3501/RiceCatRobot/robot/RobotMap.java new file mode 100644 index 0000000..90f10ec --- /dev/null +++ b/src/org/usfirst/frc3501/RiceCatRobot/robot/RobotMap.java @@ -0,0 +1,42 @@ +package org.usfirst.frc3501.RiceCatRobot.robot; + +import edu.wpi.first.wpilibj.DoubleSolenoid; +import edu.wpi.first.wpilibj.DoubleSolenoid.Value; + +/** + * The RobotMap is a mapping from the ports sensors and actuators are wired into + * to a variable name. This provides flexibility changing wiring, makes checking + * the wiring easier and significantly reduces the number of magic numbers + * floating around. + */ +public class RobotMap { + public final static int LEFT_STICK_PORT = 0, RIGHT_STICK_PORT = 1; + public final static int TRIGGER_PORT = 1, TOGGLE_PORT = 2, + TOGGLE_COMPRESSOR_PORT = 11; + public static final int DRIVE_FRONT_LEFT = 4, DRIVE_FRONT_RIGHT = 5, + DRIVE_REAR_LEFT = 3, DRIVE_REAR_RIGHT = 6; + public static final int DRIVE_LEFT_A = 3, DRIVE_LEFT_B = 4, + DRIVE_RIGHT_A = 2, DRIVE_RIGHT_B = 1; + + public static final double DISTANCE_PER_PULSE = + ((3.66 / 5.14) * 6 * Math.PI) / 256; + + public static final int ARM_LEFT = 2, ARM_RIGHT = 7; + public static final double ARM_HIGH_SPEED = 0.5, ARM_LOW_SPEED = 0.5; + + // Claw + public static final int SOLENOID_FORWARD = 0, SOLENOID_REVERSE = 1, + MODULE_NUMBER = 0; + public final static Value open = DoubleSolenoid.Value.kForward, + close = DoubleSolenoid.Value.kReverse; + public static double DRIVE_DEAD_ZONE = 0.25; + // Compressor + public static final int COMPRESSOR_PORT = 0; + + public static void init() { + } + + public static enum Direction { + LEFT, RIGHT, DOWN, UP, FORWARD, BACKWARD; + } +} diff --git a/src/org/usfirst/frc3501/RiceCatRobot/subsystems/Arm.java b/src/org/usfirst/frc3501/RiceCatRobot/subsystems/Arm.java index 8d78c8f..e20a822 100644 --- a/src/org/usfirst/frc3501/RiceCatRobot/subsystems/Arm.java +++ b/src/org/usfirst/frc3501/RiceCatRobot/subsystems/Arm.java @@ -1,6 +1,6 @@ package org.usfirst.frc3501.RiceCatRobot.subsystems; -import org.usfirst.frc3501.RiceCatRobot.RobotMap; +import org.usfirst.frc3501.RiceCatRobot.robot.RobotMap; import edu.wpi.first.wpilibj.CANJaguar; import edu.wpi.first.wpilibj.command.Subsystem; diff --git a/src/org/usfirst/frc3501/RiceCatRobot/subsystems/Claw.java b/src/org/usfirst/frc3501/RiceCatRobot/subsystems/Claw.java index b7a1f04..f3db1b5 100644 --- a/src/org/usfirst/frc3501/RiceCatRobot/subsystems/Claw.java +++ b/src/org/usfirst/frc3501/RiceCatRobot/subsystems/Claw.java @@ -1,10 +1,10 @@ package org.usfirst.frc3501.RiceCatRobot.subsystems; -import org.usfirst.frc3501.RiceCatRobot.OI; -import org.usfirst.frc3501.RiceCatRobot.Robot; -import org.usfirst.frc3501.RiceCatRobot.RobotMap; import org.usfirst.frc3501.RiceCatRobot.commands.CloseClaw; import org.usfirst.frc3501.RiceCatRobot.commands.OpenClaw; +import org.usfirst.frc3501.RiceCatRobot.robot.OI; +import org.usfirst.frc3501.RiceCatRobot.robot.Robot; +import org.usfirst.frc3501.RiceCatRobot.robot.RobotMap; import edu.wpi.first.wpilibj.DoubleSolenoid; import edu.wpi.first.wpilibj.command.Subsystem; diff --git a/src/org/usfirst/frc3501/RiceCatRobot/subsystems/DriveTrain.java b/src/org/usfirst/frc3501/RiceCatRobot/subsystems/DriveTrain.java index 49ffefa..c02dea9 100644 --- a/src/org/usfirst/frc3501/RiceCatRobot/subsystems/DriveTrain.java +++ b/src/org/usfirst/frc3501/RiceCatRobot/subsystems/DriveTrain.java @@ -1,6 +1,6 @@ package org.usfirst.frc3501.RiceCatRobot.subsystems; -import org.usfirst.frc3501.RiceCatRobot.RobotMap; +import org.usfirst.frc3501.RiceCatRobot.robot.RobotMap; import edu.wpi.first.wpilibj.CANJaguar; import edu.wpi.first.wpilibj.Encoder; @@ -30,7 +30,7 @@ public class DriveTrain extends Subsystem { } public double getRightSpeed() { - // Returns in per second + // Returns inches per second return rightEncoder.getRate(); } @@ -38,16 +38,24 @@ public class DriveTrain extends Subsystem { return leftEncoder.getRate(); } + public double getAverageSpeed() { + return (getRightSpeed() + getLeftSpeed()) / 2; + } + public double getRightDistance() { - // Returns distance in in + // Returns distance in inches return rightEncoder.getDistance(); } public double getLeftDistance() { - // Returns distance in in + // Returns distance in inches return leftEncoder.getDistance(); } + public void stop() { + setMotorSpeeds(0, 0); + } + public void setMotorSpeeds(double leftSpeed, double rightSpeed) { if (Math.abs(leftSpeed) < RobotMap.DRIVE_DEAD_ZONE) { leftSpeed = 0;