From b86dfda8e14fae0205e57349e71b1c79c64ee87c Mon Sep 17 00:00:00 2001 From: frc1646 Date: Thu, 8 Jun 2017 20:58:53 -0400 Subject: [PATCH 1/2] Add files via upload Hey Ryker, this is Hyungki. I am unsure if the extending and retracting of BallCollector (pneumatic cylinders) functions similar to limit switches (single Solenoid). I have created codes for double solenoids as well just in case. It's likely that more codes may be needed in the future for improvements. --- .../robot/commands/DisableDSolenoids.java | 38 +++++++++++++++ .../robot/commands/DriveWithSticks.java | 48 +++++++++++++++++++ .../team1646/robot/commands/PlaceBall.java | 38 +++++++++++++++ .../team1646/robot/commands/ReachBall.java | 40 ++++++++++++++++ 4 files changed, 164 insertions(+) create mode 100644 src/org/usfirst/frc/team1646/robot/commands/DisableDSolenoids.java create mode 100644 src/org/usfirst/frc/team1646/robot/commands/DriveWithSticks.java create mode 100644 src/org/usfirst/frc/team1646/robot/commands/PlaceBall.java create mode 100644 src/org/usfirst/frc/team1646/robot/commands/ReachBall.java diff --git a/src/org/usfirst/frc/team1646/robot/commands/DisableDSolenoids.java b/src/org/usfirst/frc/team1646/robot/commands/DisableDSolenoids.java new file mode 100644 index 0000000..85a8753 --- /dev/null +++ b/src/org/usfirst/frc/team1646/robot/commands/DisableDSolenoids.java @@ -0,0 +1,38 @@ +package org.usfirst.frc.team1646.robot.commands; + +import org.usfirst.frc.team1646.robot.Robot; + +import edu.wpi.first.wpilibj.command.Command; + +/** + * + */ +public class DisableDSolenoids extends Command { + + public DisableDSolenoids() { + requires(Robot.ballCollector); + } + + // Called just before this Command runs the first time + protected void initialize() { + Robot.ballCollector.neitherChannelEnabled(); + } + + // Called repeatedly when this Command is scheduled to run + protected void execute() { + } + + // Make this return true when this Command no longer needs to run execute() + protected boolean isFinished() { + return true; + } + + // Called once after isFinished returns true + protected void end() { + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + protected void interrupted() { + } +} diff --git a/src/org/usfirst/frc/team1646/robot/commands/DriveWithSticks.java b/src/org/usfirst/frc/team1646/robot/commands/DriveWithSticks.java new file mode 100644 index 0000000..5794ada --- /dev/null +++ b/src/org/usfirst/frc/team1646/robot/commands/DriveWithSticks.java @@ -0,0 +1,48 @@ +package org.usfirst.frc.team1646.robot.commands; + +import org.usfirst.frc.team1646.robot.Robot; + +import edu.wpi.first.wpilibj.command.Command; + +public class DriveWithSticks extends Command { + + private double maxPower = 0; + + public DriveWithSticks() { + requires(Robot.driveSubsystem); + } + + protected void initialize() { + } + + protected void execute() { + + double left = Robot.oi.leftStick.getY(); + double right = Robot.oi.rightStick.getY(); + + boolean leftTrigger = Robot.oi.leftStick.getRawButton(1); + boolean rightTrigger = Robot.oi.rightStick.getRawButton(1); + + if (leftTrigger || rightTrigger) { + maxPower = 1; + Robot.driveSubsystem.tankDrive(maxPower * left, maxPower * right); + } else { + maxPower = 0.5; + Robot.driveSubsystem.tankDrive(maxPower * left, maxPower * right); + } + } + + // Make this return true when this Command no longer needs to run execute() + protected boolean isFinished() { + return false; + } + + // Called once after isFinished returns true + protected void end() { + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + protected void interrupted() { + } +} diff --git a/src/org/usfirst/frc/team1646/robot/commands/PlaceBall.java b/src/org/usfirst/frc/team1646/robot/commands/PlaceBall.java new file mode 100644 index 0000000..e791574 --- /dev/null +++ b/src/org/usfirst/frc/team1646/robot/commands/PlaceBall.java @@ -0,0 +1,38 @@ +package org.usfirst.frc.team1646.robot.commands; + +import org.usfirst.frc.team1646.robot.Robot; + +import edu.wpi.first.wpilibj.command.Command; + +/** + * + */ +public class PlaceBall extends Command { + + public PlaceBall() { + requires(Robot.ballCollector); + } + + protected void initialize() { + Robot.ballCollector.moveToOriginalS(); + //Robot.ballCollector.moveToOriginalD(); + } + + // Called repeatedly when this Command is scheduled to run + protected void execute() { + } + + // Make this return true when this Command no longer needs to run execute() + protected boolean isFinished() { + return true; + } + + // Called once after isFinished returns true + protected void end() { + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + protected void interrupted() { + } +} diff --git a/src/org/usfirst/frc/team1646/robot/commands/ReachBall.java b/src/org/usfirst/frc/team1646/robot/commands/ReachBall.java new file mode 100644 index 0000000..afaa31c --- /dev/null +++ b/src/org/usfirst/frc/team1646/robot/commands/ReachBall.java @@ -0,0 +1,40 @@ +package org.usfirst.frc.team1646.robot.commands; + + +import org.usfirst.frc.team1646.robot.Robot; + +import edu.wpi.first.wpilibj.command.Command; + +/** + * + */ +public class ReachBall extends Command { + + public ReachBall() { + requires(Robot.ballCollector); + } + + // Called just before this Command runs the first time + protected void initialize() { + Robot.ballCollector.moveToCollectS(); + //Robot.ballCollector.moveToCollectD(); + } + + // Called repeatedly when this Command is scheduled to run + protected void execute() { + } + + // Make this return true when this Command no longer needs to run execute() + protected boolean isFinished() { + return true; + } + + // Called once after isFinished returns true + protected void end() { + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + protected void interrupted() { + } +} From c611bb8949ae0d71b1d622cc3ac9d787a5642a7a Mon Sep 17 00:00:00 2001 From: frc1646 Date: Thu, 8 Jun 2017 21:19:42 -0400 Subject: [PATCH 2/2] Add files via upload --- .../robot/subsystems/BallCollector.java | 76 +++++++++++++++++++ .../robot/subsystems/ClawController.java | 17 +++++ .../robot/subsystems/DriveSubsystem.java | 63 +++++++++++++++ .../robot/subsystems/ShootingSubsystem.java | 16 ++++ 4 files changed, 172 insertions(+) create mode 100644 src/org/usfirst/frc/team1646/robot/subsystems/BallCollector.java create mode 100644 src/org/usfirst/frc/team1646/robot/subsystems/ClawController.java create mode 100644 src/org/usfirst/frc/team1646/robot/subsystems/DriveSubsystem.java create mode 100644 src/org/usfirst/frc/team1646/robot/subsystems/ShootingSubsystem.java diff --git a/src/org/usfirst/frc/team1646/robot/subsystems/BallCollector.java b/src/org/usfirst/frc/team1646/robot/subsystems/BallCollector.java new file mode 100644 index 0000000..e8f3626 --- /dev/null +++ b/src/org/usfirst/frc/team1646/robot/subsystems/BallCollector.java @@ -0,0 +1,76 @@ +package org.usfirst.frc.team1646.robot.subsystems; + +import org.usfirst.frc.team1646.robot.RobotMap; + +import edu.wpi.first.wpilibj.DoubleSolenoid; +import edu.wpi.first.wpilibj.Solenoid; +import edu.wpi.first.wpilibj.Talon; +import edu.wpi.first.wpilibj.command.Subsystem; + +public class BallCollector extends Subsystem { + + //FIXME is it a single solenoid or double? + private Solenoid intakeBall; + private Talon keepBall; + + private DoubleSolenoid collectBall; + + public static boolean extend = false; + public static boolean retract = true; + + public BallCollector() { + intakeBall = new Solenoid(RobotMap.intakeBall); + keepBall = new Talon(RobotMap.keepBall); + + //Don't know what the forward channel (1st) and a reverse channel (2nd) will be + collectBall = new DoubleSolenoid( , ); + } + + public Solenoid getIntakeBall() { + return intakeBall; + } + + public Talon getKeepBall() { + return keepBall; + } + + public DoubleSolenoid getCollectBall() { + return collectBall; + } + + public void spinWheels() { + keepBall.set(0.5); + } + + // false = extend; true = retract + // S = Single Solenoid; D = Double Solenoid + public void moveToCollectS() { + intakeBall.set(extend); + spinWheels(); + } + + public void moveToOriginalS() { + intakeBall.set(retract); + spinWheels(); + } + + public void moveToCollectD() { + collectBall.set(DoubleSolenoid.Value.kForward); + } + + public void moveToOriginalD() { + collectBall.set(DoubleSolenoid.Value.kReverse); + } + + public void neitherChannelEnabled() { + collectBall.set(DoubleSolenoid.Value.kOff); + } + + + @Override + protected void initDefaultCommand() { + // TODO Auto-generated method stub + + } + +} diff --git a/src/org/usfirst/frc/team1646/robot/subsystems/ClawController.java b/src/org/usfirst/frc/team1646/robot/subsystems/ClawController.java new file mode 100644 index 0000000..a5b153b --- /dev/null +++ b/src/org/usfirst/frc/team1646/robot/subsystems/ClawController.java @@ -0,0 +1,17 @@ +package org.usfirst.frc.team1646.robot.subsystems; + +import edu.wpi.first.wpilibj.command.Subsystem; + +public class ClawController extends Subsystem { + + public ClawController() { + + } + + @Override + protected void initDefaultCommand() { + // TODO Auto-generated method stub + + } + +} diff --git a/src/org/usfirst/frc/team1646/robot/subsystems/DriveSubsystem.java b/src/org/usfirst/frc/team1646/robot/subsystems/DriveSubsystem.java new file mode 100644 index 0000000..48efd0b --- /dev/null +++ b/src/org/usfirst/frc/team1646/robot/subsystems/DriveSubsystem.java @@ -0,0 +1,63 @@ +package org.usfirst.frc.team1646.robot.subsystems; + +import org.usfirst.frc.team1646.robot.RobotMap; + +import edu.wpi.first.wpilibj.Talon; +import edu.wpi.first.wpilibj.command.Subsystem; + +public class DriveSubsystem extends Subsystem { + + private Talon frontLeft; + private Talon backLeft; + private Talon frontRight; + private Talon backRight; + + public DriveSubsystem() { + frontLeft = new Talon(RobotMap.driveFrontLeft); + backLeft = new Talon(RobotMap.driveBackLeft); + frontRight = new Talon(RobotMap.driveFrontRight); + backRight = new Talon(RobotMap.driveBackRight); + } + + public Talon getFrontLeft() { + return frontLeft; + } + + public Talon getBackLeft() { + return backLeft; + } + + public Talon getFrontRight() { + return frontRight; + } + + public Talon getBackRight() { + return backRight; + } + + //FIXME the directions might be the opposite + public void rightPower(double right) { + frontRight.set(right); + backRight.set(right); + } + + public void leftPower(double left) { + frontLeft.set(left); + backLeft.set(left); + } + + public void tankDrive(double left, double right) { + + frontLeft.set(left); + backLeft.set(left); + + frontRight.set(right); + backRight.set(right); + } + //FIXME the directions might be the opposite + + @Override + protected void initDefaultCommand() { + // TODO Auto-generated method stub + } +} diff --git a/src/org/usfirst/frc/team1646/robot/subsystems/ShootingSubsystem.java b/src/org/usfirst/frc/team1646/robot/subsystems/ShootingSubsystem.java new file mode 100644 index 0000000..61bddad --- /dev/null +++ b/src/org/usfirst/frc/team1646/robot/subsystems/ShootingSubsystem.java @@ -0,0 +1,16 @@ +package org.usfirst.frc.team1646.robot.subsystems; + +import edu.wpi.first.wpilibj.command.Subsystem; + +public class ShootingSubsystem extends Subsystem { + + public ShootingSubsystem() { + + } + + @Override + protected void initDefaultCommand() { + // TODO Auto-generated method stub + + } +}