| 122 | |
| 123 | @staticmethod |
| 124 | def process_act(action, acc_as_action, train=True): |
| 125 | if not train: |
| 126 | action = action[0] |
| 127 | if acc_as_action: |
| 128 | acc, steer = action.astype(np.float64) |
| 129 | if acc >= 0.0: |
| 130 | throttle = acc |
| 131 | brake = 0.0 |
| 132 | else: |
| 133 | throttle = 0.0 |
| 134 | brake = np.abs(acc) |
| 135 | else: |
| 136 | throttle, steer, brake = action.astype(np.float64) |
| 137 | |
| 138 | throttle = np.clip(throttle, 0, 1) |
| 139 | steer = np.clip(steer, -1, 1) |
| 140 | brake = np.clip(brake, 0, 1) |
| 141 | control = carla.VehicleControl(throttle=throttle, steer=steer, brake=brake) |
| 142 | return control |