MCPcopy Create free account
hub / github.com/OpenDriveLab/TCP / run

Method run

scenario_runner/srunner/autoagents/human_agent.py:55–88  ·  view source on GitHub ↗

Run the GUI

(self)

Source from the content-addressed store, hash-verified

53 pygame.display.set_caption("Human Agent")
54
55 def run(self):
56 """
57 Run the GUI
58 """
59 while not self._parent.agent_engaged and not self.quit:
60 time.sleep(0.5)
61
62 controller = KeyboardControl()
63 while not self.quit:
64 self._clock.tick_busy_loop(20)
65 controller.parse_events(self._parent.current_control, self._clock)
66 # Process events
67 pygame.event.pump()
68
69 # process sensor data
70 input_data = self._parent.sensor_interface.get_data()
71 image_center = input_data['Center'][1][:, :, -2::-1]
72 image_left = input_data['Left'][1][:, :, -2::-1]
73 image_right = input_data['Right'][1][:, :, -2::-1]
74 image_rear = input_data['Rear'][1][:, :, -2::-1]
75
76 top_row = np.hstack((image_left, image_center, image_right))
77 bottom_row = np.hstack((0 * image_rear, image_rear, 0 * image_rear))
78 comp_image = np.vstack((top_row, bottom_row))
79 # resize image
80 image_rescaled = cv2.resize(comp_image, dsize=(self._width, self._height), interpolation=cv2.INTER_CUBIC)
81
82 # display image
83 self._surface = pygame.surfarray.make_surface(image_rescaled.swapaxes(0, 1))
84 if self._surface is not None:
85 self._display.blit(self._surface, (0, 0))
86 pygame.display.flip()
87
88 pygame.quit()
89
90
91class HumanAgent(AutonomousAgent):

Callers

nothing calls this directly

Calls 4

parse_eventsMethod · 0.95
make_surfaceMethod · 0.80
KeyboardControlClass · 0.70
get_dataMethod · 0.45

Tested by

no test coverage detected