(self, clock)
| 919 | self.update_hud_info(clock) |
| 920 | |
| 921 | def update_hud_info(self, clock): |
| 922 | hero_mode_text = [] |
| 923 | if self.hero_actor is not None: |
| 924 | hero_speed = self.hero_actor.get_velocity() |
| 925 | hero_speed_text = 3.6 * math.sqrt(hero_speed.x ** 2 + hero_speed.y ** 2 + hero_speed.z ** 2) |
| 926 | |
| 927 | affected_traffic_light_text = 'None' |
| 928 | if self.affected_traffic_light is not None: |
| 929 | state = self.affected_traffic_light.state |
| 930 | if state == carla.TrafficLightState.Green: |
| 931 | affected_traffic_light_text = 'GREEN' |
| 932 | elif state == carla.TrafficLightState.Yellow: |
| 933 | affected_traffic_light_text = 'YELLOW' |
| 934 | else: |
| 935 | affected_traffic_light_text = 'RED' |
| 936 | |
| 937 | affected_speed_limit_text = self.hero_actor.get_speed_limit() |
| 938 | |
| 939 | hero_mode_text = [ |
| 940 | 'Hero Mode: ON', |
| 941 | 'Hero ID: %7d' % self.hero_actor.id, |
| 942 | 'Hero Vehicle: %14s' % get_actor_display_name(self.hero_actor, truncate=14), |
| 943 | 'Hero Speed: %3d km/h' % hero_speed_text, |
| 944 | 'Hero Affected by:', |
| 945 | ' Traffic Light: %12s' % affected_traffic_light_text, |
| 946 | ' Speed Limit: %3d km/h' % affected_speed_limit_text |
| 947 | ] |
| 948 | else: |
| 949 | hero_mode_text = ['Hero Mode: OFF'] |
| 950 | |
| 951 | self.server_fps = self.server_clock.get_fps() |
| 952 | self.server_fps = 'inf' if self.server_fps == float('inf') else round(self.server_fps) |
| 953 | module_info_text = [ |
| 954 | 'Server: % 16s FPS' % self.server_fps, |
| 955 | 'Client: % 16s FPS' % round(clock.get_fps()), |
| 956 | 'Simulation Time: % 12s' % datetime.timedelta(seconds=int(self.simulation_time)), |
| 957 | 'Map Name: %10s' % self.town_map.name, |
| 958 | ] |
| 959 | |
| 960 | module_info_text = module_info_text |
| 961 | module_hud = module_manager.get_module(MODULE_HUD) |
| 962 | module_hud.add_info(self.name, module_info_text) |
| 963 | module_hud.add_info('HERO', hero_mode_text) |
| 964 | |
| 965 | @staticmethod |
| 966 | def on_world_tick(weak_self, timestamp): |
no test coverage detected