Skip to content

Commit 76b9d52

Browse files
committed
intake: Simplify arm encoder offset calculations
1 parent 3a060a5 commit 76b9d52

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

components/intake.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ class IntakeComponent:
2121

2222
# Offset is measured in the vertical position
2323
VERTICAL_ENCODER_VALUE = 2.365140
24+
ARM_ENCODER_OFFSET = VERTICAL_ENCODER_VALUE - math.pi / 2.0
2425
# magic offset the deployed angle by 4 degrees to limit damage inflicted on mechanism
25-
DEPLOYED_ANGLE = 1.194348 - VERTICAL_ENCODER_VALUE + math.pi / 2.0 + math.radians(4)
26-
RETRACTED_ANGLE = 2.365140 - VERTICAL_ENCODER_VALUE + math.pi / 2.0
26+
DEPLOYED_ANGLE = 1.194348 - ARM_ENCODER_OFFSET + math.radians(4)
27+
RETRACTED_ANGLE = 2.365140 - ARM_ENCODER_OFFSET
2728

2829
gear_ratio = 4.0 * 5.0 * (48.0 / 40.0)
2930

@@ -89,9 +90,7 @@ def raw_encoder(self) -> float:
8990
return self.encoder.get()
9091

9192
def position(self):
92-
return (
93-
self.encoder.get() - IntakeComponent.VERTICAL_ENCODER_VALUE + math.pi / 2.0
94-
)
93+
return self.encoder.get() - IntakeComponent.ARM_ENCODER_OFFSET
9594

9695
def velocity(self) -> float:
9796
return self.motor_encoder.getVelocity()

0 commit comments

Comments
 (0)