Run the GUI
(self)
| 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 | |
| 91 | class HumanAgent(AutonomousAgent): |
nothing calls this directly
no test coverage detected