Skip to content

Add object_displaced_rate metric and use it in PickAndPlaceTask - #1718

Merged
xyao-nv merged 1 commit into
xyao/refactor/rename_object_moved_ratefrom
xyao/feature/object_displacement_metric
Nov 20, 2026
Merged

xyao-nv merged 1 commit into
xyao/refactor/rename_object_moved_ratefrom
xyao/feature/object_displacement_metric

Conversation

@xyao-nv

@xyao-nv xyao-nv commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Add ObjectDisplacedRateMetric, which counts an episode as displaced if the object ends up more than 2 cm from where it started, and use it in PickAndPlaceTask instead of the peak-speed metric.

Why this change?

The previous PR renamed the speed metric to object_peak_speed_exceeded_rate, so its name now says what it measures. This PR adds the measure that pick-and-place needs.

What changes?

  • Add ObjectDisplacedRateMetric (key object_displaced_rate). It records the object's world-frame position each step and counts an episode if the position is ever more than displacement_threshold_m (default 0.02 m) from the first recorded position. Deformables use their mean node position.
  • PickAndPlaceTask.get_metrics() returns the new metric in place of the peak-speed one. The other tasks (goal-pose, gear-insertion, assembly, place-upright) keep the peak-speed metric.

Breaking change: pick-and-place results now report object_displaced_rate, not object_peak_speed_exceeded_rate.

Usage example

Before:


return [SuccessRateMetric(), ObjectPeakSpeedExceededRateMetric(self.pick_up_object)]
metrics.metric_data_entries["object_peak_speed_exceeded_rate"]

After:

return [SuccessRateMetric(), ObjectDisplacedRateMetric(self.pick_up_object)]
metrics.metric_data_entries["object_displaced_rate"]

A slow carry now counts as displaced.

Validation

  • Run tests

Signed-off-by: Xinjie Yao <xyao@nvidia.com>
@xyao-nv
xyao-nv marked this pull request as ready for review November 19, 2026 21:59
@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge based on the code reviewed.

Summary

Adds a position-based movement metric and makes it the default for pick-and-place evaluations.

  • Pick-and-place reports object displacement instead of peak speed.

No confirmed actionable issues found. Tests were not run.

Reviews (1) · Last reviewed commit: "Add object_displaced_rate metric and use..." · Reviewed by Greptile



def compute_object_displaced_rate(recorded_metric_data: list[np.ndarray], displacement_threshold_m: float) -> float:
"""Computes the fraction of episodes in which the object ends up displaced from where it started.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 "Ends up" vs. "at any step"

This docstring (and the opening line of the PR description) says the object "ends up" displaced. The code counts an episode if any step is past the threshold, so lifting the object and putting it back still counts. The class docstring and the "What changes" bullet agree with the code. None of the new unit tests can tell the two apart: each one also passes with a final-position-only check. Could we fix the wording and add a lift-and-return case to test_rate_is_fraction_of_episodes?

Suggested change
"""Computes the fraction of episodes in which the object ends up displaced from where it started.
"""Computes the fraction of episodes in which the object was ever displaced from its first recorded position.
lifted_and_returned_w = np.zeros((10, 3))
lifted_and_returned_w[3:6, 2] = 0.1
assert compute_object_displaced_rate([lifted_and_returned_w], displacement_threshold_m=0.02) == 1.0

task = PickAndPlaceTask(pick_object, destination, kitchen)
task.get_metrics()
# → [SuccessRateMetric(), ObjectPeakSpeedExceededRateMetric(pick_object)]
# → [SuccessRateMetric(), ObjectDisplacedRateMetric(pick_object)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Other pages still show the old pick-and-place key

Pick-and-place now reports object_displaced_rate, but these sample outputs from pick-and-place runs still show object_peak_speed_exceeded_rate:

  • docs/pages/quickstart/running_a_real_policy/openpi.rst (lines 148–163)
  • docs/pages/quickstart/running_a_real_policy/gr00t.rst (lines 146–161)
  • docs/pages/example_workflows/analysis/variations.rst (line 77)
  • docs/pages/example_workflows/newton/deformable_pick_and_place.rst (lines 191, 211)
  • docs/pages/example_workflows/sequential_static_manipulation/step_5_evaluation.rst (_subtask_0, lines 122–268)

The values would change as well as the key, so these probably need fresh output rather than a rename. Also, the worked example just below this line now walks through a metric PickAndPlaceTask no longer uses. Would ObjectDisplacedRateMetric be the better example here?

def record_post_step(self):
# Deformables report their mean nodal position, rigid objects their root position.
t_W = self._env.arena_world.get_position_w(self.object_name)
assert t_W.shape == (self._env.num_envs, 3)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Duplicate shape check

ArenaWorld.get_position_w already asserts this exact (num_envs, 3) shape (arena_world.py:298), so this line can go.

Suggested change
assert t_W.shape == (self._env.num_envs, 3)

# The same trajectory as velocity (0.01 m/s) stays under the 0.5 m/s speed threshold.
slow_velocity_w = np.zeros((num_steps, 3))
slow_velocity_w[:, 0] = 0.01
assert compute_object_peak_speed_exceeded_rate([slow_velocity_w], object_velocity_threshold=0.5) == 0.0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Peak-speed metric loses its only value check

test_success_rate_metric.py was the only test that checked the value of object_peak_speed_exceeded_rate, and goal-pose, gear-insertion, assembly and place-upright still report it. This assertion only covers the slow case, so a compute_object_peak_speed_exceeded_rate that always returned 0.0 would now pass. Could we add a fast case next to it?

Suggested change
assert compute_object_peak_speed_exceeded_rate([slow_velocity_w], object_velocity_threshold=0.5) == 0.0
assert compute_object_peak_speed_exceeded_rate([slow_velocity_w], object_velocity_threshold=0.5) == 0.0
assert compute_object_peak_speed_exceeded_rate([slow_velocity_w * 100.0], object_velocity_threshold=0.5) == 1.0

@arena-review-bot

Copy link
Copy Markdown
Contributor

🤖 Isaac Lab-Arena Review Bot

Summary

This PR adds ObjectDisplacedRateMetric, which counts an episode when the object gets more than 2 cm from its first recorded position. PickAndPlaceTask now uses it in place of the peak-speed metric. The metric follows the existing recorder and compute-function pattern and is small. There are three gaps:

  • The function docstring and the tests don't pin down what "displaced" means.
  • Five doc pages still show the old metric key in their pick-and-place sample output.
  • Nothing checks the value of the peak-speed metric anymore, even though four tasks still report it.

Findings

🟡 Warning: isaaclab_arena/metrics/object_displaced.py:41: The docstring of compute_object_displaced_rate (and the opening line of the PR description) says the object "ends up" displaced. The code counts an episode if any step is past the threshold, so lifting the object and putting it back still counts. The class docstring and the "What changes" bullet agree with the code. None of the new unit tests can tell the two definitions apart: I checked that all four assertions also pass with a final-position-only check. Suggest fixing the wording and adding a lift-and-return case.

🔵 Improvement: docs/pages/concepts/task/concept_metrics_design.rst:22: Five other pages still show object_peak_speed_exceeded_rate in their pick-and-place sample output:

  • openpi.rst
  • gr00t.rst
  • variations.rst
  • deformable_pick_and_place.rst
  • step_5_evaluation.rst, as _subtask_0

The worked example on this page also walks through a metric that PickAndPlaceTask no longer uses.

🔵 Improvement: isaaclab_arena/metrics/object_displaced.py:29: ArenaWorld.get_position_w already asserts the same (num_envs, 3) shape, so this assert can go.

Test Coverage and CI Cost

  • The tests don't pin the "any step" behavior of the new metric (see the 🟡 above). One lift-and-return case in test_rate_is_fraction_of_episodes would cover it without starting the simulator.
  • Before this PR, test_success_rate_metric.py was the only test that checked the value of object_peak_speed_exceeded_rate. Goal-pose, gear-insertion, assembly and place-upright still report that metric. The new test checks only the slow case (expects 0.0), so a compute_object_peak_speed_exceeded_rate that always returned 0.0 would now pass. One extra assertion with a fast velocity keeps the compute logic covered (inline on test_object_displaced_metric.py:22).
  • When I reviewed, the test jobs for this head commit had not run yet (the Arena image build was still in progress), so I couldn't confirm the test results.

Verdict

Minor fixes needed

@peterd-NV peterd-NV left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, I flagged a minor note on correctness that you can make the call on whether or not you want to add.

@xyao-nv
xyao-nv merged commit 26b8991 into xyao/refactor/rename_object_moved_rate Nov 20, 2026
21 checks passed
xyao-nv added a commit that referenced this pull request Nov 20, 2026
Reopen #1718 to main.

---------

Signed-off-by: Xinjie Yao <xyao@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants