kuukar-rpi/MainRobotLane.py

41 lines
949 B
Python

import cv2
from kuukar.kuukar import kuukar
from LaneDetectionModule import getLaneCurve
from utils import initializeTrackbars
import WebcamModule
car = kuukar()
##################################################
############### MAIN ROBOT LANE ##################
##################################################
def main():
img = WebcamModule.getImg()
curveVal= getLaneCurve(img,2)
sen = 1.3 # SENSITIVITY
maxVAl= 1.0 # MAX SPEED
if curveVal>maxVAl:curveVal = maxVAl
if curveVal<-maxVAl: curveVal =-maxVAl
#print(curveVal)
if curveVal>0:
sen =1.7
if curveVal<0.05: curveVal=0
else:
if curveVal>-0.08: curveVal=0
car.motion.skt_drive(0.15,-curveVal*sen,0.05)
print(curveVal)
cv2.waitKey(1)
if __name__ == '__main__':
initialTrackBarVals = [98, 141, 77, 220]
initializeTrackbars(initialTrackBarVals)
while True:
main()