From d0e60f681d3f8e7bf43ecb6e6827461083390d03 Mon Sep 17 00:00:00 2001 From: weakriver3000 <13025774334@163.com> Date: Sun, 29 Nov 2026 09:47:35 +0800 Subject: [PATCH 1/2] Apply pose interpolation perturbation to every interior point --- ...x-pose-interpolation-perturbation.fixed.rst | 2 ++ source/isaaclab/isaaclab/utils/math.py | 6 +++--- source/isaaclab/test/utils/test_math.py | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 source/isaaclab/changelog.d/fix-pose-interpolation-perturbation.fixed.rst diff --git a/source/isaaclab/changelog.d/fix-pose-interpolation-perturbation.fixed.rst b/source/isaaclab/changelog.d/fix-pose-interpolation-perturbation.fixed.rst new file mode 100644 index 000000000000..ad378b55a98d --- /dev/null +++ b/source/isaaclab/changelog.d/fix-pose-interpolation-perturbation.fixed.rst @@ -0,0 +1,2 @@ +* Fixed :func:`~isaaclab.utils.math.interpolate_poses` skipping the last intermediate position when + position perturbation was enabled. Both endpoints remained unchanged. diff --git a/source/isaaclab/isaaclab/utils/math.py b/source/isaaclab/isaaclab/utils/math.py index c27747152ffb..8a80f6340376 100644 --- a/source/isaaclab/isaaclab/utils/math.py +++ b/source/isaaclab/isaaclab/utils/math.py @@ -1909,9 +1909,9 @@ def interpolate_poses( pos_step_size = delta_pos / num_steps grid = torch.arange(num_steps, dtype=torch.float32) if perturb: - # Move interpolation grid points by up to half-size forward or backward - perturbations = torch.rand(num_steps - 2) - 0.5 - grid[1:-1] += perturbations + # Keep the start fixed. The endpoint is appended after interpolation. + perturbations = torch.rand(num_steps - 1) - 0.5 + grid[1:] += perturbations pos_steps = torch.stack([pos1 + grid[i] * pos_step_size for i in range(num_steps)]) # Add in endpoint diff --git a/source/isaaclab/test/utils/test_math.py b/source/isaaclab/test/utils/test_math.py index bf2d30eb9369..7a40226a50c2 100644 --- a/source/isaaclab/test/utils/test_math.py +++ b/source/isaaclab/test/utils/test_math.py @@ -599,6 +599,24 @@ def test_interpolate_poses(): np.testing.assert_array_almost_equal(result_pos, expected_pos, decimal=DECIMAL_PRECISION) +@pytest.mark.kitless +def test_interpolate_poses_perturbs_single_interior_point(): + """Perturb the only intermediate position while preserving both endpoints.""" + start = torch.eye(4) + end = start.clone() + end[0, 3] = 1.0 + + with torch.random.fork_rng(devices=[]): + torch.random.default_generator.manual_seed(0) + poses, num_steps = math_utils.interpolate_poses(start, end, num_steps=1, perturb=True) + + assert num_steps == 1 + torch.testing.assert_close(poses[[0, -1]], torch.stack([start, end])) + x = poses[1, 0, 3].item() + assert 0.25 <= x <= 0.75 + assert x != 0.5 + + def test_interpolate_poses_without_interpolation(): """Test that interpolate_poses with num_steps=0 returns just the start and end poses.""" pose_1 = math_utils.generate_random_transformation_matrix() From cfe42563efc43a5de4f803dc0518ccb97f088f64 Mon Sep 17 00:00:00 2001 From: weakriver3000 <13025774334@163.com> Date: Wed, 2 Dec 2026 14:38:55 +0800 Subject: [PATCH 2/2] Annotate pose interpolation regression test return type --- source/isaaclab/test/utils/test_math.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/isaaclab/test/utils/test_math.py b/source/isaaclab/test/utils/test_math.py index 7a40226a50c2..51d2712fb1e9 100644 --- a/source/isaaclab/test/utils/test_math.py +++ b/source/isaaclab/test/utils/test_math.py @@ -600,7 +600,7 @@ def test_interpolate_poses(): @pytest.mark.kitless -def test_interpolate_poses_perturbs_single_interior_point(): +def test_interpolate_poses_perturbs_single_interior_point() -> None: """Perturb the only intermediate position while preserving both endpoints.""" start = torch.eye(4) end = start.clone()