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

Method restart

PythonAPI/examples/automatic_control.py:104–134  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

102 self.recording_start = 0
103
104 def restart(self):
105 # Keep same camera config if the camera manager exists.
106 cam_index = self.camera_manager.index if self.camera_manager is not None else 0
107 cam_pos_index = self.camera_manager.transform_index if self.camera_manager is not None else 0
108 # Get a random blueprint.
109 blueprint = random.choice(self.world.get_blueprint_library().filter(self._actor_filter))
110 blueprint.set_attribute('role_name', 'hero')
111 if blueprint.has_attribute('color'):
112 color = random.choice(blueprint.get_attribute('color').recommended_values)
113 blueprint.set_attribute('color', color)
114 # Spawn the player.
115 if self.player is not None:
116 spawn_point = self.player.get_transform()
117 spawn_point.location.z += 2.0
118 spawn_point.rotation.roll = 0.0
119 spawn_point.rotation.pitch = 0.0
120 self.destroy()
121 self.player = self.world.try_spawn_actor(blueprint, spawn_point)
122 while self.player is None:
123 spawn_points = self.map.get_spawn_points()
124 spawn_point = random.choice(spawn_points) if spawn_points else carla.Transform()
125 self.player = self.world.try_spawn_actor(blueprint, spawn_point)
126 # Set up the sensors.
127 self.collision_sensor = CollisionSensor(self.player, self.hud)
128 self.lane_invasion_sensor = LaneInvasionSensor(self.player, self.hud)
129 self.gnss_sensor = GnssSensor(self.player)
130 self.camera_manager = CameraManager(self.player, self.hud)
131 self.camera_manager.transform_index = cam_pos_index
132 self.camera_manager.set_sensor(cam_index, notify=False)
133 actor_type = get_actor_display_name(self.player)
134 self.hud.notification(actor_type)
135
136 def next_weather(self, reverse=False):
137 self._weather_index += -1 if reverse else 1

Callers 1

__init__Method · 0.95

Calls 9

destroyMethod · 0.95
CollisionSensorClass · 0.70
LaneInvasionSensorClass · 0.70
GnssSensorClass · 0.70
CameraManagerClass · 0.70
get_actor_display_nameFunction · 0.70
TransformMethod · 0.45
set_sensorMethod · 0.45
notificationMethod · 0.45

Tested by

no test coverage detected