forked from x2ever/Autonomous-Car-Simulator
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
45 lines (38 loc) · 1.17 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import argparse
import os
import threading
import pygame
from Brain import Brain
from Control import Control
from Course import Map1, Map2, Map3, Map4
from Database import Database
from Game import Game
from LiDAR import LiDAR
def main(auto):
os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (500, 30)
_ = (Map1, Map2, Map3, Map4)
walls, trophies, parkings, crosswalks, traffic_signs, car = Map2
lidar = LiDAR()
control = Control()
database = Database(lidar, control, car)
# Get LiDAR data, Set Control data
brain = Brain(database)
# Get Control data Set LiDAR data
game = Game(walls, trophies, parkings,
crosswalks, traffic_signs, car, database)
if auto:
brain_thread = threading.Thread(target=brain.run,)
brain_thread.start()
game.run(auto=auto)
pygame.quit()
return 0
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"--auto",
help="Do not use your keyboard command,\
but use pre-defined brain's command.",
action="store_true", default=True
)
args = parser.parse_args()
main(args.auto)