Metric Terms¶
Metric terms grade a rollout: each reports a value per env with a direction (MetricDirection, higher or lower is
better), a mode (MetricMode) and a success_threshold, and the metric manager combines the ones that contribute
to success. Rewards and terminations can read a metric instead of recomputing it. The
metrics and recorders guide explains them; the
term catalog lists every parameter.
The base classes MetricTerm and MetricTermFuncWrapper are on the managers page.
Proximity¶
Proximity and relative-position metric terms between entities.
Attributes¶
Classes¶
EeNearEntity
¶
EeNearEntity(env: EnvBase, options: _TermOptionsT)
Bases: MetricTerm
Check if the mean end-effector position is within threshold of a target entity.
This is a class-based metric that caches link indices at build() time
for efficiency.
| PARAMETER | DESCRIPTION |
|---|---|
robot_name
|
Name of the robot entity.
|
ee_link_names
|
Link names whose mean position is treated as the EE position.
|
entity_name
|
Name of the target entity.
|
threshold
|
Maximum allowed distance.
|
Source code in eden/managers/base.py
Functions:¶
object_a_is_on_b
¶
object_a_is_on_b(env: EnvBase, *, entity_a_name: str, entity_b_name: str, xy_threshold: float = 0.03, height_threshold: float = 0.04, height_diff: float = 0.0)
Check if object_a is on object_b by comparing height and xy distance of object origins.
This function can be used as a termination term or a metric term.
| PARAMETER | DESCRIPTION |
|---|---|
env
|
The environment instance.
TYPE:
|
entity_a_name
|
The name of the entity_a.
TYPE:
|
entity_b_name
|
The name of the entity_b.
TYPE:
|
xy_threshold
|
The threshold for the xy distance.
TYPE:
|
height_threshold
|
The threshold for the height distance.
TYPE:
|
height_diff
|
The expected height difference.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
success
|
A boolean tensor indicating if the object_a is on the object_b.
TYPE:
|
Source code in eden/managers/terms/metrics/proximity.py
object_a_within_b_xy
¶
object_a_within_b_xy(env: EnvBase, *, entity_a_name: str, entity_b_name: str, min_fraction: float = 0.8) -> Tensor
min_fraction of entity_a's footprint lies over entity_b's.
Both footprints are the xy extent of the entity's world-frame bounding box (its collision geometry),
so a cup over a cutting board, or a scissor dropped into a container, passes whatever its height:
pair it with a height or contact check to require that it rests there. PolaRiS's is_within_xy
rubric checker (eden.tasks.polaris) is this test.
| PARAMETER | DESCRIPTION |
|---|---|
env
|
The environment instance.
TYPE:
|
entity_a_name
|
The entity that must lie over the other.
TYPE:
|
entity_b_name
|
The entity it must lie over.
TYPE:
|
min_fraction
|
Smallest share of entity_a's footprint area that must overlap entity_b's, in
TYPE:
|
Source code in eden/managers/terms/metrics/proximity.py
entity_distance
¶
Distance between two entity root positions.
Returns a float tensor of shape (num_envs,) with the Euclidean
distance. Registered with direction=LIB (lower is better).
| PARAMETER | DESCRIPTION |
|---|---|
env
|
The environment instance.
TYPE:
|
entity_a_name
|
Name of the first entity.
TYPE:
|
entity_b_name
|
Name of the second entity.
TYPE:
|
Source code in eden/managers/terms/metrics/proximity.py
entity_near_target
¶
entity_near_target(env: EnvBase, *, entity_name: str, target_pos: Vec3FType | Tensor, threshold: float = 0.05) -> Tensor
Check if an entity is within threshold of a fixed world position.
Returns a per-env bool tensor (True if within threshold).
| PARAMETER | DESCRIPTION |
|---|---|
env
|
The environment instance.
TYPE:
|
entity_name
|
Name of the entity to check.
TYPE:
|
target_pos
|
Target world position
TYPE:
|
threshold
|
Maximum allowed distance.
TYPE:
|
Source code in eden/managers/terms/metrics/proximity.py
entity_distance_xy
¶
Horizontal (XY) distance between two entity root positions.
Like :func:entity_distance but ignores the Z axis. Useful for
placement tasks where objects sit at different heights (e.g. an apple
on a plate).
| PARAMETER | DESCRIPTION |
|---|---|
env
|
The environment instance.
TYPE:
|
entity_a_name
|
Name of the first entity.
TYPE:
|
entity_b_name
|
Name of the second entity.
TYPE:
|
Source code in eden/managers/terms/metrics/proximity.py
entity_near_entity_xy
¶
entity_near_entity_xy(env: EnvBase, *, entity_a_name: str, entity_b_name: str, threshold: float = 0.05) -> Tensor
Check if two entities are within threshold horizontal (XY) distance.
Returns a per-env bool tensor, True when the XY distance between root positions is below threshold. Useful for placement tasks where objects naturally sit at different heights.
| PARAMETER | DESCRIPTION |
|---|---|
env
|
The environment instance.
TYPE:
|
entity_a_name
|
Name of the first entity.
TYPE:
|
entity_b_name
|
Name of the second entity.
TYPE:
|
threshold
|
Maximum allowed horizontal distance.
TYPE:
|
Source code in eden/managers/terms/metrics/proximity.py
Containment¶
Containment metric terms (object above height / inside region).
Attributes¶
Classes¶
Functions:¶
object_above_height
¶
object_above_height(env: EnvBase, *, entity_name: str, height: float, relative: bool = False) -> Tensor
Check if an entity's root z-position is above height.
Returns a per-env bool tensor (True if above).
| PARAMETER | DESCRIPTION |
|---|---|
env
|
The environment instance.
TYPE:
|
entity_name
|
Name of the entity.
TYPE:
|
height
|
Minimum height threshold.
TYPE:
|
relative
|
Frame height is measured in. Only a rigid entity has the second frame, so
TYPE:
|
Source code in eden/managers/terms/metrics/containment.py
object_bottom_above_height
¶
Lowest point of the entity above height.
Unlike :func:object_above_height, this does not depend on where the asset puts its origin (a
scanned mesh's origin may sit at its base, its centre or off to one side), so height=0.03 with
the table at z = 0 reads "lifted 3 cm off the table" for any object.
| PARAMETER | DESCRIPTION |
|---|---|
env
|
The environment instance.
TYPE:
|
entity_name
|
Name of the entity.
TYPE:
|
height
|
World
TYPE:
|
Source code in eden/managers/terms/metrics/containment.py
object_in_region
¶
object_in_region(env: EnvBase, *, entity_name: str, region_min: list[float], region_max: list[float], relative: bool = False) -> Tensor
Check if an entity's root position is inside an axis-aligned box.
Returns a per-env bool tensor (True if inside, bounds inclusive).
| PARAMETER | DESCRIPTION |
|---|---|
env
|
The environment instance.
TYPE:
|
entity_name
|
Name of the entity.
TYPE:
|
region_min
|
Lower corner of the box |
region_max
|
Upper corner of the box |
relative
|
Frame the box is expressed in — see :func:
TYPE:
|
Source code in eden/managers/terms/metrics/containment.py
Grasping¶
Grasp metric terms (object lifted, is-grasping).
Attributes¶
Classes¶
IsGrasping
¶
IsGrasping(env: EnvBase, options: MetricTermOptions)
Bases: MetricTerm
Detect a parallel-jaw grasp via contact force alignment.
Returns a per-env bool, True when both gripper pads have contact forces aligned with their closing direction above force_threshold. This correctly detects a grasp even when the fingers cannot fully close (e.g. when an object is between them).
Shares the force test of :func:~eden.managers.terms.utils.parallel_jaw_is_grasping with
:class:~eden.managers.terms.actions.welding_actions.ParallelJawWelding, but sums each pad's
contacts over every link it touches. A grasp spanning two links of one object counts, and so
do pads pressing two different objects. The weld action instead requires both pads on the one
link it would weld, so this metric can read True in a step that welds nothing.
| PARAMETER | DESCRIPTION |
|---|---|
robot_name
|
Name of the robot entity.
TYPE:
|
left_gripper_link_name
|
Link name of the left gripper pad (e.g.
TYPE:
|
right_gripper_link_name
|
Link name of the right gripper pad (e.g.
TYPE:
|
force_threshold
|
Minimum projected contact force magnitude on each pad to count as grasping. Lower values are more sensitive.
TYPE:
|
Source code in eden/managers/terms/metrics/grasp.py
Attributes¶
left_gripper_link_name
class-attribute
instance-attribute
¶
left_gripper_link_name: str = 'left_gripper_pad'
right_gripper_link_name
class-attribute
instance-attribute
¶
right_gripper_link_name: str = 'right_gripper_pad'
Methods:¶
build
¶
Source code in eden/managers/terms/metrics/grasp.py
compute
¶
Source code in eden/managers/terms/metrics/grasp.py
Functions:¶
object_lifted
¶
Check if an entity has been lifted above min_height.
Returns a per-env bool tensor, True when the entity's root z-position (solver frame) exceeds min_height.
| PARAMETER | DESCRIPTION |
|---|---|
env
|
The environment instance.
TYPE:
|
entity_name
|
Name of the entity.
TYPE:
|
min_height
|
World-z height threshold [m].
TYPE:
|
Source code in eden/managers/terms/metrics/grasp.py
Articulation¶
Articulation metric terms (e.g. joint angle at target).
Attributes¶
Classes¶
Functions:¶
joint_angle_at_target
¶
joint_angle_at_target(env: EnvBase, *, entity_name: str, joint_name: str, target_angle: float, threshold: float = 0.05) -> Tensor
Check if a single DOF is within threshold of target_angle.
Returns a per-env bool tensor, True when the joint position satisfies
|current - target_angle| < threshold.
| PARAMETER | DESCRIPTION |
|---|---|
env
|
The environment instance.
TYPE:
|
entity_name
|
Name of the articulated entity.
TYPE:
|
joint_name
|
Name of the DOF to query.
TYPE:
|
target_angle
|
Target joint position (radians or meters depending on joint type).
TYPE:
|
threshold
|
Maximum allowed deviation.
TYPE:
|
Source code in eden/managers/terms/metrics/articulation.py
Velocity-tracking error¶
Velocity-tracking error metric terms.
Attributes¶
Classes¶
Functions:¶
error_vel_xy
¶
Source code in eden/managers/terms/metrics/error.py
error_vel_yaw
¶
Source code in eden/managers/terms/metrics/error.py
Boolean combinators¶
Boolean combinators (AND/OR/NOT) over metric terms.
Attributes¶
Classes¶
MetricTermAND
¶
MetricTermAND(env: EnvBase, options: MetricTermOptions)
Bases: _BooleanMetricTermBase
Metric term that returns the element-wise minimum of its child terms.
All child terms must be "passing" for this term to pass.
| PARAMETER | DESCRIPTION |
|---|---|
terms
|
Child term configurations (from
TYPE:
|
Example
::
MetricTermAND.configure(
terms=[
EeNearEntity.configure(robot_name="robot", ...),
IsGrasping.configure(robot_name="robot", ...),
],
)
Source code in eden/managers/terms/metrics/boolean.py
MetricTermOR
¶
MetricTermOR(env: EnvBase, options: MetricTermOptions)
Bases: _BooleanMetricTermBase
Metric term that returns the element-wise maximum of its child terms.
Any child term passing is sufficient for this term to pass.
| PARAMETER | DESCRIPTION |
|---|---|
terms
|
Child term configurations (from
TYPE:
|
Example
::
MetricTermOR.configure(
terms=[
entity_near_target.configure(entity_name="apple", ...),
entity_near_target.configure(entity_name="orange", ...),
],
)
Source code in eden/managers/terms/metrics/boolean.py
MetricTermNOT
¶
MetricTermNOT(env: EnvBase, options: MetricTermOptions)
Bases: MetricTerm
Metric term that inverts a single child term (1.0 - value).
| PARAMETER | DESCRIPTION |
|---|---|
term
|
The child term configuration (from
TYPE:
|
Example
::
MetricTermNOT.configure(
term=IsGrasping.configure(robot_name="robot", ...),
)
Source code in eden/managers/terms/metrics/boolean.py
Attributes¶
Methods:¶
build
¶
Source code in eden/managers/terms/metrics/boolean.py
reset
¶
Functions:¶
Sequences and rubrics¶
Sequential and rubric metric terms: sub-metrics met in order, or in any order their dependencies allow.
Attributes¶
Classes¶
SequentialMetricTerm
¶
SequentialMetricTerm(env: EnvBase, options: MetricTermOptions)
Bases: MetricTerm
Metric that tracks ordered sub-goals (phases).
Each phase is a predicate that must be satisfied before the next phase is
evaluated. The metric value is the fraction of phases completed
(completed / total). With the default success_threshold=1.0 and
direction="hib", the episode is considered successful once all
phases are complete.
Phase advancement is per-environment -- different parallel environments can be in different phases.
| PARAMETER | DESCRIPTION |
|---|---|
phases
|
Ordered list of phase definitions. Each
And optionally:
TYPE:
|
allow_skip
|
If
TYPE:
|
Example
::
SequentialMetricTerm.configure(
phases=[
PhaseOptions(
name="reach",
term=EeNearEntity.configure(
robot_name="robot",
ee_link_names=["finger_l", "finger_r"],
entity_name="apple",
threshold=0.15,
),
threshold=0.5,
),
PhaseOptions(
name="grasp",
term=IsGrasping.configure(
robot_name="robot",
left_gripper_link_name="left_gripper_pad",
right_gripper_link_name="right_gripper_pad",
force_threshold=0.5,
),
threshold=1.0,
hold=True,
hold_until="place",
),
PhaseOptions(
name="place",
term=entity_near_target.configure(entity_name="apple", target_pos=[0.5, 0.0, 0.8]),
),
],
allow_skip=False,
)
Source code in eden/managers/terms/metrics/sequence.py
Attributes¶
Methods:¶
resolve_refs
¶
Resolve ref phases by looking up sibling MetricTermOptions.
Called by MetricManager._prepare_terms() in a second pass after
all terms have been built.
Source code in eden/managers/terms/metrics/sequence.py
build
¶
Source code in eden/managers/terms/metrics/sequence.py
get_phase_params
¶
Return the mutable params dict for a phase (by index or name).
Only meaningful for function-based terms that have a params attribute.
Modifying the returned dict changes future compute() calls.
Source code in eden/managers/terms/metrics/sequence.py
get_phase_term
¶
get_phase_term(phase: int | str) -> MetricTerm
Return the underlying term instance for a phase (by index or name).
reset
¶
Source code in eden/managers/terms/metrics/sequence.py
compute
¶
Source code in eden/managers/terms/metrics/sequence.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | |
RubricMetricTerm
¶
RubricMetricTerm(env: EnvBase, options: MetricTermOptions)
Bases: MetricTerm
Fraction of rubric criteria met, each after its dependencies.
A criterion is reached the first step its predicate succeeds — by the term's own is_success, so
its direction and success_threshold decide (entity_distance with success_threshold=0.05
is met within 5 cm) — while every criterion in its after list has already been reached, and stays
reached until the env resets: a cube let go over the tray counts even if it bounces off later. The value
is the fraction of criteria reached, so with the default success_threshold=1.0 the task succeeds once
all of them are. Unlike
:class:SequentialMetricTerm, criteria with no dependency between them are reached in any order
(both cubes' "reach" before either "lift", or one cube's whole chain first) — the progress score of
PolaRiS's Rubric, which :mod:eden.tasks.polaris reproduces.
Criteria are evaluated in list order every step, so after names earlier criteria only, and a
criterion can be reached in the same step as the ones it depends on.
| PARAMETER | DESCRIPTION |
|---|---|
criteria
|
The criteria, each a named predicate (
TYPE:
|
Example
::
RubricMetricTerm.configure(
criteria=[
CriterionOptions(name="reach", term=EeNearEntity.configure(robot_name="gripper", ...)),
CriterionOptions(name="lift", term=object_above_height.configure(...), after=["reach"]),
CriterionOptions(name="in_bowl", term=object_a_within_b_xy.configure(...), after=["lift"]),
]
)
Source code in eden/managers/terms/metrics/sequence.py
Attributes¶
Methods:¶
build
¶
Source code in eden/managers/terms/metrics/sequence.py
reset
¶
reached
¶
(num_envs, num_criteria) bool: the criteria each env has reached this episode (a copy).