|
1
|
|
|
package org.usfirst.frc.team3695.robot.subsystems; |
|
2
|
|
|
|
|
3
|
|
|
import org.usfirst.frc.team3695.robot.Constants; |
|
4
|
|
|
import org.usfirst.frc.team3695.robot.commands.ManualCommandHook; |
|
5
|
|
|
import org.usfirst.frc.team3695.robot.util.Xbox; |
|
6
|
|
|
|
|
7
|
|
|
import com.ctre.phoenix.motorcontrol.ControlMode; |
|
8
|
|
|
import com.ctre.phoenix.motorcontrol.can.TalonSRX; |
|
9
|
|
|
|
|
10
|
|
|
import edu.wpi.first.wpilibj.Joystick; |
|
11
|
|
|
import edu.wpi.first.wpilibj.command.Subsystem; |
|
12
|
|
|
|
|
13
|
|
|
/** VROOM VROOM */ |
|
14
|
|
|
public class SubsystemHook extends Subsystem { |
|
15
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
private TalonSRX hook; |
|
18
|
|
|
|
|
19
|
|
|
/** applies left arm motor invert */ |
|
20
|
|
|
public static final double hookify(double hook) { |
|
21
|
|
|
return hook * (Constants.HOOK_MOTOR_INVERT ? -1.0 : 1.0); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** runs at robot boot */ |
|
25
|
|
|
public void initDefaultCommand() { |
|
26
|
|
|
setDefaultCommand(new ManualCommandHook()); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** gives birth to the CANTalons */ |
|
30
|
|
|
public SubsystemHook(){ |
|
31
|
|
|
hook = new TalonSRX(Constants.HOOK); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public void swing(Joystick joy) { |
|
35
|
|
|
double speed = 0; |
|
36
|
|
|
speed = joy.getRawButton(Xbox.A) ? speed++ : speed; |
|
|
|
|
|
|
37
|
|
|
speed = joy.getRawButton(Xbox.B) ? speed-- : speed; |
|
|
|
|
|
|
38
|
|
|
hook.set(ControlMode.PercentOutput, speed); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** configures the voltage of each CANTalon */ |
|
42
|
|
|
private void voltage(TalonSRX talon) { |
|
|
|
|
|
|
43
|
|
|
// talon.configNominalOutputVoltage(0f, 0f); |
|
44
|
|
|
// talon.configPeakOutputVoltage(12.0f, -12.0f); |
|
45
|
|
|
// talon.enableCurrentLimit(true); |
|
46
|
|
|
// talon.configContinuousCurrentLimit(30, 3000); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
|