Extended Attributes#
Newton’s State and Contacts objects can optionally carry extra arrays that are not always needed.
These extended attributes are allocated on demand when explicitly requested, reducing memory usage for simulations that don’t need them.
Extended Contact Attributes#
Extended contact attributes are optional arrays on Contacts (e.g., contact forces for sensors).
Request them via Model.request_contact_attributes or ModelBuilder.request_contact_attributes before creating a Contacts object.
builder = newton.ModelBuilder()
# build/import model ...
model = builder.finalize()
sensor = newton.sensors.SensorContact(model, ...) # transparently requests "force"
contacts = newton.Contacts(
rigid_contact_max,
soft_contact_max,
requested_attributes=model.get_requested_contact_attributes(),
)
The canonical list is Contacts.EXTENDED_ATTRIBUTES:
Attribute |
Description |
|---|---|
Contact spatial forces (used by |
Extended State Attributes#
Extended state attributes are optional arrays on State (e.g., accelerations for sensors).
Request them via Model.request_state_attributes or ModelBuilder.request_state_attributes before calling Model.state().
builder = newton.ModelBuilder()
# build/import model ...
builder.request_state_attributes("body_qdd")
model = builder.finalize()
state = model.state() # state.body_qdd is now allocated
The canonical list is State.EXTENDED_ATTRIBUTES:
Attribute |
Description |
|---|---|
Rigid-body spatial accelerations (used by |
|
Rigid-body parent interaction wrenches |
Notes#
Some components transparently request attributes they need. For example,
SensorIMUrequestsbody_qddandSensorContactrequestsforce. Create sensors before allocating State/Contacts for this to work automatically.Solvers populate extended attributes they support. Currently,
SolverMuJoCopopulatesbody_qdd,body_parent_f, andforce.