MCPcopy Create free account
hub / github.com/OpenDriveLab/DriveAdapter / start

Method start

scenario_runner/no_rendering_mode.py:836–886  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

834 exit_game()
835
836 def start(self):
837 self.world, self.town_map = self._get_data_from_carla()
838
839 # Create Surfaces
840 self.map_image = MapImage(
841 carla_world=self.world,
842 carla_map=self.town_map,
843 pixels_per_meter=PIXELS_PER_METER,
844 show_triggers=self.args.show_triggers,
845 show_connections=self.args.show_connections,
846 show_spawn_points=self.args.show_spawn_points)
847
848 # Store necessary modules
849 self.module_hud = module_manager.get_module(MODULE_HUD)
850 self.module_input = module_manager.get_module(MODULE_INPUT)
851
852 self.original_surface_size = min(self.module_hud.dim[0], self.module_hud.dim[1])
853 self.surface_size = self.map_image.big_map_surface.get_width()
854
855 self.scaled_size = int(self.surface_size)
856 self.prev_scaled_size = int(self.surface_size)
857
858 # Render Actors
859 self.actors_surface = pygame.Surface((self.map_image.surface.get_width(), self.map_image.surface.get_height()))
860 self.actors_surface.set_colorkey(COLOR_BLACK)
861
862 self.vehicle_id_surface = pygame.Surface((self.surface_size, self.surface_size)).convert()
863 self.vehicle_id_surface.set_colorkey(COLOR_BLACK)
864
865 self.border_round_surface = pygame.Surface(self.module_hud.dim, pygame.SRCALPHA).convert()
866 self.border_round_surface.set_colorkey(COLOR_WHITE)
867 self.border_round_surface.fill(COLOR_BLACK)
868
869 center_offset = (int(self.module_hud.dim[0] / 2), int(self.module_hud.dim[1] / 2))
870 pygame.draw.circle(self.border_round_surface, COLOR_ALUMINIUM_1, center_offset, int(self.module_hud.dim[1] / 2))
871 pygame.draw.circle(self.border_round_surface, COLOR_WHITE, center_offset, int((self.module_hud.dim[1] - 8) / 2))
872
873 scaled_original_size = self.original_surface_size * (1.0 / 0.9)
874 self.hero_surface = pygame.Surface((scaled_original_size, scaled_original_size)).convert()
875
876 self.result_surface = pygame.Surface((self.surface_size, self.surface_size)).convert()
877 self.result_surface.set_colorkey(COLOR_BLACK)
878
879 # Start hero mode by default
880 self.select_hero_actor()
881 self.hero_actor.set_autopilot(False)
882 self.module_input.wheel_offset = HERO_DEFAULT_SCALE
883 self.module_input.control = carla.VehicleControl()
884
885 weak_self = weakref.ref(self)
886 self.world.on_tick(lambda timestamp: ModuleWorld.on_world_tick(weak_self, timestamp))
887
888 def select_hero_actor(self):
889 hero_vehicles = [actor for actor in self.world.get_actors(

Callers

nothing calls this directly

Calls 5

_get_data_from_carlaMethod · 0.95
select_hero_actorMethod · 0.95
MapImageClass · 0.85
get_moduleMethod · 0.80
on_world_tickMethod · 0.80

Tested by

no test coverage detected