Loop dr testmech
Looped linkages
The DR TestMech in many worlds on Kamino.
steel preset (the default), recordedon an NVIDIA RTX PRO 6000 Blackwell.Run it
cd examples# the default preset (steel), then the othersuv run shelf play loop_dr_testmechuv run shelf play loop_dr_testmech --solver kamino# change solver settings liveuv run shelf tune loop_dr_testmechSource: examples/shelf/05_looped_linkages/loop_dr_testmech/ ยท ported from newton/examples/kamino/example_kamino_basic_dr_testmech.py @ skild-ai/newton 7565a26b1
Presets
| Preset | Solver | Status | Checked |
|---|---|---|---|
steeldefault | steel | works | 2026-11-04, newton 7565a26b1, NVIDIA GeForce RTX 3090 |
kamino | kamino | works | 2026-10-28, newton 7565a26b1, NVIDIA RTX A6000 |
Solvers with no row are untested on this example. The full settings are inpresets.toml.
Code
# SPDX-FileCopyrightText: Copyright (c) 2025 The Newton Developers# SPDX-License-Identifier: Apache-2.0# Modified for Steel Shelf: preset-driven execution and shared runner integration.
############################################################################ Example for basic DR TestMech system## Shows how to simulate DR TestMech with multiple worlds using SolverKamino.## Command: python -m shelf run loop_dr_testmech --world-count 16############################################################################
import warp as wp
import newtonimport newton.examplesfrom common import presets
class Example: def __init__(self, viewer: newton.viewer.ViewerBase, args=None): self.preset = presets.load(__file__) # Set simulation run-time configurations self.fps = self.preset.fps self.frame_dt = 1.0 / self.fps self.sim_substeps = self.preset.substeps self.sim_dt = self.frame_dt / self.sim_substeps self.sim_time = 0.0 self.world_count = args.world_count if args else 1 self.viewer = viewer self.device = wp.get_device()
# Create a single-robot model builder and register the Kamino-specific custom attributes robot_builder = newton.ModelBuilder(up_axis=newton.Axis.Z) if self.preset.name == "kamino": newton.solvers.SolverKamino.register_custom_attributes(robot_builder) robot_builder.default_shape_cfg.margin = 1e-6 robot_builder.default_shape_cfg.gap = 0.01 # Load the DR TestMech USD and add it to the builder asset_path = newton.utils.download_asset("disneyresearch") asset_file = str(asset_path / "dr_testmech/usd" / "dr_testmech.usda") robot_builder.add_usd( asset_file, # Kamino keeps the file's joint order; reduced-coordinate solvers (Steel) need a parent-first tree joint_ordering=None if self.preset.name == "kamino" else "dfs", force_show_colliders=True, force_position_velocity_actuation=False, collapse_fixed_joints=False, enable_self_collisions=False, hide_collision_shapes=True, )
# Create the multi-world model by duplicating the single-robot # builder for the specified number of worlds builder = newton.ModelBuilder(up_axis=newton.Axis.Z) builder.num_rigid_contacts_per_world = 2048 for _ in range(self.world_count): builder.add_world(robot_builder)
# Create the model from the builder self.model = builder.finalize(skip_validation_joints=True)
# Create the Kamino solver for the given model self.build_solver()
# Create state and control data containers self.state_0 = self.model.state() self.state_1 = self.model.state() self.control = self.model.control()
# Attach the model to the viewer for visualization self.viewer.set_model(self.model)
# Capture the simulation graph if running on CUDA # NOTE: This only has an effect on GPU devices self.capture()
# If only a single-world is created, set initial # camera position for better view of the system if self.world_count == 1 and hasattr(self.viewer, "set_camera"): camera_pos = wp.vec3(0.2, 0.2, 0.15) pitch = -20.0 yaw = 215.0 self.viewer.set_camera(camera_pos, pitch, yaw)
def build_solver(self): """Build the solver and everything bound to its instance; the tuner calls this again to swap it.""" if self.preset.name == "kamino": self.config = self.preset.make_config(self.model) self.solver = newton.solvers.SolverKamino(self.model, config=self.config) else: self.solver = self.preset.make_solver(self.model)
def capture(self): self.graph = None if self.device.is_cuda and not wp.config.verify_cuda: with wp.ScopedCapture() as capture: self.simulate() self.graph = capture.graph
# simulate() performs one frame's worth of updates def simulate(self): for substep in range(self.sim_substeps): self.state_0.clear_forces() self.viewer.apply_forces(self.state_0) self.solver.step(self.state_0, self.state_1, self.control, None, self.sim_dt) if self.sim_substeps % 2 == 1 and substep == self.sim_substeps - 1: # an odd count under graph capture: copy the last result into state_0 instead of swapping, # so every replay of the captured graph starts from the newest state self.state_0.assign(self.state_1) else: self.state_0, self.state_1 = self.state_1, self.state_0
def step(self): if self.graph: wp.capture_launch(self.graph) else: self.simulate()
self.sim_time += self.frame_dt
def render(self): self.viewer.begin_frame(self.sim_time) self.viewer.log_state(self.state_0) self.viewer.end_frame()
def test_final(self): pass # TODO: Add some assertions here once we have a more meaningful test scenario
@staticmethod def create_parser(): parser = newton.examples.create_parser() newton.examples.add_world_count_arg(parser) parser.set_defaults(world_count=1) return parser
if __name__ == "__main__": parser = Example.create_parser() viewer, args = newton.examples.init(parser) newton.examples.run(Example(viewer, args), args)example = "loop_dr_testmech"source = "newton/examples/kamino/example_kamino_basic_dr_testmech.py @ skild-ai/newton 7565a26b1"default = "steel"
[check]# Arguments `python -m shelf check` passes in test mode (from Newton's test_examples.py).args = ["--num-frames", "120"]
[gallery]short = "The DR TestMech in many worlds on Kamino."
[xpbd]status = "untested"
[vbd]status = "untested"
[mujoco]status = "untested"
[featherstone]status = "untested"
[semi_implicit]status = "untested"
[feather_pgs]status = "untested"
[steel]status = "works"sim = { fps = 50, substeps = 20 }# loop-closing joints need the "immediate" response; the four loop closures need 38 constraint rows, over the# default 32. 20 substeps x 4 iterations: the fastest setting (RTX PRO 6000 sweep, 2026-11-04) whose loop-closure gap# stays under Kamino's (max 0.36 mm vs 0.47 mm); 10 or 15 substeps open the gaps to 0.6-1.7 mm. Joint limits are# enforced as in Kamino; joint_limit_activation_gap = 0.1 rad adds a limit row only near its limit, which cuts a# quarter of the step time and leaves the motion unchanged.solver = { solve_mode = "matrix_free", iterations = 4, articulated_contact_response = "immediate", enable_joint_limits = true, joint_limit_activation_gap = 0.1, articulation_constraint_max = 64 }checked = "2026-11-04, newton 7565a26b1, NVIDIA GeForce RTX 3090"
[kamino]status = "works"# substeps = frame_dt / sim_dt with sim_dt = 0.001 ssim = { fps = 50, substeps = 20 }solver = { use_collision_detector = false, use_fk_solver = false, padmm = { max_iterations = 200, primal_tolerance = 1e-6, dual_tolerance = 1e-6, compl_tolerance = 1e-6, rho_0 = 0.01 } }checked = "2026-10-28, newton 7565a26b1, NVIDIA RTX A6000"
[implicit_mpm]status = "untested"
[style3d]status = "untested"Steel docs and tutorials are licensed under Apache-2.0. Third-party notices. "Skild", "Skild AI" and the Skild logo are trademarks of Skild AI and are not licensed under Apache-2.0.