MCPcopy Create free account
hub / github.com/OpenDriveLab/TCP / _spawn_hero

Method _spawn_hero

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

Source from the content-addressed store, hash-verified

895 self._spawn_hero()
896
897 def _spawn_hero(self):
898 # Get a random blueprint.
899 blueprint = random.choice(self.world.get_blueprint_library().filter(self.args.filter))
900 blueprint.set_attribute('role_name', 'hero')
901 if blueprint.has_attribute('color'):
902 color = random.choice(blueprint.get_attribute('color').recommended_values)
903 blueprint.set_attribute('color', color)
904 # Spawn the player.
905 while self.hero_actor is None:
906 spawn_points = self.world.get_map().get_spawn_points()
907 spawn_point = random.choice(spawn_points) if spawn_points else carla.Transform()
908 self.hero_actor = self.world.try_spawn_actor(blueprint, spawn_point)
909 self.hero_transform = self.hero_actor.get_transform()
910
911 # Save it in order to destroy it when closing program
912 self.spawned_hero = self.hero_actor
913
914 def tick(self, clock):
915 actors = self.world.get_actors()

Callers 1

select_hero_actorMethod · 0.95

Calls 2

get_mapMethod · 0.80
get_transformMethod · 0.80

Tested by

no test coverage detected