newton.sensors.SensorFrameTransform#

class newton.sensors.SensorFrameTransform(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())

The shapes and reference_sites parameters accept label patterns — see Label Matching.

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 = SensorFrameTransform(
    model,
    shapes=shape_indices,
    reference_sites=[reference_site_idx],
)

# Update after eval_fk
sensor.update(state)

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

Initialize the SensorFrameTransform.

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

  • shapes (str | list[str] | list[int]) – List of shape indices, single pattern to match against shape labels, or list of patterns where any one matches.

  • reference_sites (str | list[str] | list[int]) – List of shape indices, single pattern to match against shape labels, or list of patterns where any one matches. Reference shapes must have the SITE flag. Must match 1:1 with shapes, 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 or no labels match.

update(state)#

Update sensor measurements based on current state.

This should be called after eval_fk to compute transforms.

Parameters:

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