newton.sensors.SensorFrameTransform#
- class newton.sensors.SensorFrameTransform(model, shapes, reference_sites, *, verbose=None)[source]#
Bases:
objectSensor 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
shapesandreference_sitesparameters 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.