-
Notifications
You must be signed in to change notification settings - Fork 1
/
check_env.py
152 lines (142 loc) · 4.34 KB
/
check_env.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import carla
import Controller.MPCController as MPCController
from Utils.HUD import HUD as HUD
from World import World
from stable_baselines3.common.env_checker import check_env
import argparse
argparser = argparse.ArgumentParser(
description='CARLA Manual Control Client')
argparser.add_argument(
'-v', '--verbose',
action='store_true',
dest='debug',
help='print debug information')
argparser.add_argument(
'--host',
metavar='H',
default='127.0.0.1',
help='IP of the host server (default: 127.0.0.1)')
argparser.add_argument(
'-p', '--port',
metavar='P',
default=2000,
type=int,
help='TCP port to listen to (default: 2000)')
argparser.add_argument(
'-a', '--autopilot',
action='store_true',
help='enable autopilot')
argparser.add_argument(
'--res',
metavar='WIDTHxHEIGHT',
default='1280x720',
help='window resolution (default: 1280x720)')
argparser.add_argument(
'--filter',
metavar='PATTERN',
default='vehicle.*',
help='actor filter (default: "vehicle.*")')
argparser.add_argument(
'--rolename',
metavar='NAME',
default='hero',
help='actor role name (default: "hero")')
argparser.add_argument(
'--gamma',
default=2.2,
type=float,
help='Gamma correction of the camera (default: 2.2)')
argparser.add_argument(
'--map',
metavar='NAME',
default='Town04',
help='simulation map (default: "Town04")')
argparser.add_argument(
'--spawn_x',
metavar='x',
default='-16.75', #town04 = -16.75
help='x position to spawn the agent')
argparser.add_argument(
'--spawn_y',
metavar='y',
default='-223.55', #town04 = -223.55
help='y position to spawn the agent')
argparser.add_argument(
'--random_spawn',
metavar='RS',
default='0',
type=int,
help='Random spawn agent')
argparser.add_argument(
'--vehicle_id',
metavar='NAME',
# default='vehicle.jeep.wrangler_rubicon',
default='vehicle.tesla.model3',
help='vehicle to spawn, available options : vehicle.audi.a2 vehicle.audi.tt vehicle.carlamotors.carlacola vehicle.citroen.c3 vehicle.dodge_charger.police vehicle.jeep.wrangler_rubicon vehicle.yamaha.yzf vehicle.nissan.patrol vehicle.gazelle.omafiets vehicle.bh.crossbike vehicle.ford.mustang vehicle.bmw.isetta vehicle.audi.etron vehicle.harley-davidson.low rider vehicle.mercedes-benz.coupe vehicle.bmw.grandtourer vehicle.toyota.prius vehicle.diamondback.century vehicle.tesla.model3 vehicle.seat.leon vehicle.lincoln.mkz2017 vehicle.kawasaki.ninja vehicle.volkswagen.t2 vehicle.nissan.micra vehicle.chevrolet.impala vehicle.mini.cooperst')
argparser.add_argument(
'--vehicle_wheelbase',
metavar='NAME',
type=float,
default='2.89',
help='vehicle wheelbase used for model predict control')
argparser.add_argument(
'--waypoint_resolution',
metavar='WR',
default='1',
type=float,
help='waypoint resulution for control')
argparser.add_argument(
'--waypoint_lookahead_distance',
metavar='WLD',
default='5',
type=float,
help='waypoint look ahead distance for control')
argparser.add_argument(
'--desired_speed',
metavar='SPEED',
default='15',
type=float,
help='desired speed for highway driving')
argparser.add_argument(
'--control_mode',
metavar='CONT',
default='PID',
help='Controller')
argparser.add_argument(
'--planning_horizon',
metavar='HORIZON',
type=int,
default='5',
help='Planning horizon for MPC')
argparser.add_argument(
'--time_step',
metavar='DT',
default='0.15',
type=float,
help='Planning time step for MPC')
argparser.add_argument(
'--FPS',
metavar='FPS',
default='30',
type=int,
help='Frame per second for simulation')
args = argparser.parse_args()
args.width, args.height = [int(x) for x in args.res.split('x')]
try:
client = carla.Client('127.0.0.1', 2000)
client.set_timeout(100.0)
# carla_world = client.load_world(args.map)
carla_world = client.get_world()
carla_world.apply_settings(carla.WorldSettings(
no_rendering_mode=False,
synchronous_mode=True,
fixed_delta_seconds=1/30))
hud = HUD()
world = World(client, carla_world, hud, args)
# check_env(world)
world.reset()
# world.destroy()
finally:
# print(world.list_wp)
if world is not None:
world.destroy()