Skip to content

Commit 73ab0c9

Browse files
committed
Configure head_tracking node that manages servos. Fixes flipping PID smoothing error value in x (pan) from negative to positive.
The PID error flipping was required because of the new servos and their configuration for min and max values
1 parent 7263a64 commit 73ab0c9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

coffee_ws/src/coffee_head/coffee_head/head_tracking.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,16 @@ def __init__(self, node):
117117

118118
# Pan/tilt motor IDs and parameters
119119
self.pan_motor_id = 1
120-
self.tilt_motor_id = 2
120+
self.tilt_motor_id = 9 # TODO: FIX NAMING AND NUMBERING
121121

122122
# Motor angle limits (in degrees)
123-
self.pan_min_angle = 0.01 # Min pan angle (right)
124-
self.pan_max_angle = 180.0 # Max pan angle (left)
125-
self.tilt_min_angle = 135.0 # Min tilt angle (up)
126-
self.tilt_max_angle = 225.0 # Max tilt angle (down)
123+
self.pan_min_angle = 143.0 # Min pan angle (right)
124+
self.pan_max_angle = 210.0 # Max pan angle (left)
125+
self.tilt_min_angle = 169.0 # Min tilt angle (up)
126+
self.tilt_max_angle = 206.0 # Max tilt angle (down)
127127

128128
# Default positions (center)
129-
self.default_pan_angle = 90.0 # degrees (center)
129+
self.default_pan_angle = 180.0 # degrees (center)
130130
self.default_tilt_angle = 180.0 # degrees (center)
131131

132132
self.current_pan_position = 0
@@ -495,7 +495,7 @@ def calculate_coordinated_movement(self, face):
495495
if self.use_pid_smoothing:
496496
# PID-based approach
497497
# Calculate the adjustments using PIDs, but only if needed
498-
pan_adjustment = self.pan_pid.compute(0, -error_x) if need_pan_movement else 0
498+
pan_adjustment = self.pan_pid.compute(0, error_x) if need_pan_movement else 0
499499
tilt_adjustment = self.tilt_pid.compute(0, -error_y) if need_tilt_movement else 0
500500

501501
# Calculate new angles

0 commit comments

Comments
 (0)