-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
84 lines (67 loc) · 2.37 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import video_labeler
import recorder
import spawn
import cv2
import glob
import time
import os
import sys
try:
sys.path.append(glob.glob('../carla/dist/carla-*%d.%d-%s.egg' % (
sys.version_info.major,
sys.version_info.minor,
'win-amd64' if os.name == 'nt' else 'linux-x86_64'))[0])
except IndexError:
pass
import carla
from carla import Transform
from carla import Location, Rotation
from carla import ColorConverter as cc
if __name__ == "__main__":
order = sys.argv[-1]
info_file = "/home/oguzhan/PycharmProjects/carla/out/info_{}.txt".format(order)
video_file = "/home/oguzhan/PycharmProjects/carla/out/video_{}.mp4".format(order)
log_file = "/home/oguzhan/PycharmProjects/carla/out/log_{}.csv".format(order)
labeled_file = "/home/oguzhan/PycharmProjects/carla/out/labeled_{}.mp4".format(order)
fps = 0.033
num_vehics = 10
end_step = 15000
client = carla.Client('192.168.12.211', 2000)
client.set_timeout(10.0)
world = client.get_world()
settings = world.get_settings()
if not settings.synchronous_mode:
settings.synchronous_mode = True
settings.fixed_delta_seconds = fps
world.apply_settings(settings)
record = recorder.Recorder(world=world,
video_file=video_file,
log_file=log_file,
info_file=info_file,
order=order)
spawner = spawn.Spawn(world=world)
start_time = 0.0
for i in range(num_vehics):
spawner.spawn_actor(actor_type="vehicle")
try:
k = 0
while True:
k += 1
server_time = world.tick()
cur_time = world.get_snapshot().platform_timestamp
if start_time == 0.0:
start_time = cur_time
print("\rELAPSED TIME: {}".format(k * 0.033), end="", flush=True)
record.log_actors(server_time)
frame = record.record_img(server_time)
record.move_2((cur_time - start_time) / 1000)
if k > end_step:
break
raise KeyboardInterrupt
except KeyboardInterrupt:
del record
del spawner
video_labeler.label_video(log_file=log_file,
video_file=video_file,
out_file=labeled_file)
print('Exit')