newton.sensors.FrameTransformSensor#

class newton.sensors.FrameTransformSensor(model, shapes, reference_sites, verbose=None)[source]#

Bases: object

Sensor that measures transforms of shapes/sites relative to reference sites.

This sensor computes the transform from a reference frame (site) to target shapes (which can be regular shapes or sites).

transforms#

Output array of relative transforms (updated after each call to update())

Example

Measure shapes relative to a site:

# Get shape indices somehow (e.g., via selection or direct indexing)
shape_indices = [0, 1, 2]  # indices of shapes to measure
reference_site_idx = 5  # index of reference site

sensor = FrameTransformSensor(
    model,
    shape_indices=shape_indices,
    reference_site_indices=[reference_site_idx],
)

# Update after eval_fk
sensor.update(model, state)

# Access transforms
transforms = sensor.transforms.numpy()  # shape: (N, 7) [pos, quat]
__init__(model, shapes, reference_sites, verbose=None)#

Initialize the FrameTransformSensor.

Parameters:
  • model (Model) – The model to measure.

  • shapes (list[int]) – List of shape indices to measure.

  • reference_sites (list[int]) – List of reference site indices (shapes with SITE flag). Must match 1:1 with shape_indices, or be a single site for all shapes.

  • verbose (bool | None) – If True, print details. If None, uses wp.config.verbose.

Raises:

ValueError – If arguments are invalid.

update(model, state)#

Update sensor measurements based on current state.

This should be called after eval_fk to compute transforms.

Parameters:
  • model (Model) – The model (must match the one used in __init__)

  • state (State) – The current state with body_q populated by eval_fk