(self, pred, command, speed, target_point)
| 204 | return outputs |
| 205 | |
| 206 | def process_action(self, pred, command, speed, target_point): |
| 207 | action = self._get_action_beta(pred['mu_branches'].view(1,2), pred['sigma_branches'].view(1,2)) |
| 208 | acc, steer = action.cpu().numpy()[0].astype(np.float64) |
| 209 | if acc >= 0.0: |
| 210 | throttle = acc |
| 211 | brake = 0.0 |
| 212 | else: |
| 213 | throttle = 0.0 |
| 214 | brake = np.abs(acc) |
| 215 | |
| 216 | throttle = np.clip(throttle, 0, 1) |
| 217 | steer = np.clip(steer, -1, 1) |
| 218 | brake = np.clip(brake, 0, 1) |
| 219 | |
| 220 | metadata = { |
| 221 | 'speed': float(speed.cpu().numpy().astype(np.float64)), |
| 222 | 'steer': float(steer), |
| 223 | 'throttle': float(throttle), |
| 224 | 'brake': float(brake), |
| 225 | 'command': command, |
| 226 | 'target_point': tuple(target_point[0].data.cpu().numpy().astype(np.float64)), |
| 227 | } |
| 228 | return steer, throttle, brake, metadata |
| 229 | |
| 230 | def _get_action_beta(self, alpha, beta): |
| 231 | x = torch.zeros_like(alpha) |
no test coverage detected