Resamples a trajectory to a new length. Parameters: x (np.ndarray): original trajectory, shape (N, 2) length (int): length of resampled trajectory Returns: np.ndarray: resampled trajectory, shape (length, 2)
(x, length=200)
| 4 | |
| 5 | |
| 6 | def resample_trajectory(x, length=200): |
| 7 | """ |
| 8 | Resamples a trajectory to a new length. |
| 9 | |
| 10 | Parameters: |
| 11 | x (np.ndarray): original trajectory, shape (N, 2) |
| 12 | length (int): length of resampled trajectory |
| 13 | |
| 14 | Returns: |
| 15 | np.ndarray: resampled trajectory, shape (length, 2) |
| 16 | """ |
| 17 | len_x = len(x) |
| 18 | time_steps = np.arange(length) * (len_x - 1) / (length - 1) |
| 19 | x = x.T |
| 20 | resampled_trajectory = np.zeros((2, length)) |
| 21 | for i in range(2): |
| 22 | resampled_trajectory[i] = np.interp(time_steps, np.arange(len_x), x[i]) |
| 23 | return resampled_trajectory.T |
| 24 | |
| 25 | |
| 26 | def time_warping(x, length=200): |
nothing calls this directly
no outgoing calls
no test coverage detected