| 88 | |
| 89 | @staticmethod |
| 90 | def process_obs(obs, input_states, train=True): |
| 91 | |
| 92 | state_list = [] |
| 93 | if 'speed' in input_states: |
| 94 | state_list.append(obs['speed']['speed_xy']) |
| 95 | if 'speed_limit' in input_states: |
| 96 | state_list.append(obs['control']['speed_limit']) |
| 97 | if 'control' in input_states: |
| 98 | state_list.append(obs['control']['throttle']) |
| 99 | state_list.append(obs['control']['steer']) |
| 100 | state_list.append(obs['control']['brake']) |
| 101 | state_list.append(obs['control']['gear']/5.0) |
| 102 | if 'acc_xy' in input_states: |
| 103 | state_list.append(obs['velocity']['acc_xy']) |
| 104 | if 'vel_xy' in input_states: |
| 105 | state_list.append(obs['velocity']['vel_xy']) |
| 106 | if 'vel_ang_z' in input_states: |
| 107 | state_list.append(obs['velocity']['vel_ang_z']) |
| 108 | |
| 109 | state = np.concatenate(state_list) |
| 110 | |
| 111 | birdview = obs['birdview']['masks'] |
| 112 | |
| 113 | if not train: |
| 114 | birdview = np.expand_dims(birdview, 0) |
| 115 | state = np.expand_dims(state, 0) |
| 116 | |
| 117 | obs_dict = { |
| 118 | 'state': state.astype(np.float32), |
| 119 | 'birdview': birdview |
| 120 | } |
| 121 | return obs_dict |
| 122 | |
| 123 | @staticmethod |
| 124 | def process_act(action, acc_as_action, train=True): |