skt drive

This commit is contained in:
Siwat Sirichai 2022-12-10 14:20:28 +07:00
parent 01cb139802
commit 04c1f51b88
1 changed files with 16 additions and 0 deletions

View File

@ -88,6 +88,22 @@ class motion:
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
leftSpeed = speed - turn
rightSpeed = speed + turn
if leftSpeed>100: leftSpeed=100
elif leftSpeed<-100: leftSpeed= -100
if rightSpeed>100: rightSpeed=100
elif rightSpeed<-100: rightSpeed= -100
self.motor_write(MOTOR_FL_F, MOTOR_FL_R, speed)
self.motor_write(MOTOR_FR_F, MOTOR_FR_R, speed)
self.motor_write(MOTOR_RL_F, MOTOR_RL_R, speed)
self.motor_write(MOTOR_RR_F, MOTOR_RR_R, speed)
def stop(self):
self.leds.set_left_signal_led(False)
self.leds.set_right_signal_led(False)