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

Function game_loop

PythonAPI/examples/automatic_control.py:579–624  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

577# ==============================================================================
578
579def game_loop(args):
580 pygame.init()
581 pygame.font.init()
582 world = None
583
584 try:
585 client = carla.Client(args.host, args.port)
586 client.set_timeout(4.0)
587
588 display = pygame.display.set_mode(
589 (args.width, args.height),
590 pygame.HWSURFACE | pygame.DOUBLEBUF)
591
592 hud = HUD(args.width, args.height)
593 world = World(client.get_world(), hud, args.filter)
594 controller = KeyboardControl(world)
595
596 if args.agent == "Roaming":
597 agent = RoamingAgent(world.player)
598 else:
599 agent = BasicAgent(world.player)
600 spawn_point = world.map.get_spawn_points()[0]
601 agent.set_destination((spawn_point.location.x,
602 spawn_point.location.y,
603 spawn_point.location.z))
604
605 clock = pygame.time.Clock()
606 while True:
607 if controller.parse_events():
608 return
609
610 # as soon as the server is ready continue!
611 world.world.wait_for_tick(10.0)
612
613 world.tick(clock)
614 world.render(display)
615 pygame.display.flip()
616 control = agent.run_step()
617 control.manual_gear_shift = False
618 world.player.apply_control(control)
619
620 finally:
621 if world is not None:
622 world.destroy()
623
624 pygame.quit()
625
626
627# ==============================================================================

Callers 1

mainFunction · 0.70

Calls 13

set_timeoutMethod · 0.95
set_destinationMethod · 0.95
parse_eventsMethod · 0.95
tickMethod · 0.95
renderMethod · 0.95
run_stepMethod · 0.95
destroyMethod · 0.95
RoamingAgentClass · 0.90
BasicAgentClass · 0.90
HUDClass · 0.70
WorldClass · 0.70
KeyboardControlClass · 0.70

Tested by

no test coverage detected