Update kuukar_motion.py

This commit is contained in:
Siwat Sirichai 2022-12-10 15:49:32 +07:00
parent 6318032820
commit edad44b715
1 changed files with 10 additions and 8 deletions

View File

@ -93,15 +93,17 @@ class motion:
turn *=100 turn *=100
leftSpeed = speed - turn leftSpeed = speed - turn
rightSpeed = speed + turn rightSpeed = speed + turn
if leftSpeed>100: leftSpeed=100 if leftSpeed>990: leftSpeed=990
elif leftSpeed<-100: leftSpeed= -100 elif leftSpeed<-990: leftSpeed= -990
if rightSpeed>100: rightSpeed=100 if rightSpeed>990: rightSpeed=990
elif rightSpeed<-100: rightSpeed= -100 elif rightSpeed<-990: rightSpeed= -990
if speed>100: speed=100 if speed>990: speed=990
elif speed<-100: speed= -100 elif speed<-990: speed= -990
self.motor_write(MOTOR_FL_F, MOTOR_FL_R, abs(leftSpeed)) self.motor_write(MOTOR_FL_F, MOTOR_FL_R, abs(leftSpeed/10))
self.motor_write(MOTOR_FR_F, MOTOR_FR_R, abs(rightSpeed)) self.motor_write(MOTOR_FR_F, MOTOR_FR_R, abs(rightSpeed/10))
self.motor_write(MOTOR_RL_F, MOTOR_RL_R, speed/10)
self.motor_write(MOTOR_RR_F, MOTOR_RR_R, speed/10)