Skip to content

Commit b082864

Browse files
Merge pull request #292 from thedropbears/make_climber_unable_to_retract_until_first_deploy
Make climber unable to retract until first deploy
2 parents 6bbddd7 + b7aa45d commit b082864

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

components/climber.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ def __init__(self) -> None:
4848
SparkMax.PersistMode.kPersistParameters,
4949
)
5050

51-
def stop(self) -> None:
52-
self.set_angle(math.radians(self.encoder_angle()))
53-
5451
def on_disable(self) -> None:
5552
self.update_pid = True
5653
self.go_to_neutral()
5754

55+
def stop(self) -> None:
56+
self.set_angle(math.radians(self.encoder_angle()))
57+
5858
def stop_pid_update(self) -> None:
5959
self.update_pid = False
6060

controllers/climber.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,18 @@ class ClimberStateMachine(StateMachine):
1414
chassis: ChassisComponent
1515

1616
def __init__(self):
17+
self.has_deployed = False
1718
self.heading_to_cage = 0.0
1819

20+
def on_disable(self) -> None:
21+
self.has_deployed = False
22+
1923
def deploy(self) -> None:
2024
self.engage("deploying")
2125

2226
def retract(self) -> None:
23-
self.engage("retracting", force=True)
27+
if self.has_deployed:
28+
self.engage("retracting", force=True)
2429

2530
@state(first=True, must_finish=True)
2631
def deploying(self, initial_call) -> None:
@@ -30,6 +35,7 @@ def deploying(self, initial_call) -> None:
3035

3136
if self.climber.is_deployed():
3237
self.climber.stop_pid_update()
38+
self.has_deployed = True
3339

3440
cage_positions = cage_pos(is_red())
3541
closest_cage_position = cage_positions[0]

0 commit comments

Comments
 (0)