Implementing mouse movement into our program will allow it to drive the truck autonomously.
The two modules that could be used to do this are pyautogui using its moveTo() function and win32api using its mouse_event function as done here.
Calculate current x position by dividing width by 2
Calculate difference between current x position and midpoint of third line.
Use PID controller to determine amount to move mouse cursor by
3a. Calculate max amount of pixels that the cursor can move before the lane is lost (approx. 65 pixels)
3b. Divide #2 by #3a
3c. Create a variable called turning_speed which dictates the rate at which the wheel will turn (usually 1 / #3a
3d. Multiply #3b by #3c
3e. [optional] if #3d is > some_number, initiate turn (to prevent overcorrection)
Implementing mouse movement into our program will allow it to drive the truck autonomously. The two modules that could be used to do this are
pyautogui
using its moveTo() function andwin32api
using its mouse_event function as done here.We can find the midpoint of the line that connects the left and right lane lines produced by our program in the Experimental branch https://github.com/zappybiby/EuroTruckAutopilot/blob/EXPERIMENTAL/hough_lines.py#L16 to determine the center of the lane.
Here wot I think
#2
by#3a
3c. Create a variable called turning_speed which dictates the rate at which the wheel will turn (usually1 / #3a
3d. Multiply#3b
by#3c
3e. [optional]if #3d is > some_number
, initiate turn (to prevent overcorrection)