-
Notifications
You must be signed in to change notification settings - Fork 8
add interp trajectory with segment nums #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -245,7 +245,7 @@ def get_trajectory_object_offset_qpos( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return is_success, key_qpos_offset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def interpolate_with_distance_warp( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def interpolate_with_distance( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| trajectory: torch.Tensor, # expected shape [B, N, M], float or convertible to float | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| interp_num: int, # T | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| device=torch.device("cuda"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -258,7 +258,7 @@ def interpolate_with_distance_warp( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Args: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| trajectory: Torch.Tensor of shape [B, N, M]. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| interp_num: Target number of samples T. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| device: Warp device string ('cpu', 'cuda', 'cuda:0', ...). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| device: Torch device string ('cpu', 'cuda', 'cuda:0', ...). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dtype: Working dtype (wp.float32 or wp.float64). Defaults to wp.float32. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+261
to
262
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| device: Torch device string ('cpu', 'cuda', 'cuda:0', ...). | |
| dtype: Working dtype (wp.float32 or wp.float64). Defaults to wp.float32. | |
| device: Torch device string ('cpu', 'cuda', 'cuda:0', ...). Warp kernels | |
| internally operate in single precision (wp.float32). |
Copilot
AI
Feb 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New trajectory resampling logic is added here (interpolate_with_nums), but there are no unit tests covering it. Since CI runs pytest, please add a small CPU-only test to validate output length/shape, first/last waypoint preservation, and edge cases like zero counts and N==1.
Copilot
AI
Feb 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interpolate_with_nums docstring describes generating k samples per segment including the segment start and excluding the segment end, and says k=0 draws no samples (except the final endpoint). The implementation instead always preserves segment endpoints (including appending p1 when count==0) and, for count>0, generates points that include the segment end (alpha=1). Please align the docstring with the actual behavior, or adjust the sampling logic to match the documented contract.
| Each entry ``interp_nums[i] = k`` controls segment ``i`` between | |
| ``trajectory[:, i, :]`` and ``trajectory[:, i + 1, :]``. For that segment, | |
| ``k`` samples are generated with interpolation factors | |
| ``alpha = 0, 1/k, 2/k, ..., (k-1)/k`` (i.e., including the segment start | |
| and excluding the segment end). The final endpoint | |
| ``trajectory[:, -1, :]`` is appended once at the end of the result, so | |
| intermediate segment endpoints are not duplicated. | |
| Args: | |
| trajectory: Torch.Tensor of shape [B, N, M]. | |
| interp_nums: Torch.Tensor of shape [N - 1] specifying the number of | |
| samples per segment, including each segment start and excluding | |
| its end. Values must be non-negative; a value of 0 means that | |
| no samples are drawn from that segment (other than the final | |
| overall endpoint that is always appended once). | |
| Controls piecewise-linear interpolation between successive waypoints in | |
| ``trajectory``. | |
| Each entry ``interp_nums[i] = k`` controls segment ``i`` between | |
| ``trajectory[:, i, :]`` (``p0``) and ``trajectory[:, i + 1, :]`` (``p1``). | |
| For that segment: | |
| * If ``k == 0``, no interior samples are generated and the segment | |
| contributes only its endpoint ``p1``. | |
| * If ``k > 0``, exactly ``k`` new points are generated by linear | |
| interpolation between ``p0`` and ``p1``, excluding ``p0`` and | |
| including ``p1`` (i.e., ``k`` samples strictly after the segment | |
| start and including the segment end). | |
| The first waypoint ``trajectory[:, 0, :]`` is always kept. Each intermediate | |
| waypoint (segment endpoint) appears exactly once in the output, and the | |
| final endpoint ``trajectory[:, -1, :]`` appears once at the end of the | |
| result. | |
| Args: | |
| trajectory: Torch.Tensor of shape [B, N, M]. | |
| interp_nums: Torch.Tensor of shape [N - 1] specifying how many new | |
| samples to insert per segment, excluding the segment start and | |
| including its end. Values must be non-negative; a value of 0 | |
| means that the segment contributes only its endpoint (no interior | |
| samples), while still preserving the global final endpoint exactly | |
| once. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renaming
interpolate_with_distance_warptointerpolate_with_distanceremoves the old symbol entirely, which is a breaking change for any downstream code importing the previous name. If this module is part of the public API, consider keepinginterpolate_with_distance_warpas a backwards-compatible alias (possibly with a deprecation warning) to match the PR’s “non-breaking” intent.