From 495a233594dad21b34d6d74471c5295996202eac Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Sat, 10 Dec 2022 17:09:04 +0700 Subject: [PATCH] Update kuukar_motion.py --- kuukar/kuukar_motion.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/kuukar/kuukar_motion.py b/kuukar/kuukar_motion.py index db951e9..f3e5e9a 100644 --- a/kuukar/kuukar_motion.py +++ b/kuukar/kuukar_motion.py @@ -87,7 +87,8 @@ class motion: self.motor_write(MOTOR_FR_F, MOTOR_FR_R, rm_speed) self.motor_write(MOTOR_RL_F, MOTOR_RL_R, lm_speed) self.motor_write(MOTOR_RR_F, MOTOR_RR_R, rm_speed) - + + ''' def skt_drive(self, speed: float, turn: float, t=0): speed *=100 turn *=100 @@ -115,6 +116,24 @@ class motion: 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) + ''' + + def skt_drive(self, speed: float, turn: float, t=0): + speed *=100 + turn *=100 + leftSpeed = speed - turn + rightSpeed = speed + turn + if leftSpeed>99: leftSpeed=99 + elif leftSpeed<-99: leftSpeed= -99 + if rightSpeed>99: rightSpeed=99 + elif rightSpeed<-99: rightSpeed= -99 + 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)