newton.actuators.DriveNeuralMLP#
- class newton.actuators.DriveNeuralMLP(model_path)[source]#
Bases:
DriveBaseMLP-based neural network actuator drive.
Uses a pre-trained MLP to compute joint effort from concatenated, scaled position-error and joint-velocity history. The output is multiplied by
effort_scaleto convert from network units to physical effort [N or N·m].Configuration parameters (
input_order,input_idx,pos_scale,vel_scale,effort_scale) are read from checkpoint metadata, falling back to defaults when absent..onnxcheckpoints run through Warp-NN. Torch checkpoints keep the Torch backend and accept pt2 archives (.pt2saved withtorch.export.save; preferred) and the deprecated TorchScript (.ptsaved withtorch.jit.save) and module-bundle ({"model": <network module>, "metadata": {...}}saved withtorch.save) formats.Implicit actuation linearizes the network about the current state each step (
prepare_implicit()) and enters the shared implicit solve as the linearized force lawtau0 + a*(q-q0) + b*(qd-qd0)(seeevaluate_force/bind_params()). Supported only on ONNX checkpoints withinput_idx == [0].- evaluate_force(q, qd, target_q, target_qd, feedforward, params, i)#
The network enters the general implicit solve as a per-step-linearized in-kernel law (see
prepare_implicit()), like any other drive.
- classmethod resolve_arguments(args)#
- __init__(model_path)#
Initialize the MLP drive from a checkpoint file.
- Parameters:
model_path (str) – Path to the
.onnx,.pt2,.pt, or.pthcheckpoint.
- bind_params()#
Linearization pack
[tau0, a, b, q0, qd0];Noneif implicit unsupported.The pack is allocated in
finalize()and rewritten in place each step byprepare_implicit(), so binding just hands it to the effort mode.Noneunless the checkpoint is ONNX withinput_idx == [0].
- compute(positions, velocities, target_pos, target_vel, feedforward, pos_indices, vel_indices, target_pos_indices, target_vel_indices, forces, state, dt, device=None)#
- finalize(device, num_actuators)#
- is_graphable()#
- is_stateful()#
- prepare_implicit(positions, velocities, target_pos, target_vel, pos_indices, vel_indices, target_pos_indices, target_vel_indices, drive_state, dt, inv_mass=None, device=None)#
Refresh the linearization of the network about the current state.
One network forward + autodiff backward at the current per-slot state gives
tau0, d(tau)/dq, d(tau)/dqd; these are packed as[tau0, a, b, q0, qd0]intobind_params(), which the general implicit kernel then reads as the linearized force law. Called once per step before the solve.
- state(num_actuators, device)#
- update_state(current_state, next_state)#