@@ -339,16 +339,19 @@ def __init__(self, configs=None):
339
339
340
340
# Render related
341
341
Render .resize_screen (self ._render_x_res , self ._render_y_res )
342
-
342
+
343
343
self ._camera_poses , window_dim = Render .get_surface_poses (
344
- [self ._x_res , self ._y_res ], self ._actor_configs )
344
+ [self ._x_res , self ._y_res ], self ._actor_configs
345
+ )
345
346
346
347
if manual_control_count == 0 :
347
348
Render .resize_screen (window_dim [0 ], window_dim [1 ])
348
349
else :
349
350
self ._manual_control_render_pose = (0 , window_dim [1 ])
350
351
Render .resize_screen (
351
- max (self ._render_x_res , window_dim [0 ]), self ._render_y_res + window_dim [1 ])
352
+ max (self ._render_x_res , window_dim [0 ]),
353
+ self ._render_y_res + window_dim [1 ],
354
+ )
352
355
353
356
# Actions space
354
357
if self ._discrete_actions :
@@ -666,8 +669,7 @@ def _clear_server_state(self):
666
669
if self ._server_process :
667
670
if IS_WINDOWS_PLATFORM :
668
671
subprocess .call (
669
- ["taskkill" , "/F" , "/T" , "/PID" ,
670
- str (self ._server_process .pid )]
672
+ ["taskkill" , "/F" , "/T" , "/PID" , str (self ._server_process .pid )]
671
673
)
672
674
live_carla_processes .remove (self ._server_process .pid )
673
675
else :
@@ -780,7 +782,9 @@ def _spawn_new_actor(self, actor_id):
780
782
#: closest match
781
783
782
784
if actor_type == "pedestrian" :
783
- blueprints = self .world .get_blueprint_library ().filter ("walker" )
785
+ blueprints = self .world .get_blueprint_library ().filter (
786
+ "walker.pedestrian.*"
787
+ )
784
788
785
789
elif actor_type == "vehicle_4W" :
786
790
blueprints = self .world .get_blueprint_library ().filter ("vehicle" )
@@ -833,7 +837,12 @@ def _spawn_new_actor(self, actor_id):
833
837
self .world .tick ()
834
838
if vehicle is not None and vehicle .get_location ().z > 0.0 :
835
839
# Register it under traffic manager
836
- vehicle .set_autopilot (False , self ._traffic_manager .get_port ())
840
+ # Walker vehicle type does not have autopilot. Use walker controller ai
841
+ if actor_type == "pedestrian" :
842
+ # vehicle.set_simulate_physics(False)
843
+ pass
844
+ else :
845
+ vehicle .set_autopilot (False , self ._traffic_manager .get_port ())
837
846
break
838
847
# Wait to see if spawn area gets cleared before retrying
839
848
# time.sleep(0.5)
@@ -960,16 +969,18 @@ def _reset(self, clean_world=True):
960
969
# Manual Control
961
970
if actor_config ["manual_control" ]:
962
971
self ._control_clock = pygame .time .Clock ()
963
-
972
+
964
973
self ._manual_controller = KeyboardControl (
965
- self , actor_config ["auto_control" ])
974
+ self , actor_config ["auto_control" ]
975
+ )
966
976
self ._manual_controller .actor_id = actor_id
967
-
977
+
968
978
self .world .on_tick (self ._hud .on_world_tick )
969
979
self ._manual_control_camera_manager = CameraManager (
970
- self ._actors [actor_id ], self ._hud )
980
+ self ._actors [actor_id ], self ._hud
981
+ )
971
982
self ._manual_control_camera_manager .set_sensor (
972
- CAMERA_TYPES [' rgb' ].value - 1 , pos = 2 , notify = False
983
+ CAMERA_TYPES [" rgb" ].value - 1 , pos = 2 , notify = False
973
984
)
974
985
975
986
self ._start_coord .update (
@@ -1161,13 +1172,16 @@ def step(self, action_dict):
1161
1172
k for k , v in self ._actor_configs .items () if v .get ("render" , False )
1162
1173
]
1163
1174
if render_required :
1164
- images = {k : self ._decode_obs (k , v )
1165
- for k , v in obs_dict .items () if self ._actor_configs [k ]["render" ]}
1175
+ images = {
1176
+ k : self ._decode_obs (k , v )
1177
+ for k , v in obs_dict .items ()
1178
+ if self ._actor_configs [k ]["render" ]
1179
+ }
1166
1180
1167
1181
Render .multi_view_render (images , self ._camera_poses )
1168
1182
if self ._manual_controller is None :
1169
1183
Render .dummy_event_handler ()
1170
-
1184
+
1171
1185
return obs_dict , reward_dict , self ._done_dict , info_dict
1172
1186
except Exception :
1173
1187
print (
@@ -1214,12 +1228,21 @@ def _step(self, actor_id, action):
1214
1228
config = self ._actor_configs [actor_id ]
1215
1229
if config ["manual_control" ]:
1216
1230
self ._control_clock .tick (60 )
1217
- self ._manual_control_camera_manager ._hud .tick (self .world , self ._actors [actor_id ], self ._collisions [actor_id ], self ._control_clock )
1231
+ self ._manual_control_camera_manager ._hud .tick (
1232
+ self .world ,
1233
+ self ._actors [actor_id ],
1234
+ self ._collisions [actor_id ],
1235
+ self ._control_clock ,
1236
+ )
1218
1237
self ._manual_controller .parse_events (self , self ._control_clock )
1219
1238
1220
1239
# TODO: consider move this to Render as well
1221
- self ._manual_control_camera_manager .render (Render .get_screen (), self ._manual_control_render_pose )
1222
- self ._manual_control_camera_manager ._hud .render (Render .get_screen (), self ._manual_control_render_pose )
1240
+ self ._manual_control_camera_manager .render (
1241
+ Render .get_screen (), self ._manual_control_render_pose
1242
+ )
1243
+ self ._manual_control_camera_manager ._hud .render (
1244
+ Render .get_screen (), self ._manual_control_render_pose
1245
+ )
1223
1246
pygame .display .flip ()
1224
1247
elif config ["auto_control" ]:
1225
1248
if getattr (self ._actors [actor_id ], "set_autopilot" , 0 ):
@@ -1523,19 +1546,16 @@ def get_next_actions(measurements, is_discrete_actions):
1523
1546
1524
1547
1525
1548
if __name__ == "__main__" :
1526
- argparser = argparse .ArgumentParser (
1527
- description = "CARLA Manual Control Client" )
1528
- argparser .add_argument ("--scenario" , default = "3" ,
1529
- help = "print debug information" )
1549
+ argparser = argparse .ArgumentParser (description = "CARLA Manual Control Client" )
1550
+ argparser .add_argument ("--scenario" , default = "3" , help = "print debug information" )
1530
1551
# TODO: Fix the default path to the config.json;Should work after packaging
1531
1552
argparser .add_argument (
1532
1553
"--config" ,
1533
1554
default = "src/macad_gym/carla/config.json" ,
1534
1555
help = "print debug information" ,
1535
1556
)
1536
1557
1537
- argparser .add_argument ("--map" , default = "Town01" ,
1538
- help = "print debug information" )
1558
+ argparser .add_argument ("--map" , default = "Town01" , help = "print debug information" )
1539
1559
1540
1560
args = argparser .parse_args ()
1541
1561
0 commit comments