Controlling conveyors#
Using a conveyor with suction#
This standalone Newton MJWarp example has one static belt, one parcel, and one kinematic suction tool. It builds the scene from primitives. The belt moves the parcel, the tool seals against its top face and lifts it, and opening the gripper releases it onto the belt.
uv run python scripts/tutorials/01_assets/run_conveyor_suction.py --device cuda:0 --viz newton
Use --viz none to run the same sequence without a window.
Create the scene and conveyor before resetting the simulation. Name the belt’s collision surface and the parcel body in the controller configuration. The belt and parcel use low contact friction because the conveyor controller supplies their tangential traction. After stopping the belt, command the kinematic tool above the parcel with its pads facing down. Stage the gripper command, write the scene before stepping, and refresh it afterward. Close the conveyor and scene before tearing down the simulation.
Code for run_conveyor_suction.py
1# Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md).
2# All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5
6"""Move a parcel along a belt, lift it with suction, and release it in Newton."""
7
8import argparse
9from contextlib import closing
10
11import torch
12from isaaclab_newton.physics import MJWarpSolverCfg, NewtonCfg
13
14import isaaclab.sim as sim_utils
15from isaaclab.app import add_launcher_args, launch_simulation
16from isaaclab.assets import AssetBaseCfg, RigidObjectCfg, SurfaceGripperCfg
17from isaaclab.controllers import Conveyor, ConveyorCfg, ConveyorSurfaceCfg
18from isaaclab.scene import InteractiveScene, InteractiveSceneCfg
19from isaaclab.utils import configclass
20
21PARCEL_SIZE = 0.05
22TOOL_OFFSET = 0.10
23# The controller supplies belt traction independently of the contact material.
24BELT_CONTACT = sim_utils.RigidBodyMaterialBaseCfg(static_friction=1.1e-5, dynamic_friction=1.1e-5)
25
26
27@configclass
28class ConveyorSceneCfg(InteractiveSceneCfg):
29 """A static belt, one parcel, and a kinematic suction tool."""
30
31 ground = AssetBaseCfg(
32 prim_path="/World/Ground",
33 spawn=sim_utils.CuboidCfg(size=(2.0, 1.5, 0.04), collision_props=sim_utils.UsdPhysicsCollisionCfg()),
34 init_state=AssetBaseCfg.InitialStateCfg(pos=(0.0, 0.0, -0.12)),
35 )
36 light = AssetBaseCfg(prim_path="/World/Light", spawn=sim_utils.DomeLightCfg(intensity=2000.0))
37 belt = AssetBaseCfg(
38 prim_path="{ENV_REGEX_NS}/Belt",
39 spawn=sim_utils.CuboidCfg(
40 size=(1.0, 0.28, 0.10),
41 collision_props=sim_utils.UsdPhysicsCollisionCfg(),
42 physics_material=BELT_CONTACT,
43 visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(0.25, 0.28, 0.30)),
44 ),
45 init_state=AssetBaseCfg.InitialStateCfg(pos=(0.0, 0.0, -0.05)),
46 )
47 parcel = RigidObjectCfg(
48 prim_path="{ENV_REGEX_NS}/Parcel",
49 spawn=sim_utils.CuboidCfg(
50 size=(PARCEL_SIZE, PARCEL_SIZE, PARCEL_SIZE),
51 rigid_props=sim_utils.UsdPhysicsRigidBodyCfg(),
52 mass_props=sim_utils.MassCfg(mass=0.05),
53 physics_material=BELT_CONTACT,
54 collision_props=sim_utils.UsdPhysicsCollisionCfg(),
55 visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(0.66, 0.33, 0.12)),
56 ),
57 init_state=RigidObjectCfg.InitialStateCfg(pos=(-0.25, 0.0, PARCEL_SIZE / 2)),
58 )
59 tool = RigidObjectCfg(
60 prim_path="{ENV_REGEX_NS}/Tool",
61 spawn=sim_utils.CuboidCfg(
62 size=(0.035, 0.035, 0.16),
63 rigid_props=sim_utils.UsdPhysicsRigidBodyCfg(kinematic_enabled=True),
64 collision_props=sim_utils.UsdPhysicsCollisionCfg(),
65 visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(0.05, 0.54, 0.82)),
66 ),
67 init_state=RigidObjectCfg.InitialStateCfg(pos=(0.20, 0.0, 0.23), rot=(0.0, 1.0, 0.0, 0.0)),
68 )
69 suction = SurfaceGripperCfg(
70 prim_path="{ENV_REGEX_NS}/Tool",
71 target_prim_path="{ENV_REGEX_NS}/Parcel",
72 tool_offset=(0.0, 0.0, TOOL_OFFSET),
73 )
74
75
76def step_scene(sim: sim_utils.SimulationContext, scene: InteractiveScene, steps: int) -> None:
77 """Apply staged commands and refresh the scene after each physics step."""
78 dt = sim.get_physics_dt()
79 for _ in range(steps):
80 scene.write_data_to_sim()
81 sim.step()
82 scene.update(dt)
83
84
85def run_example(sim: sim_utils.SimulationContext) -> None:
86 """Convey, pick up, and release the parcel."""
87 cfg = ConveyorCfg(
88 surface_specs=(ConveyorSurfaceCfg("{ENV_REGEX_NS}/Belt", velocity=0.20),),
89 body_pattern=r"/Parcel$",
90 body_count_per_env=1,
91 startup_duration_s=0.25,
92 )
93 with closing(InteractiveScene(ConveyorSceneCfg(num_envs=1, env_spacing=1.0))) as scene:
94 with closing(Conveyor(cfg, num_envs=scene.num_envs, sim=sim)) as conveyor:
95 sim.reset()
96 parcel, tool, suction = scene["parcel"], scene["tool"], scene["suction"]
97
98 start_x = parcel.data.root_pos_w.torch[0, 0].item()
99 conveyor.start()
100 step_scene(sim, scene, 120)
101 conveyor.stop()
102 step_scene(sim, scene, 12)
103 distance = parcel.data.root_pos_w.torch[0, 0].item() - start_x
104 if distance <= 0.03:
105 raise RuntimeError("The belt did not move the parcel.")
106 print(f"Conveyor moved the parcel {distance:.2f} m.")
107
108 # Keep the tool pointing down and place the pads just above the box.
109 pose = tool.data.default_root_pose.torch.clone()
110 pose[:, :3] = parcel.data.root_pos_w.torch
111 pose[:, 2] += PARCEL_SIZE / 2 + TOOL_OFFSET + 0.002
112 tool.write_root_pose_to_sim_index(root_pose=pose)
113 close = torch.ones(scene.num_envs, device=sim.device)
114 suction.set_grippers_command_index(close)
115 step_scene(sim, scene, 60)
116 if suction.state.numpy()[0] != 1:
117 raise RuntimeError("The suction pads did not seal.")
118
119 pickup_z = parcel.data.root_pos_w.torch[0, 2].item()
120 for _ in range(120):
121 pose[:, 2] += 0.0006
122 tool.write_root_pose_to_sim_index(root_pose=pose)
123 step_scene(sim, scene, 1)
124 lift = parcel.data.root_pos_w.torch[0, 2].item() - pickup_z
125 if lift <= 0.04:
126 raise RuntimeError("The sealed tool did not lift the parcel.")
127 print(f"Suction lifted the parcel {lift:.2f} m.")
128
129 suction.set_grippers_command_index(-close)
130 step_scene(sim, scene, 60)
131 if suction.state.numpy()[0] != -1 or parcel.data.root_pos_w.torch[0, 2].item() > pickup_z + 0.01:
132 raise RuntimeError("The suction tool did not release the parcel onto the belt.")
133 print("Suction released the parcel onto the belt.")
134
135
136def main() -> None:
137 """Run the example in Newton MJWarp."""
138 parser = argparse.ArgumentParser(description=__doc__)
139 add_launcher_args(parser)
140 args = parser.parse_args()
141 cfg = sim_utils.SimulationCfg(
142 device=args.device,
143 dt=1.0 / 120,
144 physics=NewtonCfg(
145 solver_cfg=MJWarpSolverCfg(use_mujoco_contacts=False, integrator="implicitfast", cone="elliptic"),
146 use_cuda_graph=False,
147 ),
148 )
149 with launch_simulation(cfg, args), sim_utils.build_simulation_context(sim_cfg=cfg) as sim:
150 sim.set_camera_view(eye=(1.1, -0.9, 0.65), target=(0.0, 0.0, 0.06))
151 run_example(sim)
152
153
154if __name__ == "__main__":
155 main()
See Interacting with a surface gripper for backend-specific gripper configuration.
Configuring a controller#
Create a controller after authoring the collision geometry and before the first simulation
reset. This example assumes sim is a simulation context and each environment already
contains a Belt collision surface and five parcels named Parcel0 through Parcel4:
from isaaclab.controllers import Conveyor, ConveyorCfg, ConveyorSurfaceCfg
conveyor = Conveyor(
ConveyorCfg(
surface_specs=(ConveyorSurfaceCfg("{ENV_REGEX_NS}/Belt", velocity=0.35),),
body_pattern=r"/Parcel[0-9]+$",
body_count_per_env=5,
),
num_envs=scene.num_envs,
sim=sim,
)
sim.reset()
conveyor.set_speed_scale(0.5)
conveyor.stop(env_ids=[0])
conveyor.start(env_ids=[0])
conveyor.set_speed_scale(-1.0)
speed_scale contains the requested multiplier for each environment. It multiplies
the configured signed centerline velocity before the startup ramp. Commands persist across
episode and hard resets. Call reset(env_ids)
after restoring bodies to clear stale forces for those environments, and close() before
destroying the simulation.
Removing solver hooks invalidates Newton’s cached step graphs. Newton rebuilds them on a subsequent step when capture is enabled. If you capture the simulation in an enclosing CUDA graph, discard that graph before changing the hooks and capture again before replaying.
For device-side selection, use set_speed_scale(..., env_mask=mask) and
reset(env_mask=mask) with a full-environment boolean Warp or Torch mask.
Same-device masks and contiguous int32 indices reuse native storage without a host round trip.
Strided or int64 indices require normalization. Surface paths follow the simulation’s clone
template, or /World/envs/env_{} for manually built worlds without a clone plan.
The Newton MJWarp implementation uses the force model from the conveyor example in the locked Newton revision. A public runtime interface is tracked in Newton #5501. Straight and curved sections retain their authored relative speeds under each environment’s multiplier. Independent speed profiles can use separate controllers with disjoint collision surfaces. Newton requires world-attached static collision shapes for the belt surfaces. Contact forces produce the prescribed surface motion.