kuukar-rpi/MainRobotLane.py

43 lines
1.0 KiB
Python
Raw Normal View History

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)
2022-12-11 07:51:17 +00:00
sen = 0.8 # 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
2022-12-11 08:51:35 +00:00
car.motion.skt_drive(0.4,-curveVal*sen,0.05)
2022-12-11 08:05:01 +00:00
turn_value = -curveVal*sen
2022-12-11 14:34:17 +00:00
print("Curve Value : " + str(curveVal) + " Turn Value : "+ str(round(turn_value,2))
cv2.waitKey(1)
if __name__ == '__main__':
2022-12-11 07:51:17 +00:00
initialTrackBarVals = [70, 124, 4, 195]
initializeTrackbars(initialTrackBarVals)
while True:
2022-12-11 07:51:17 +00:00
main()