Skip to content

Commit

Permalink
WIP: and ability to invert servo
Browse files Browse the repository at this point in the history
  • Loading branch information
CalvinOdropbear committed Jan 27, 2025
1 parent 49c4b94 commit 1f8e717
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
14 changes: 12 additions & 2 deletions components/algae_manipulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def __init__(self) -> None:
self.desired_injector_speed = 0.25

self.algae_size = 0.0
self.desired_feeler_angle = math.radians(90)

def spin_flywheels(self) -> None:
self.desired_flywheel_speed = self.flywheel_shoot_speed
Expand Down Expand Up @@ -122,12 +123,21 @@ def has_algae(self) -> bool:
def feeler_touching_algae(self) -> bool:
return not self.feeler_limit_switch.get()

def set_feeler(self, rot: float):
self.FeelerServo.setAngle(math.degrees(rot))
def set_feeler(self, rot: float, inverted: bool) -> None:
if inverted:
self.desired_feeler_angle = math.radians(180) - rot
else:
self.desired_feeler_angle = rot

@feedback
def get_feeler_set_angle(self) -> float:
return self.desired_feeler_angle

def execute(self) -> None:
self.injector_1.setVoltage(self.desired_injector_speed)

self.FeelerServo.setAngle(math.degrees(self.desired_feeler_angle))

if self.desired_flywheel_speed == 0:
self.flywheel_1.set_control(NeutralOut())
self.flywheel_2.set_control(Follower(TalonId.FLYWHEEL_1, False))
Expand Down
6 changes: 3 additions & 3 deletions controllers/reef_intake.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ def touch_the_algae(self, initial_call: bool):
self.done()
return

self.algae_manipulator_component.set_feeler(self.current_feeler_angle)
self.algae_manipulator_component.set_feeler(self.current_feeler_angle, True)

if self.algae_manipulator_component.feeler_limit_switch:
if self.algae_manipulator_component.feeler_touching_algae():
self.algae_manipulator_component.algae_size = self.current_feeler_angle
self.done()
return
Expand All @@ -68,4 +68,4 @@ def done(self) -> None:
super().done()
self.wrist.go_to_neutral()
self.current_feeler_angle = self.FEELER_START_ANGLE
self.algae_manipulator_component.set_feeler(self.current_feeler_angle)
self.algae_manipulator_component.set_feeler(self.current_feeler_angle, True)

0 comments on commit 1f8e717

Please sign in to comment.