(self)
| 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() |
no test coverage detected