MCPcopy Create free account
hub / github.com/AdaCompNUS/summit / gamma_loop

Function gamma_loop

PythonAPI/examples/gamma_crowd.py:1275–1355  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

1273
1274
1275def gamma_loop(args):
1276 try:
1277 # Wait for crowd service.
1278 time.sleep(3)
1279 c = Context(args)
1280 print('GAMMA loop running.')
1281
1282 car_agents = []
1283 bike_agents = []
1284 pedestrian_agents = []
1285 statistics_file = open('statistics.log', 'w')
1286 statistics = Statistics(statistics_file)
1287 statistics.start_time = time.time()
1288
1289 last_bounds_update = None
1290
1291 rate_statistics_start = None
1292 rate_statistics_count = 0
1293 rate_statistics_done = False
1294
1295 while True:
1296 destroy_list = []
1297 start = time.time()
1298
1299 # Download bounds.
1300 # Required for death process.
1301 if last_bounds_update is None or start - last_bounds_update > 1.0:
1302
1303 new_bounds = c.crowd_service.simulation_bounds
1304 if (new_bounds[0] is not None and new_bounds[0] != c.bounds_min) or \
1305 (new_bounds[1] is not None and new_bounds[1] != c.bounds_max):
1306 c.bounds_min = new_bounds[0]
1307 c.bounds_max = new_bounds[1]
1308 c.bounds_occupancy = carla.OccupancyMap(c.bounds_min, c.bounds_max)
1309
1310 new_forbidden_bounds = c.crowd_service.forbidden_bounds
1311 if (new_forbidden_bounds[0] is not None and new_forbidden_bounds[0] != c.forbidden_bounds_min) or \
1312 (new_forbidden_bounds[1] is not None and new_forbidden_bounds[1] != c.forbidden_bounds_max):
1313 c.forbidden_bounds_min = new_forbidden_bounds[0]
1314 c.forbidden_bounds_max = new_forbidden_bounds[1]
1315 c.forbidden_bounds_occupancy = carla.OccupancyMap(c.forbidden_bounds_min, c.forbidden_bounds_max)
1316
1317 last_bounds_update = time.time()
1318
1319 # TODO: Maybe an functional-immutable interface wasn't the best idea...
1320
1321 # Do this first if not new agents from pull_new_agents will affect avg. speed.
1322 (statistics) = \
1323 do_speed_statistics(c, car_agents, bike_agents, pedestrian_agents, statistics)
1324
1325 (car_agents, bike_agents, pedestrian_agents, statistics) = \
1326 pull_new_agents(c, car_agents, bike_agents, pedestrian_agents, statistics)
1327
1328 (car_agents, bike_agents, pedestrian_agents, destroy_list) = \
1329 do_gamma(c, car_agents, bike_agents, pedestrian_agents, destroy_list)
1330
1331 (car_agents, bike_agents, pedestrian_agents, destroy_list, statistics) = \
1332 do_death(c, car_agents, bike_agents, pedestrian_agents, destroy_list, statistics)

Callers

nothing calls this directly

Calls 10

ContextClass · 0.85
StatisticsClass · 0.85
do_speed_statisticsFunction · 0.85
pull_new_agentsFunction · 0.85
do_gammaFunction · 0.85
do_deathFunction · 0.85
OccupancyMapMethod · 0.80
acquire_destroy_listMethod · 0.80
extend_destroy_listMethod · 0.80
release_destroy_listMethod · 0.80

Tested by

no test coverage detected