Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added unsafe distance after intaking algae #128

Merged
merged 8 commits into from
Jan 30, 2025
19 changes: 18 additions & 1 deletion controllers/reef_intake.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class ReefIntake(StateMachine):
L2_INTAKE_ANGLE = tunable(math.radians(-40.0))
L3_INTAKE_ANGLE = tunable(math.radians(-10.0))

RETREAT_DISTANCE = tunable(0.6)

def __init__(self):
self.last_l3 = False

Expand All @@ -24,9 +26,12 @@ def intake(self) -> None:

@state(first=True, must_finish=True)
def intaking(self, initial_call: bool):
if self.algae_manipulator_component.has_algae():
if self.algae_manipulator_component.has_algae() and initial_call:
self.done()
return
LHowe-a11y marked this conversation as resolved.
Show resolved Hide resolved
elif self.algae_manipulator_component.has_algae():
self.next_state("safing")
return

current_is_L3 = self.is_L3()

Expand All @@ -39,6 +44,18 @@ def intaking(self, initial_call: bool):

self.algae_manipulator_component.intake()

@state(must_finish=True)
def safing(self, initial_call: bool):
if initial_call:
self.origin_robot_pose = self.chassis.get_pose()
robot_pose = self.chassis.get_pose()

distance = self.origin_robot_pose.translation() - robot_pose.translation()

if distance.norm() >= self.RETREAT_DISTANCE:
self.done()
return
LHowe-a11y marked this conversation as resolved.
Show resolved Hide resolved

@feedback
def is_L3(self) -> bool:
return game.is_L3(game.nearest_reef_tag(self.chassis.get_pose()))
Expand Down
Loading