newton.solvers.SolverBase#
- class newton.solvers.SolverBase(model)[source]#
Bases:
objectGeneric base class for solvers.
The implementation provides helper kernels to integrate rigid bodies and particles. Concrete solver back-ends should derive from this class and override
step()as well asnotify_model_changed()where necessary.- classmethod register_custom_attributes(builder)#
Register custom attributes for the solver.
- Parameters:
builder (ModelBuilder) – The model builder to register the custom attributes to.
- __init__(model)#
- integrate_bodies(model, state_in, state_out, dt, angular_damping=0.0)#
Integrate the rigid bodies of the model.
- integrate_particles(model, state_in, state_out, dt)#
Integrate the particles of the model.
- notify_model_changed(flags)#
Notify the solver that parts of the
Modelwere modified.The flags argument is a bit-mask composed of the
ModelFlagsenums or customintbits. Each flag represents a category of model data that may have been updated after the solver was created. Passing the appropriate combination of flags enables a solver implementation to refresh its internal buffers without having to recreate the whole solver object. Valid flags are:ModelFlags.JOINT_PROPERTIES: Joint transforms or coordinates have changed.ModelFlags.JOINT_DOF_PROPERTIES: Joint axis limits, targets, modes, DOF state, or force buffers have changed.ModelFlags.BODY_PROPERTIES: Rigid-body pose or velocity buffers have changed.ModelFlags.BODY_INERTIAL_PROPERTIES: Rigid-body mass or inertia tensors have changed.ModelFlags.SHAPE_PROPERTIES: Shape transforms or geometry have changed.ModelFlags.MODEL_PROPERTIES: Model global properties (e.g., gravity) have changed.ModelFlags.CONSTRAINT_PROPERTIES: Constraint definitions, coefficients, or enable flags have changed.ModelFlags.TENDON_PROPERTIES: Tendon stiffness or related tendon properties have changed.ModelFlags.ACTUATOR_PROPERTIES: Actuator gains, biases, limits, or force properties have changed.
- Parameters:
flags (ModelFlags | int) – Bit-mask of
ModelFlagsor customintbits indicating which model properties changed.
- reset(state, world_mask=None, flags=None)#
Reset the solver internal state data.
Modifies the given state in place. Derived solvers override this to reset solver-specific internal buffers or custom state attributes when environments are reset (e.g. during RL training).
The default implementation is a no-op so solvers that do not require special reset logic need not override this method.
- Parameters:
state (State) – The simulation state to reset (modified in place).
world_mask (array | None) – Optional boolean mask of shape
(num_worlds,)specifying which worlds to reset. IfNone, all worlds are reset.flags (StateFlags | int | None) – Optional
StateFlagsorintbitmask controlling which state attributes need to be reset. IfNone, all state attributes are reset.
- step(state_in, state_out, control, contacts, dt)#
Simulate the model for a given time step using the given control input.
- Parameters:
- update_contacts(contacts, state=None)#
Update a Contacts object with forces from the solver state. Where the solver state contains other contact data, convert that data to the Contacts format.