(self, world, clock)
| 216 | self.simulation_time = timestamp.elapsed_seconds |
| 217 | |
| 218 | def tick(self, world, clock): |
| 219 | self._notifications.tick(world, clock) |
| 220 | if not self._show_info: |
| 221 | return |
| 222 | t = world.player.get_transform() |
| 223 | v = world.player.get_velocity() |
| 224 | c = world.player.get_control() |
| 225 | heading = 'N' if abs(t.rotation.yaw) < 89.5 else '' |
| 226 | heading += 'S' if abs(t.rotation.yaw) > 90.5 else '' |
| 227 | heading += 'E' if 179.5 > t.rotation.yaw > 0.5 else '' |
| 228 | heading += 'W' if -0.5 > t.rotation.yaw > -179.5 else '' |
| 229 | colhist = world.collision_sensor.get_collision_history() |
| 230 | collision = [colhist[x + self.frame - 200] for x in range(0, 200)] |
| 231 | max_col = max(1.0, max(collision)) |
| 232 | collision = [x / max_col for x in collision] |
| 233 | vehicles = world.world.get_actors().filter('vehicle.*') |
| 234 | self._info_text = [ |
| 235 | 'Server: % 16.0f FPS' % self.server_fps, |
| 236 | 'Client: % 16.0f FPS' % clock.get_fps(), |
| 237 | '', |
| 238 | 'Vehicle: % 20s' % get_actor_display_name(world.player, truncate=20), |
| 239 | 'Map: % 20s' % world.map.name, |
| 240 | 'Simulation time: % 12s' % datetime.timedelta(seconds=int(self.simulation_time)), |
| 241 | '', |
| 242 | 'Speed: % 15.0f km/h' % (3.6 * math.sqrt(v.x ** 2 + v.y ** 2 + v.z ** 2)), |
| 243 | u'Heading:% 16.0f\N{DEGREE SIGN} % 2s' % (t.rotation.yaw, heading), |
| 244 | 'Location:% 20s' % ('(% 5.1f, % 5.1f)' % (t.location.x, t.location.y)), |
| 245 | 'GNSS:% 24s' % ('(% 2.6f, % 3.6f)' % (world.gnss_sensor.lat, world.gnss_sensor.lon)), |
| 246 | 'Height: % 18.0f m' % t.location.z, |
| 247 | ''] |
| 248 | if isinstance(c, carla.VehicleControl): |
| 249 | self._info_text += [ |
| 250 | ('Throttle:', c.throttle, 0.0, 1.0), |
| 251 | ('Steer:', c.steer, -1.0, 1.0), |
| 252 | ('Brake:', c.brake, 0.0, 1.0), |
| 253 | ('Reverse:', c.reverse), |
| 254 | ('Hand brake:', c.hand_brake), |
| 255 | ('Manual:', c.manual_gear_shift), |
| 256 | 'Gear: %s' % {-1: 'R', 0: 'N'}.get(c.gear, c.gear)] |
| 257 | elif isinstance(c, carla.WalkerControl): |
| 258 | self._info_text += [ |
| 259 | ('Speed:', c.speed, 0.0, 5.556), |
| 260 | ('Jump:', c.jump)] |
| 261 | self._info_text += [ |
| 262 | '', |
| 263 | 'Collision:', |
| 264 | collision, |
| 265 | '', |
| 266 | 'Number of vehicles: % 8d' % len(vehicles)] |
| 267 | if len(vehicles) > 1: |
| 268 | self._info_text += ['Nearby vehicles:'] |
| 269 | |
| 270 | def distance(l): return math.sqrt( |
| 271 | (l.x - t.location.x) ** 2 + (l.y - t.location.y) ** 2 + (l.z - t.location.z) ** 2) |
| 272 | vehicles = [(distance(x.get_location()), x) for x in vehicles if x.id != world.player.id] |
| 273 | for d, vehicle in sorted(vehicles): |
| 274 | if d > 200.0: |
| 275 | break |
no test coverage detected