(self, path_to_conf_file)
| 31 | |
| 32 | class TCPAgent(autonomous_agent.AutonomousAgent): |
| 33 | def setup(self, path_to_conf_file): |
| 34 | self.track = autonomous_agent.Track.SENSORS |
| 35 | self.alpha = 0.3 |
| 36 | self.status = 0 |
| 37 | self.steer_step = 0 |
| 38 | self.last_moving_status = 0 |
| 39 | self.last_moving_step = -1 |
| 40 | self.last_steers = deque() |
| 41 | |
| 42 | self.config_path = path_to_conf_file |
| 43 | self.step = -1 |
| 44 | self.wall_start = time.time() |
| 45 | self.initialized = False |
| 46 | |
| 47 | self.config = GlobalConfig() |
| 48 | self.net = TCP(self.config) |
| 49 | |
| 50 | |
| 51 | ckpt = torch.load(path_to_conf_file) |
| 52 | ckpt = ckpt["state_dict"] |
| 53 | new_state_dict = OrderedDict() |
| 54 | for key, value in ckpt.items(): |
| 55 | new_key = key.replace("model.","") |
| 56 | new_state_dict[new_key] = value |
| 57 | self.net.load_state_dict(new_state_dict, strict = False) |
| 58 | self.net.cuda() |
| 59 | self.net.eval() |
| 60 | |
| 61 | self.takeover = False |
| 62 | self.stop_time = 0 |
| 63 | self.takeover_time = 0 |
| 64 | |
| 65 | self.save_path = None |
| 66 | self._im_transform = T.Compose([T.ToTensor(), T.Normalize(mean=[0.485,0.456,0.406], std=[0.229,0.224,0.225])]) |
| 67 | |
| 68 | self.last_steers = deque() |
| 69 | if SAVE_PATH is not None: |
| 70 | now = datetime.datetime.now() |
| 71 | string = pathlib.Path(os.environ['ROUTES']).stem + '_' |
| 72 | string += '_'.join(map(lambda x: '%02d' % x, (now.month, now.day, now.hour, now.minute, now.second))) |
| 73 | |
| 74 | print (string) |
| 75 | |
| 76 | self.save_path = pathlib.Path(os.environ['SAVE_PATH']) / string |
| 77 | self.save_path.mkdir(parents=True, exist_ok=False) |
| 78 | |
| 79 | (self.save_path / 'rgb').mkdir() |
| 80 | (self.save_path / 'meta').mkdir() |
| 81 | (self.save_path / 'bev').mkdir() |
| 82 | |
| 83 | def _init(self): |
| 84 | self._route_planner = RoutePlanner(4.0, 50.0) |
nothing calls this directly
no test coverage detected