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

Method tick

PythonAPI/examples/manual_control_rss.py:437–503  ·  view source on GitHub ↗
(self, world, clock)

Source from the content-addressed store, hash-verified

435 self.simulation_time = timestamp.elapsed_seconds
436
437 def tick(self, world, clock):
438 self._notifications.tick(world, clock)
439 if not self._show_info:
440 return
441 t = world.player.get_transform()
442 v = world.player.get_velocity()
443 c = world.player.get_control()
444 heading = 'N' if abs(t.rotation.yaw) < 89.5 else ''
445 heading += 'S' if abs(t.rotation.yaw) > 90.5 else ''
446 heading += 'E' if 179.5 > t.rotation.yaw > 0.5 else ''
447 heading += 'W' if -0.5 > t.rotation.yaw > -179.5 else ''
448 colhist = world.collision_sensor.get_collision_history()
449 collision = [colhist[x + self.frame - 200] for x in range(0, 200)]
450 max_col = max(1.0, max(collision))
451 collision = [x / max_col for x in collision]
452 vehicles = world.world.get_actors().filter('vehicle.*')
453 self._info_text = [
454 'Server: % 16.0f FPS' % self.server_fps,
455 'Client: % 16.0f FPS' % clock.get_fps(),
456 '',
457 'Vehicle: % 20s' % get_actor_display_name(world.player, truncate=20),
458 'Map: % 20s' % world.map.name,
459 'Simulation time: % 12s' % datetime.timedelta(seconds=int(self.simulation_time)),
460 '',
461 'Speed: % 15.0f km/h' % (3.6 * math.sqrt(v.x**2 + v.y**2 + v.z**2)),
462 u'Heading:% 16.0f\N{DEGREE SIGN} % 2s' % (t.rotation.yaw, heading),
463 'Location:% 20s' % ('(% 5.1f, % 5.1f)' % (t.location.x, t.location.y)),
464 'GNSS:% 24s' % ('(% 2.6f, % 3.6f)' % (world.gnss_sensor.lat, world.gnss_sensor.lon)),
465 'Height: % 18.0f m' % t.location.z,
466 '']
467 if isinstance(c, carla.VehicleControl):
468 if isinstance(self.original_vehicle_control, carla.VehicleControl):
469 orig_control = self.original_vehicle_control
470 restricted_control = self.restricted_vehicle_control
471 self._info_text += [
472 ('Throttle:', orig_control.throttle, 0.0, 1.0, restricted_control.throttle),
473 ('Steer:', orig_control.steer, -1.0, 1.0, restricted_control.steer),
474 ('Brake:', orig_control.brake, 0.0, 1.0, restricted_control.brake)]
475 else:
476 self._info_text += [
477 ('Throttle:', c.throttle, 0.0, 1.0),
478 ('Steer:', c.steer, -1.0, 1.0),
479 ('Brake:', c.brake, 0.0, 1.0)]
480 self._info_text += [
481 ('Reverse:', c.reverse),
482 ('Hand brake:', c.hand_brake),
483 ('Manual:', c.manual_gear_shift),
484 'Gear: %s' % {-1: 'R', 0: 'N'}.get(c.gear, c.gear)]
485 elif isinstance(c, carla.WalkerControl):
486 self._info_text += [
487 ('Speed:', c.speed, 0.0, 5.556),
488 ('Jump:', c.jump)]
489 self._info_text += [
490 '',
491 'Collision:',
492 collision,
493 '',
494 'Number of vehicles: % 8d' % len(vehicles)]

Callers 2

tickMethod · 0.45
on_world_tickMethod · 0.45

Calls 6

absFunction · 0.85
get_fpsMethod · 0.80
get_actor_display_nameFunction · 0.70
get_collision_historyMethod · 0.45
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected