| 438 | return None |
| 439 | |
| 440 | def save(self, near_node, far_node, near_command, far_command, tick_data, supervision_dict, render_img, should_brake): |
| 441 | frame = self.step // 10 - 2 |
| 442 | |
| 443 | Image.fromarray(tick_data['rgb']).save(self.save_path / 'rgb' / ('%04d.png' % frame)) |
| 444 | Image.fromarray(render_img).save(self.save_path / 'bev' / ('%04d.png' % frame)) |
| 445 | pos = self._get_position(tick_data) |
| 446 | theta = tick_data['compass'] |
| 447 | speed = tick_data['speed'] |
| 448 | |
| 449 | data = { |
| 450 | 'x': pos[0], |
| 451 | 'y': pos[1], |
| 452 | 'theta': theta, |
| 453 | 'speed': speed, |
| 454 | 'x_command_far': far_node[0], |
| 455 | 'y_command_far': far_node[1], |
| 456 | 'command_far': far_command.value, |
| 457 | 'x_command_near': near_node[0], |
| 458 | 'y_command_near': near_node[1], |
| 459 | 'command_near': near_command.value, |
| 460 | 'should_brake': should_brake, |
| 461 | 'x_target': tick_data['x_target'], |
| 462 | 'y_target': tick_data['y_target'], |
| 463 | 'target_command': tick_data['next_command'], |
| 464 | } |
| 465 | outfile = open(self.save_path / 'measurements' / ('%04d.json' % frame), 'w') |
| 466 | json.dump(data, outfile, indent=4) |
| 467 | outfile.close() |
| 468 | with open(self.save_path / 'supervision' / ('%04d.npy' % frame), 'wb') as f: |
| 469 | np.save(f, supervision_dict) |
| 470 | |
| 471 | |
| 472 | def get_target_gps(self, gps, compass): |