zappybiby / EuroTruckAutopilot

Autonomous Driving for Euro Truck Simulator 2
MIT License
12 stars 2 forks source link

Mouse Movement #5

Closed zappybiby closed 1 year ago

zappybiby commented 6 years ago

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.

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

  1. Calculate current x position by dividing width by 2
  2. Calculate difference between current x position and midpoint of third line.
  3. 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)
ajchili commented 6 years ago

@zappybiby are we looking into multi-platform support, or just windows?

zappybiby commented 6 years ago

https://gist.github.com/zappybiby/d9e99c152dbc26fdb02a0e710bc01da8