From: EvanYap Date: Tue, 16 Feb 2016 02:09:29 +0000 (-0800) Subject: Create identical copy of IntakeArm subsystem but with slight modifications to remove... X-Git-Url: http://challenge-bot.com/repos/?a=commitdiff_plain;h=refs%2Fheads%2Fevan%2Fupdate-defense-arm;p=3501%2Fstronghold-2016 Create identical copy of IntakeArm subsystem but with slight modifications to remove roller related tuff for the Single jointed Defense arm --- diff --git a/src/org/usfirst/frc/team3501/robot/subsystems/DefenseArm.java b/src/org/usfirst/frc/team3501/robot/subsystems/DefenseArm.java new file mode 100644 index 00000000..963c089c --- /dev/null +++ b/src/org/usfirst/frc/team3501/robot/subsystems/DefenseArm.java @@ -0,0 +1,89 @@ +package org.usfirst.frc.team3501.robot.subsystems; + +import org.usfirst.frc.team3501.robot.Constants; + +import edu.wpi.first.wpilibj.AnalogPotentiometer; +import edu.wpi.first.wpilibj.CANTalon; +import edu.wpi.first.wpilibj.command.Subsystem; + +/*** + * The IntakeArm consists of two rollers that are controlled by one motor, with + * a potentiometer on it. + * + * The motor controls the rollers, making them roll forwards and backwards. The + * Intake rollers are on the back of the robot. As the rollers run, they intake + * the ball. + * + * @author superuser + * + */ + +public class DefenseArm extends Subsystem { + + private CANTalon defenseArm; + private AnalogPotentiometer defensePot; + public static double[] potAngles = { 0, 30, 45, 90 }; // TODO: correct angles + public static double moveIntakeArmSpeed = 0; + + public DefenseArm() { + defenseArm = new CANTalon(Constants.IntakeArm.ARM_PORT); + defensePot = new AnalogPotentiometer(Constants.DefenseArm.POT_CHANNEL, + Constants.IntakeArm.FULL_RANGE, Constants.DefenseArm.OFFSET); + } + + /*** + * This method sets the voltage of the arm motor. The range is from [-1,1]. A + * negative voltage makes the direction of the motor go backwards. + * + * @param voltage + * The voltage that you set the motor at. The range of the voltage of + * the arm motor is from [-1,1]. A negative voltage makes the + * direction of the motor go backwards. + */ + + public void setArmSpeed(double voltage) { + if (voltage > 1) + voltage = 1; + else if (voltage < -1) + voltage = -1; + + defenseArm.set(voltage); + } + + /*** + * This method gets you the current voltage of the motor that controls the + * intake arm. The range of voltage is from [-1,1]. A negative voltage makes + * the motor run backwards. + * + * @return Returns the voltage of the motor that controls the arm. The range + * of the voltage goes from [-1,1]. A negative voltage indicates that + * the motor is running backwards. + */ + + public double getArmSpeed() { + return defenseArm.get(); + } + + /*** + * This method gets the angle of the potentiometer on the Intake Arm. + * + * @return angle of potentiometer + */ + + public double getArmAngle() { + return defensePot.get() + Constants.IntakeArm.ZERO_ANGLE; + } + + public void stop() { + setArmSpeed(0); + } + + public double getAngleForLevel(double targetLevel) { + return potAngles[(int) (targetLevel - 1)]; + } + + @Override + protected void initDefaultCommand() { + + } +}