Compare commits

...

2 Commits

Author SHA1 Message Date
Siwat Sirichai 04c1f51b88 skt drive 2022-12-10 14:20:28 +07:00
Siwat Sirichai 01cb139802 change_Track 2022-12-10 14:20:20 +07:00
2 changed files with 17 additions and 1 deletions

View File

@ -79,7 +79,7 @@ def getLaneCurve(img, display = 2):
if __name__ == '__main__':
cap = cv2.VideoCapture(0)
initialTrackBarVals = [96, 139, 48, 218]
initialTrackBarVals = [96, 139, 15, 218]
utils.initializeTrackbars(initialTrackBarVals)
frameCounter = 0
curveList = []

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)