tracer
¶
Tracer
dataclass
¶
Tracer(
target: Traceable,
duration: float = 1.0,
color: Vec4 | None = None,
width: float = 0.005,
fade: bool = True,
record_decimation: int = 1,
)
Draws a fading trail of recent world positions behind a Traceable object (a Body, Site, or Geom).
Typical usage inside a runtime function, within a with runtime_manager as rm: block::
| Text Only | |
|---|---|
1 | |
Sampled once per RuntimeManager.step() and drawn by any VideoRecorder with show_traces=True.
-
Code Reference
mujoco_mojoruntime
target
instance-attribute
¶
target: Traceable
The object whose world position is followed over time.
duration
class-attribute
instance-attribute
¶
duration: float = 1.0
How many seconds of trailing history to keep.
color
class-attribute
instance-attribute
¶
color: Vec4 | None = None
RGBA color of the trail. Defaults to the user's visualization.trace_line setting.
fade
class-attribute
instance-attribute
¶
fade: bool = True
If True, older segments are drawn more transparent than newer ones.
record_decimation
class-attribute
instance-attribute
¶
record_decimation: int = 1
How many steps between each recorded point. Increase for long, fine-timestep simulations to reduce the number of trail segments.
update
¶
update(state: MjState) -> None
Records the target's current position, then drops points older than duration. Call once per step.
Source code in src/mujoco_mojo/runtime/tracer.py
get_visuals
¶
Returns the trail's cached LineConfig segments, one per consecutive pair of recorded positions.
Segments are built once, in update(), as new points are recorded, and reused across every call here - only the fade alpha is refreshed in place, since a segment's position within the trailing window (and therefore its fade level) shifts every step even though its endpoints never change.