From e615010ce7fbe14d2ff9404f1529deaa6ff5c074 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Sat, 10 Dec 2022 16:30:42 +0700 Subject: [PATCH] Update kuukar_motion.py --- kuukar/kuukar_motion.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/kuukar/kuukar_motion.py b/kuukar/kuukar_motion.py index e6cd4da..ba66708 100644 --- a/kuukar/kuukar_motion.py +++ b/kuukar/kuukar_motion.py @@ -100,10 +100,21 @@ class motion: if speed>99: speed=99 elif speed<-99: speed= -99 - self.motor_write(MOTOR_FL_F, MOTOR_FL_R, abs(leftSpeed)) - self.motor_write(MOTOR_FR_F, MOTOR_FR_R, abs(rightSpeed)) - self.motor_write(MOTOR_RL_F, MOTOR_RL_R, speed) - self.motor_write(MOTOR_RR_F, MOTOR_RR_R, speed) + if (rightSpeed - leftSpeed) > 0: + self.motor_write(MOTOR_FL_F, MOTOR_FL_R, -1*abs(leftSpeed)) + self.motor_write(MOTOR_FR_F, MOTOR_FR_R, abs(rightSpeed)) + self.motor_write(MOTOR_RL_F, MOTOR_RL_R, speed) + self.motor_write(MOTOR_RR_F, MOTOR_RR_R, speed) + elif (rightSpeed - leftSpeed) < 0: + self.motor_write(MOTOR_FL_F, MOTOR_FL_R, abs(leftSpeed)) + self.motor_write(MOTOR_FR_F, MOTOR_FR_R, -1*abs(rightSpeed)) + self.motor_write(MOTOR_RL_F, MOTOR_RL_R, speed) + self.motor_write(MOTOR_RR_F, MOTOR_RR_R, speed) + else: + self.motor_write(MOTOR_FL_F, MOTOR_FL_R, abs(leftSpeed)) + self.motor_write(MOTOR_FR_F, MOTOR_FR_R, abs(rightSpeed)) + self.motor_write(MOTOR_RL_F, MOTOR_RL_R, speed) + self.motor_write(MOTOR_RR_F, MOTOR_RR_R, speed)