Class to control a vehicle manually for debugging purposes
| 37 | return 'HumanAgent' |
| 38 | |
| 39 | class HumanInterface(object): |
| 40 | |
| 41 | """ |
| 42 | Class to control a vehicle manually for debugging purposes |
| 43 | """ |
| 44 | |
| 45 | def __init__(self): |
| 46 | self._width = 800 |
| 47 | self._height = 600 |
| 48 | self._surface = None |
| 49 | |
| 50 | pygame.init() |
| 51 | pygame.font.init() |
| 52 | self._clock = pygame.time.Clock() |
| 53 | self._display = pygame.display.set_mode((self._width, self._height), pygame.HWSURFACE | pygame.DOUBLEBUF) |
| 54 | pygame.display.set_caption("Human Agent") |
| 55 | |
| 56 | def run_interface(self, input_data): |
| 57 | """ |
| 58 | Run the GUI |
| 59 | """ |
| 60 | |
| 61 | # process sensor data |
| 62 | image_center = input_data['Center'][1][:, :, -2::-1] |
| 63 | |
| 64 | # display image |
| 65 | self._surface = pygame.surfarray.make_surface(image_center.swapaxes(0, 1)) |
| 66 | if self._surface is not None: |
| 67 | self._display.blit(self._surface, (0, 0)) |
| 68 | pygame.display.flip() |
| 69 | |
| 70 | def _quit(self): |
| 71 | pygame.quit() |
| 72 | |
| 73 | |
| 74 | class HumanAgent(AutonomousAgent): |