-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
43 lines (33 loc) · 1.09 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
## Python
from pathlib import Path
import time
import sys
## MMS
from trackmap_gui import TrackMapGUI
from vehicle_model import VehicleModel
from path_planning import PathPlanner
from motion_controller import MotionController
from keyboard_controller import KeyboardController
rate = 50.0
def main(keyboard=False):
track_csv = Path("./FSG2019.csv")
track_ref_csv = Path("./FSG2019_ref.csv")
gui = TrackMapGUI(track_csv)
vehicle = VehicleModel()
planner = PathPlanner(track_ref_csv)
if keyboard:
controller = KeyboardController()
else:
controller = MotionController()
while(True):
car = vehicle.get_state(1.0/rate)
next_reference = planner.get_next_reference(car)
next_controls = controller.get_controls(car, next_reference)
vehicle.set_control_inputs(next_controls)
gui.update_vehicle(car)
gui.update_reference(next_reference)
gui.event_loop()
time.sleep(1.0/rate)
if __name__ == "__main__":
keyboard = len(sys.argv) > 1 and sys.argv[1] == "keyboard"
main(keyboard)