1313import org .lasarobotics .hardware .revrobotics .Spark .MotorKind ;
1414import org .lasarobotics .hardware .revrobotics .Spark .SparkInputs ;
1515import org .littletonrobotics .junction .Logger ;
16-
16+ import edu . wpi . first . wpilibj . Servo ;
1717import edu .wpi .first .wpilibj2 .command .Command ;
1818import frc .robot .Constants ;
1919import frc .robot .LoopTimer ;
@@ -25,11 +25,12 @@ public class ClimbSubsystem extends StateMachine implements AutoCloseable {
2525 static final double MOUNT_ANGLE = 0.357 ;
2626 static final double CLIMB_ANGLE = 0.12 ;
2727 static final double STOW_ANGLE = 0.08 ;
28+ static final double SERVO_ANGLE = 120.0 ;
2829
2930 public static record Hardware (
3031 Spark climbEncoder ,
31- TalonFX climbMotor
32-
32+ TalonFX climbMotor ,
33+ Servo servo
3334
3435 ) {}
3536
@@ -79,6 +80,7 @@ public ClimbStates nextState() {
7980 @ Override
8081 public void initialize () {
8182 s_climbInstance .climb ();
83+ s_climbInstance .extendServo ();
8284 s_climbInstance .setIsMounted (false );
8385
8486 }
@@ -102,8 +104,10 @@ public ClimbStates nextState() {
102104 private static ClimbSubsystem s_climbInstance ;
103105 private final Spark m_climbEncoder ;
104106 private final TalonFX m_climbMotor ;
107+ private final Servo m_servo ;
105108 private ClimbStates nextState ;
106109 private boolean m_mounted ;
110+ private boolean m_servoExtended = false ;
107111
108112
109113 /** Creates a new ClimbSubsystem. */
@@ -113,6 +117,7 @@ private ClimbSubsystem(Hardware ClimbHardware) {
113117
114118 this .m_climbEncoder = ClimbHardware .climbEncoder ;
115119 this .m_climbMotor = ClimbHardware .climbMotor ;
120+ this .m_servo = ClimbHardware .servo ;
116121
117122 this .m_mounted = false ;
118123
@@ -143,6 +148,13 @@ private void mount() {
143148 m_climbMotor .set (-CLIMB_SPEED );
144149 }
145150
151+ private void extendServo () {
152+ if (!m_servoExtended ) {
153+ m_servo .setAngle (SERVO_ANGLE );
154+ m_servoExtended = true ;
155+ }
156+ }
157+
146158 /**
147159 * Runs climber
148160 * @return Command to run the climber motors
@@ -166,7 +178,8 @@ public Command lowerClimberCommand() {
166178 public static Hardware initializeHardware () {
167179 Hardware climbHardware = new Hardware (
168180 new Spark (Constants .ClimbHardware .ENCODER_ID , MotorKind .NEO ),
169- new TalonFX (Constants .ClimbHardware .CLIMB_MOTOR_ID .deviceID , Constants .ClimbHardware .CLIMB_MOTOR_ID .bus .name )
181+ new TalonFX (Constants .ClimbHardware .CLIMB_MOTOR_ID .deviceID , Constants .ClimbHardware .CLIMB_MOTOR_ID .bus .name ),
182+ new Servo (Constants .ClimbHardware .SERVO_ID )
170183 );
171184
172185
0 commit comments