newton.solvers.FeatherstoneSolver#
- class newton.solvers.FeatherstoneSolver(model, angular_damping=0.05, update_mass_matrix_every=1, friction_smoothing=1.0, use_tile_gemm=False, fuse_cholesky=True)#
A semi-implicit integrator using symplectic Euler that operates on reduced (also called generalized) coordinates to simulate articulated rigid body dynamics based on Featherstone’s composite rigid body algorithm (CRBA).
See: Featherstone, Roy. Rigid Body Dynamics Algorithms. Springer US, 2014.
Instead of maximal coordinates
body_q
(rigid body positions) andbody_qd
(rigid body velocities) as is the case inSemiImplicitSolver
andXPBDSolver
,FeatherstoneSolver
usesjoint_q
andjoint_qd
to represent the positions and velocities of joints without allowing any redundant degrees of freedom.After constructing
Model
andState
objects this time-integrator may be used to advance the simulation state forward in time.Note
Unlike
SemiImplicitSolver
andXPBDSolver
,FeatherstoneSolver
does not simulate rigid bodies with nonzero mass as floating bodies if they are not connected through any joints. Floating-base systems require an explicit free joint with which the body is connected to the world, seenewton.ModelBuilder.add_joint_free()
.Semi-implicit time integration is a variational integrator that preserves energy, however it not unconditionally stable, and requires a time-step small enough to support the required stiffness and damping forces.
See: https://en.wikipedia.org/wiki/Semi-implicit_Euler_method
Example
solver = newton.solvers.FeatherstoneSolver(model) # simulation loop for i in range(100): solver.step(model, state_in, state_out, control, contacts, dt)
Methods
__init__
(model[, angular_damping, ...])integrate_bodies
(model, state_in, state_out, dt)Integrate the rigid bodies of the model.
integrate_particles
(model, state_in, ...)Integrate the particles of the model.
notify_model_changed
(flags)Notify the solver that parts of the
Model
were modified.Attributes
Get the device used by the solver.
- __init__(model, angular_damping=0.05, update_mass_matrix_every=1, friction_smoothing=1.0, use_tile_gemm=False, fuse_cholesky=True)#
- Parameters:
model (Model) – the model to be simulated.
angular_damping (float, optional) – Angular damping factor. Defaults to 0.05.
update_mass_matrix_every (int, optional) – How often to update the mass matrix (every n-th time the
simulate()
function gets called). Defaults to 1.friction_smoothing (float, optional) – The delta value for the Huber norm (see
warp.math.norm_huber()
) used for the friction velocity normalization. Defaults to 1.0.
- step(model, state_in, state_out, control, contacts, dt)#
Simulate the model for a given time step using the given control input.
- Parameters:
model (Model) – The model to simulate.
state_in (State) – The input state.
state_out (State) – The output state.
control (Control) – The control input. Defaults to None which means the control values from the
Model
are used.contacts (Contact) – The contact information.
dt (float) – The time step (typically in seconds).
- property device: Device#
Get the device used by the solver.
- Returns:
The device used by the solver.
- Return type:
wp.Device
- 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
Model
were modified.The flags argument is a bit-mask composed of the
NOTIFY_FLAG_*
constants defined innewton.core.types
. 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:Constant
Description
NOTIFY_FLAG_JOINT_PROPERTIES
Joint transforms or coordinates have changed.
NOTIFY_FLAG_JOINT_AXIS_PROPERTIES
Joint axis limits, targets, or modes have changed.
NOTIFY_FLAG_DOF_PROPERTIES
Joint DOF state or force buffers have changed.
NOTIFY_FLAG_BODY_PROPERTIES
Rigid-body pose or velocity buffers have changed.
NOTIFY_FLAG_BODY_INERTIAL_PROPERTIES
Rigid-body mass or inertia tensors have changed.
NOTIFY_FLAG_SHAPE_PROPERTIES
Shape transforms or geometry have changed.
- Parameters:
flags (int) – Bit-mask of model-update flags indicating which model properties changed.