From 69508f3556c612d1df60952dc9b3471422e9d7d1 Mon Sep 17 00:00:00 2001 From: Rick Rongen Date: Sun, 17 May 2020 20:03:14 +0200 Subject: [PATCH] feat: fixed incorrect mapping eyes --- control/walle.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/control/walle.py b/control/walle.py index 6a9b0ce..538878f 100644 --- a/control/walle.py +++ b/control/walle.py @@ -59,7 +59,11 @@ class WallE: self.motor_a.set(velocity_l) self.motor_b.set(velocity_r) - def set_eye_velocity(self, up_down: float, left_right: float): + def set_eye_velocity(self, angle: float, distance: float): + if distance > 1: + distance = 1 + up_down = distance * math.sin(angle) + left_right = distance * math.cos(angle) minval = 50 maxval = 130 self.servo_controller.write(SERVO_ARM_L, map_range(up_down, 0.0, 1.0, minval, maxval))