File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change 55from wpilib import DutyCycleEncoder
66from wpimath .controller import PIDController
77
8+ from components .led_component import LightStrip
89from ids import DioChannel , SparkId
910from utilities .functions import constrain_angle
1011from utilities .rev import configure_through_bore_encoder
1112
1213
1314class ClimberComponent :
15+ status_lights : LightStrip
16+
1417 target_speed = 0.0
1518 winch_voltage = tunable (12.0 )
1619
@@ -90,6 +93,8 @@ def is_retracted(self) -> bool:
9093 )
9194
9295 def execute (self ) -> None :
96+ if self .is_retracted ():
97+ self .status_lights .climber_retracting ()
9398 if self .update_pid :
9499 pid_result = self .pid .calculate (self .raw_encoder_val (), self .desired_angle )
95100 self .motor .setVoltage (pid_result )
Original file line number Diff line number Diff line change @@ -158,7 +158,35 @@ def climber_deploying(self) -> None:
158158 self .keep_alive ()
159159
160160 def climber_retracting (self ) -> None :
161- self .pattern = LEDPattern .blink (LEDPattern .solid (Color .kMagenta ), 0.15 )
161+ colour = Color .kRed if is_red () else Color .kBlue
162+ steps = []
163+ stripes = 16
164+ increment = 1.0 / 16
165+ for v in range (0 , stripes , 2 ):
166+ steps .append ((v * increment , colour ))
167+ steps .append (((v + 1 ) * increment , Color .kBlack ))
168+
169+ forward_pattern = (
170+ LEDPattern .steps (steps ).scrollAtAbsoluteSpeed (1.0 , LED_SPACING ).reversed ()
171+ )
172+
173+ def remapper (length : int , idx : int ) -> int :
174+ idx = int (idx )
175+ splits = [
176+ 0 ,
177+ int (length * self .right_rear_front_split ),
178+ int (length * self .halfway_split ),
179+ int (length * self .left_front_rear_split ),
180+ ]
181+ if splits [0 ] <= int (idx ) < splits [1 ]:
182+ return int (splits [1 ] - splits [0 ]) - idx
183+ elif splits [2 ] <= int (idx ) < splits [3 ]:
184+ return int (splits [3 ] - splits [2 ]) - (idx - splits [2 ]) + splits [2 ]
185+ else :
186+ return int (idx )
187+
188+ forward = forward_pattern .mapIndex (remapper )
189+ self .pattern = forward
162190 self .keep_alive ()
163191
164192 def execute (self ) -> None :
You can’t perform that action at this time.
0 commit comments