03 · Tune the robot¶
Goal. Make the imported Lime simulate well. The arm should hold its pose, the wheels should follow velocity commands, the casters should slide, and the gripper should open and close. Then make it look like the real robot. The tuning goes into its own USD file, so a re-import never loses it.
Concepts¶
Joint drives¶
Every movable joint has a drive, a spring-damper that PhysX solves implicitly, so it stays stable even when stiff:
| Use | stiffness \(k_p\) | damping \(k_d\) | target |
|---|---|---|---|
| Position control (arm, gripper) | > 0 | > 0 | position |
| Velocity control (wheels) | 0 | > 0 | velocity |
\(\tau_{max}\) is Max Force. The importer took it from the URDF effort limits (wheels 3 N·m, arm 1 N·m)
but left stiffness and damping at 0, which is why everything was limp in tutorial 02.
Units: USD stores angular gains per degree
In the Property panel and in the .usda file, revolute stiffness is N·m/deg and damping is
N·m·s/deg. Isaac Sim's Python APIs (Articulation.set_dof_gains) use radians.
200 N·m/rad = 3.49 N·m/deg. The script converts with gain * π / 180.
Friction and combine modes¶
Where two colliders touch, PhysX combines their friction coefficients. The default is the average. Our casters are meant to slide, so they get friction 0. The floor (a ground plane with no physics material of its own) uses PhysX's default material, which has friction > 0. The average of the two is not 0. The caster pads carry the heavy battery at the back, and that friction brakes the robot. Setting the caster material's combine mode to min makes its 0.0 win.
Measured on the final tuned asset (both wheels at 5 rad/s for 3 s, ideal distance 0.90 m):
| Caster material | Floor | Distance | Wheel speed |
|---|---|---|---|
| friction 0, combine average | default material | 0.67 m | 1.2 / 2.4 rad/s (and it curves) |
| friction 0, combine average | friction set to 0 | 0.87 m | 5.0 rad/s |
| friction 0, combine min | default material | 0.87 m | 5.0 rad/s |
The second row confirms the cause: removing friction at the caster–floor contact fixes the problem. The third row fixes it without touching the floor.
The robot on the left of the video at the top drives even less, about 0.25 m. Its caster pads have no physics material at all, so they keep PhysX's default friction instead of 0. Give that robot only the caster material (friction 0, combine min), with its arm still fallen over and its cylinder tyres, and it drives 0.86 m in the same test.
Wheel colliders: cylinder vs sphere¶
The URDF describes each tyre as a cylinder, 0.06 m radius and 24 mm wide. A cylinder touches the floor along a line across its tread. When the robot turns, the inner and outer end of that line would need different speeds, so the tyre scrubs and resists the turn. A sphere with the same radius touches the floor in one point, which is the ideal wheel that the differential-drive formula (tutorial 06) assumes.
Measured: command 0.2 m/s and 0.5 rad/s, then read the robot's real yaw rate:
| Tyre collider | Wheel speeds (command 2.11 / 4.56 rad/s) | Yaw rate (command 0.5 rad/s) |
|---|---|---|
| cylinder (URDF) | 2.40 / 4.16 rad/s | 0.44 rad/s |
| sphere | 2.06 / 4.56 rad/s | 0.50 rad/s |
So the tuned asset switches the cylinder's collision off and adds an invisible sphere collider (sphere_collider,
purpose guide) to each wheel link. The visible tyre mesh is unchanged.
Looks: the real robot's colours¶
The URDF paints the whole robot grey. The real Lime is black and lime green: black waffle plates and Dynamixel servos, lime-green 3D-printed brackets, translucent yellow-green tyres with lime hubs, metal standoffs, and the LiDAR on a lime mount. The colours below were measured from a photo of the real robot.

One mesh per link is too coarse: link2.stl, for example, holds a servo, a bracket and four screws. But inside the
mesh these are separate solids: groups of triangles that don't share a vertex with the rest. The script splits
every mesh into its solids and colours each one by its size: a 28 × 42 × 46 mm block is a Dynamixel servo
(black), other arm parts are brackets (lime), the wheel's 120 mm ring is the tyre and its 84 mm disc the hub.
Only the look changes. The colliders, the masses and the joints are untouched.
The colours and the rules: isaac/common/looks.py
# name: (base colour as linear RGB, roughness, metallic, opacity) - UsdPreviewSurface values
COLOURS = {
"black": ((0.005, 0.005, 0.005), 0.55, 0.0, 1.0), # waffle plates, LiDAR, gripper
"servo": ((0.008, 0.008, 0.008), 0.30, 0.0, 1.0), # Dynamixel XM430 servos (slightly glossy)
"lime": ((0.16, 0.62, 0.012), 0.45, 0.0, 1.0), # 3D-printed PLA brackets
"tyre": ((0.55, 0.65, 0.03), 0.20, 0.0, 0.85), # translucent yellow-green tyres
"hub": ((0.30, 0.62, 0.03), 0.40, 0.0, 1.0), # lime wheel hubs
"metal": ((0.60, 0.60, 0.62), 0.30, 1.0, 1.0), # aluminium standoffs, screws
}
def classify(mesh_name: str, size: np.ndarray, faces: int) -> str:
"""Which colour is this solid? size = its sorted extents in mm, faces = its number of triangles."""
small, middle, large = size
if mesh_name == "tire":
return "tyre" if large > 100 else "hub" # the outer ring vs the inner disc
if mesh_name == "ladar":
return "lime" if small < 15 and large > 50 else "black" # the LiDAR sits on a lime mount plate
if mesh_name == "base":
if small < 8 and middle < 8 and large > 15:
return "metal" # standoffs: thin rods
return "black" # plates, battery, boards
if mesh_name.startswith("gripper") or mesh_name == "link7":
return "black" # the gripper and its servo
if faces < 300 or large < 15:
return "metal" # screws, small parts
if 26 <= small <= 31 and 33 <= middle <= 44 and 39 <= large <= 48:
return "servo" # Dynamixel XM430: 28.5 x 34 x 46.5 mm
return "lime" # brackets
Instanced meshes
The importer stores each link's visual mesh as an instance: a shared, read-only copy. To colour parts of
it, the script first switches instancing off for the visual meshes (SetInstanceable(False), an override in
the tuned layer). The colliders stay instanced.
Solver iterations¶
An articulation (the robot's joint tree) is solved iteratively. Raising the articulation's position iterations from 32 (default) to 64 made the drive test slightly more accurate: 0.847 m → 0.874 m in the run above. Keep velocity iterations ≤ 4. PhysX's TGS solver changed how it treats more, and it prints a warning.
The values¶
| What | Setting |
|---|---|
| Wheels (×2) | velocity drive: stiffness 0, damping 100 N·m·s/rad, max force 3 N·m (XM430-W210) |
| Arm joints (×6) | position drive: stiffness 200 N·m/rad, damping 10 N·m·s/rad, max force 4.1 N·m (XM430-W350 stall torque) |
| Arm start pose | the SRDF home pose [0, -1.10, 1.80, 0, 0.98, 0] rad, as both the drive target and the initial joint state (upstream uses 1.87 for joint3, which is outside its own URDF limit of 1.8567; MoveIt rejects that in tutorial 12. 1.80 leaves a margin for the arm sagging under gravity) |
| Gripper (left) | position drive: stiffness 1000 N/m, damping 20 N·s/m, max force 10 N |
| Gripper (right) | no drive. It follows the left finger through its mimic joint |
| Tyres / casters | friction 1.0 (average) / friction 0.0 (min) |
| Tyre collision shape | sphere, r = 0.06 m, instead of the URDF cylinder |
| Articulation | 64 position / 4 velocity solver iterations |
| Look | black plates and servos, lime brackets, translucent yellow-green tyres, lime hubs, metal standoffs (common/looks.py) |
Tune it¶
Open your stage from tutorial 02, my_stages/02_import.usd (robot referenced, Physics = physx, ground plane).
Drives. In the Stage panel open turtlebot3_lime ▸ Physics and select a joint, for example joint2.
In Property ▸ Drive ▸ Angular set Stiffness, Damping and Max Force (in per-degree units, see the table above).
Set Target Position in degrees. Select several joints at once (Ctrl+click) to edit them together.

Gain Tuner. Tools ▸ Robotics ▸ Asset Editors ▸ Gain Tuner shows all joints of the selected articulation in one table. It can also play test motions (sinusoids or steps) and plot how each joint follows them. Use it to see the effect of a gain before you commit to it.

Friction. Create ▸ Physics ▸ Physics Material (rigid body). In its Rigid Body Material section
set Static/Dynamic Friction. In its Material (PhysX) section set the Friction Combine Mode to min
for the caster material. Then select each caster collider (caster_back_*_link/box) and choose the
material in Property ▸ Physics materials on selected models. Do not use the Materials on
selected models section: that one is for the visual look.
Sphere tyres (these GUI steps describe what the script does; the script is the verified path).
For each wheel_*_link: select its cylinder and untick Collider ▸ Collision Enabled.
Then right-click the link and choose Create ▸ Shape ▸ Sphere. Set its Radius to 0.06 and Purpose to
guide (not rendered). Add a collider with Add ▸ Physics ▸ Collider and bind the tyre physics material.
Solver. Select base_link (the articulation root). In its Articulation Root / PhysxArticulationAPI
properties set Solver Position Iteration Count = 64 and Solver Velocity Iteration Count = 4.
Looks (these GUI steps describe what the script does; the script is the verified path). Create ▸
Material ▸ OmniPBR for each colour and set its Albedo colour. Select a link's visual prim, for example
link4/link4, untick Instanceable in the Property panel (instanced prims are read-only), then pick the
material under Materials on selected models. In the GUI you colour whole meshes; colouring the solids
inside a mesh separately (servo black, bracket lime) is what the script adds.
Save as an override layer. Your stage holds the imported robot as a reference, so your edits did not
change the imported files. They are stored in your stage as overs on top of the reference. Press Stop ■
and save it: File ▸ Save As my_stages/03_tune_robot.usd. The script below builds the same kind of
layer and writes it to assets/usd/turtlebot3_lime_tuned.usda. Don't save over that file: every later
tutorial loads it, and expects the robot at its root, not a whole stage.
The script writes assets/usd/turtlebot3_lime_tuned.usda, a small layer that references the
import and adds overrides. Then it loads that file and checks the result.
robot = stage.DefinePrim("/turtlebot3_lime", "Xform")
robot.GetReferences().AddReference("./turtlebot3_lime/turtlebot3_lime.usda")
robot.GetVariantSet("Physics").SetVariantSelection("physx") # (1)!
drive = UsdPhysics.DriveAPI.Apply(joint_prim, "angular")
drive.CreateStiffnessAttr(200.0 * math.pi / 180.0) # (2)!
drive.CreateDampingAttr(10.0 * math.pi / 180.0)
drive.CreateMaxForceAttr(4.1)
drive.CreateTargetPositionAttr(math.degrees(home)) # (3)!
PhysxSchema.PhysxMaterialAPI.Apply(caster_material).CreateFrictionCombineModeAttr("min")
looks.paint_like_the_real_lime(stage, "/turtlebot3_lime") # (4)!
- Users of the tuned file no longer have to pick the physics variant.
- N·m/rad → N·m/deg.
- USD joint angles are in degrees too.
- The real robot's colours, solid by solid (see Looks above).
Full script: isaac/03_tune_robot.py
# SPDX-FileCopyrightText: 2026 An (an-robotics)
# SPDX-License-Identifier: Apache-2.0
"""Tutorial 03 - Tune TurtleBot3 Lime: joint drives, wheel/caster friction, start pose.
python isaac/03_tune_robot.py # write the tuned asset, then try it in the GUI
python isaac/03_tune_robot.py --headless --test
Right after the URDF import (tutorial 02) the robot is *not* ready to simulate:
* every joint drive has stiffness = damping = 0, so the arm collapses under gravity and the
wheels cannot be driven;
* the two small caster pads use the default friction, so they drag on the floor when turning;
* the arm starts stretched out at 0 rad instead of the folded "home" pose;
* the URDF paints the whole robot grey - the real Lime is black and lime green.
This script writes the fixes into a NEW layer, assets/usd/turtlebot3_lime_tuned.usda, that *references*
the imported asset. The imported files stay untouched, so re-running tutorial 02 never loses the tuning.
Then it loads the tuned robot and checks that the arm holds its pose, the wheels follow a velocity
command and the gripper opens.
"""
import math
import os
import sys
from common.cli import parse_args
args = parse_args(__doc__.splitlines()[0])
from isaacsim import SimulationApp
simulation_app = SimulationApp({"headless": args.headless, "width": 1280, "height": 720})
import isaacsim.core.experimental.utils.app as app_utils
import isaacsim.core.experimental.utils.stage as stage_utils
import numpy as np
from common import lime, looks
from common.paths import LIME_IMPORTED_USD, LIME_USD
from isaacsim.core.experimental.objects import GroundPlane
from isaacsim.core.experimental.prims import Articulation
from isaacsim.core.simulation_manager import SimulationManager
from pxr import PhysxSchema, Sdf, Usd, UsdGeom, UsdLux, UsdPhysics, UsdShade
# ---------------------------------------------------------------------------------------------------
# Tuning values - SI units (radians, metres, N, N*m). Change them and re-run to see the effect.
# ---------------------------------------------------------------------------------------------------
WHEEL_DRIVE = dict(stiffness=0.0, damping=100.0, max_force=3.0) # velocity control: stiffness MUST be 0
ARM_DRIVE = dict(stiffness=200.0, damping=10.0, max_force=4.1) # position control (XM430 stall torque 4.1 N*m)
GRIPPER_DRIVE = dict(stiffness=1000.0, damping=20.0, max_force=10.0) # position control, prismatic (N/m)
WHEEL_FRICTION = 1.0 # rubber tyres
CASTER_FRICTION = 0.0 # the caster pads should slide freely
SOLVER_ITERATIONS = (64, 4) # (position, velocity) iterations; PhysX TGS wants <= 4 velocity iterations
def angular_gain_to_usd(gain_per_rad: float) -> float:
"""USD stores angular drive gains per DEGREE (N*m/deg); we think in N*m/rad."""
return gain_per_rad * math.pi / 180.0
# ---------------------------------------------------------------------------------------------------
# 1. Create the tuned layer: turtlebot3_lime_tuned.usda --references--> turtlebot3_lime/turtlebot3_lime.usda
# ---------------------------------------------------------------------------------------------------
if LIME_USD.exists():
LIME_USD.unlink()
layer = Sdf.Layer.CreateNew(str(LIME_USD))
stage = Usd.Stage.Open(layer)
UsdGeom.SetStageUpAxis(stage, UsdGeom.Tokens.z)
UsdGeom.SetStageMetersPerUnit(stage, 1.0)
UsdPhysics.SetStageKilogramsPerUnit(stage, 1.0)
robot = stage.DefinePrim("/turtlebot3_lime", "Xform")
stage.SetDefaultPrim(robot)
robot.GetReferences().AddReference("./" + os.path.relpath(LIME_IMPORTED_USD, LIME_USD.parent))
# Select PhysX physics by default (see tutorial 02) - users of this file no longer have to.
robot.GetVariantSet("Physics").SetVariantSelection("physx")
def joint(name: str) -> Usd.Prim:
return stage.GetPrimAtPath(f"/turtlebot3_lime/Physics/{name}")
def set_drive(name: str, kind: str, stiffness: float, damping: float, max_force: float, target: float):
"""kind: 'angular' (revolute, target in rad) or 'linear' (prismatic, target in m)."""
prim = joint(name)
drive = UsdPhysics.DriveAPI.Apply(prim, kind)
to_usd = angular_gain_to_usd if kind == "angular" else (lambda g: g)
drive.CreateTypeAttr("force")
drive.CreateStiffnessAttr(to_usd(stiffness))
drive.CreateDampingAttr(to_usd(damping))
drive.CreateMaxForceAttr(max_force)
if stiffness > 0: # position drive: target + initial joint position (USD angles are in degrees)
value = math.degrees(target) if kind == "angular" else target
drive.CreateTargetPositionAttr(value)
prim.CreateAttribute(f"state:{kind}:physics:position", Sdf.ValueTypeNames.Float).Set(value)
else: # velocity drive
drive.CreateTargetVelocityAttr(0.0)
# 2. Joint drives ------------------------------------------------------------------------------------
for name in lime.WHEEL_JOINTS:
set_drive(name, "angular", **WHEEL_DRIVE, target=0.0)
for name, home in zip(lime.ARM_JOINTS, lime.ARM_HOME):
set_drive(name, "angular", **ARM_DRIVE, target=home)
set_drive(lime.GRIPPER_JOINT, "linear", **GRIPPER_DRIVE, target=0.0)
# gripper_right_joint follows gripper_left_joint through its mimic joint (NewtonMimicAPI authored by the
# importer from the URDF <mimic> tag), so it gets no drive of its own.
set_drive(lime.GRIPPER_MIMIC_JOINT, "linear", stiffness=0.0, damping=0.0, max_force=GRIPPER_DRIVE["max_force"], target=0.0)
# 3. Physics materials (friction) -----------------------------------------------------------------------
def physics_material(path: str, friction: float, combine_mode: str = "average") -> UsdShade.Material:
mat = UsdShade.Material.Define(stage, path)
api = UsdPhysics.MaterialAPI.Apply(mat.GetPrim())
api.CreateStaticFrictionAttr(friction)
api.CreateDynamicFrictionAttr(friction)
api.CreateRestitutionAttr(0.0)
# When two materials touch, PhysX COMBINES their friction - by default it takes the AVERAGE.
# A 0.0-friction caster on a floor with friction > 0 still gets friction > 0 and brakes the robot
# (measured: 0.67 m instead of 0.87 m in the drive test below). "min" makes the caster's 0.0 win.
PhysxSchema.PhysxMaterialAPI.Apply(mat.GetPrim()).CreateFrictionCombineModeAttr(combine_mode)
return mat
wheel_mat = physics_material("/turtlebot3_lime/PhysicsMaterials/wheel", WHEEL_FRICTION)
caster_mat = physics_material("/turtlebot3_lime/PhysicsMaterials/caster", CASTER_FRICTION, combine_mode="min")
base = f"/turtlebot3_lime/{lime.BASE_LINK}"
def bind_physics_material(prim: Usd.Prim, mat: UsdShade.Material):
UsdShade.MaterialBindingAPI.Apply(prim).Bind(mat, UsdShade.Tokens.weakerThanDescendants, "physics")
for link in ["caster_back_left_link", "caster_back_right_link"]:
bind_physics_material(stage.GetPrimAtPath(f"{base}/{link}/box"), caster_mat)
# 3b. Wheel colliders: sphere instead of cylinder ------------------------------------------------------
# The URDF tyre is a 24 mm wide cylinder that touches the floor along a LINE. In a turn the inner and
# outer edge of that line want different speeds, the tyre scrubs, and the robot turns ~12 % slower than
# commanded. A sphere of the same radius touches the floor in one POINT, like the ideal wheel the
# differential-drive formula assumes (measured: 0.44 -> 0.50 rad/s for a 0.5 rad/s command).
for link in lime.WHEEL_JOINTS:
link_path = f"{base}/{link.replace('_joint', '_link')}"
UsdPhysics.CollisionAPI(stage.GetPrimAtPath(f"{link_path}/cylinder")).CreateCollisionEnabledAttr(False)
sphere = UsdGeom.Sphere.Define(stage, f"{link_path}/sphere_collider")
sphere.CreateRadiusAttr(lime.WHEEL_RADIUS)
sphere.CreatePurposeAttr(UsdGeom.Tokens.guide) # a collision shape only: not rendered
UsdPhysics.CollisionAPI.Apply(sphere.GetPrim())
bind_physics_material(sphere.GetPrim(), wheel_mat)
# 4. Articulation solver ---------------------------------------------------------------------------------
# More solver iterations = more accurate joints + contacts (default: 32 position iterations).
articulation = PhysxSchema.PhysxArticulationAPI.Apply(stage.GetPrimAtPath(f"/turtlebot3_lime/{lime.ARTICULATION_ROOT}"))
articulation.CreateSolverPositionIterationCountAttr(SOLVER_ITERATIONS[0])
articulation.CreateSolverVelocityIterationCountAttr(SOLVER_ITERATIONS[1])
# 4b. Looks: the colours of the real Lime ---------------------------------------------------------------
# Black plates and servos, lime-green brackets, translucent yellow-green tyres (common/looks.py).
painted = looks.paint_like_the_real_lime(stage, "/turtlebot3_lime")
print(f"[03] painted like the real Lime: {', '.join(f'{name} {n} faces' for name, n in painted.items())}", flush=True)
layer.Save()
print(f"[03] wrote tuned robot: {LIME_USD}")
# ---------------------------------------------------------------------------------------------------
# 5. Try the tuned robot
# ---------------------------------------------------------------------------------------------------
stage = stage_utils.create_new_stage(template="sunlight")
UsdLux.DomeLight.Define(stage, "/World/DomeLight").GetIntensityAttr().Set(500.0)
GroundPlane("/World/GroundPlane")
root_path = lime.add_lime("/World/turtlebot3_lime", position=(0.0, 0.0, 0.0))
recorder = None
if args.record:
from common.recorder import Recorder
recorder = Recorder(args.record, eye=(1.0, -1.0, 0.7), target=(0.2, 0.0, 0.2))
SimulationManager.setup_simulation(dt=1.0 / 60.0)
app_utils.play()
simulation_app.update()
robot = Articulation(root_path)
arm_idx = robot.get_dof_indices(lime.ARM_JOINTS)
wheel_idx = robot.get_dof_indices(lime.WHEEL_JOINTS)
grip_idx = robot.get_dof_indices([lime.GRIPPER_JOINT, lime.GRIPPER_MIMIC_JOINT])
def base_xy():
return robot.get_world_poses()[0].numpy()[0, :2].copy()
results = {}
step = 0
WHEEL_SPEED = 5.0 # rad/s -> 5 * 0.06 = 0.3 m/s
while simulation_app.is_running():
t = step / 60.0
if step == 120: # t = 2 s: arm settled -> measure pose error, then drive forward
q = robot.get_dof_positions(dof_indices=arm_idx).numpy()[0]
results["arm_error"] = float(np.max(np.abs(q - np.array(lime.ARM_HOME))))
results["start_xy"] = base_xy()
robot.set_dof_velocity_targets([[WHEEL_SPEED, WHEEL_SPEED]], dof_indices=wheel_idx)
if step == 300: # t = 5 s: stop wheels, open the gripper
results["distance"] = float(np.linalg.norm(base_xy() - results["start_xy"]))
robot.set_dof_velocity_targets([[0.0, 0.0]], dof_indices=wheel_idx)
robot.set_dof_position_targets([[lime.GRIPPER_OPEN]], dof_indices=robot.get_dof_indices([lime.GRIPPER_JOINT]))
if step == 420: # t = 7 s: check gripper
results["gripper"] = robot.get_dof_positions(dof_indices=grip_idx).numpy()[0].tolist()
simulation_app.update()
if recorder:
recorder.look_at(eye=(base_xy()[0] + 1.0, -1.0, 0.7), target=(base_xy()[0] + 0.1, base_xy()[1], 0.15))
recorder.capture()
step += 1
if (args.test or args.record) and step > 430:
break
ok = True
if "gripper" in results:
expected = WHEEL_SPEED * lime.WHEEL_RADIUS * 3.0 # 3 s at 0.3 m/s = 0.9 m
left, right = results["gripper"]
print(f"[03] arm max error after 2 s : {results['arm_error']:.3f} rad")
print(f"[03] distance in 3 s : {results['distance']:.3f} m (ideal {expected:.2f} m)")
print(f"[03] gripper left / right : {left:.4f} / {right:.4f} m (target {lime.GRIPPER_OPEN})")
if args.test:
ok = (
results["arm_error"] < 0.05
and abs(results["distance"] - expected) < 0.2 * expected
and abs(left - lime.GRIPPER_OPEN) < 0.003
)
print(f"[03][test] {'PASS' if ok else 'FAIL'}")
if recorder:
recorder.save()
app_utils.stop()
simulation_app.close(exit_code=0 if ok else 1)
sys.exit(0 if ok else 1)
Check the result¶
[03] painted like the real Lime: black 645338 faces, servo 38830 faces, lime 45098 faces, tyre 5848 faces, hub 8444 faces, metal 3864 faces
[03] arm max error after 2 s : 0.002 rad
[03] distance in 3 s : 0.873 m (ideal 0.90 m)
[03] gripper left / right : 0.0190 / 0.0190 m (target 0.019)
[03][test] PASS
- The arm holds
homeagainst gravity to within 0.002 rad (0.1°). - 5 rad/s × 0.06 m = 0.30 m/s, so 0.90 m in 3 s. The missing 2.6 cm is the acceleration phase.
- The right finger copies the left one exactly: the mimic joint works under PhysX.
03_tune_robot.py with the tuned robot: the arm holds, the robot drives, the gripper opens.Experiment
Change ARM_DRIVE = dict(stiffness=200.0, ...) to stiffness=20.0 and re-run: the arm sags.
Change the caster combine mode back to "average": the robot covers only about 0.67 m, curves, and the
distance test fails.
Before and after, side by side¶
isaac/03_before_after.py makes the video at the top of this page. It puts the imported robot next to the tuned
one and runs the same test on both. It only reads the two assets, so run 03_tune_robot.py first.
The left robot is the asset exactly as tutorial 02 imported it:
# The robot as imported (tutorial 02): pick the PhysX variant, place it. Nothing else.
stage_utils.add_reference_to_stage(str(LIME_IMPORTED_USD), "/World/as_imported", variants=[("Physics", "physx")])
XformPrim("/World/as_imported", reset_xform_op_properties=True).set_world_poses(positions=[[0.0, LANES["as imported"], 0.0]])
# The tuned robot (tutorial 03).
lime.add_lime("/World/tuned", position=(0.0, LANES["tuned"], 0.0))
with one change. Its wheel drives have no damping, so a speed command would do nothing at all. The script gives them the tuned robot's damping, in the running simulation only:
# The ONE change to the imported robot: a velocity drive on the wheels (stiffness 0, damping as tuned).
# The Python API takes SI units (N*m*s/rad); it changes the running simulation only, not the asset.
before = robots["as imported"]
wheels = before.get_dof_indices(lime.WHEEL_JOINTS)
before.set_dof_gains(stiffnesses=[[0.0, 0.0]], dampings=[[WHEEL_DAMPING, WHEEL_DAMPING]], dof_indices=wheels)
[03vs] as imported : arm moved 1.819 rad in 2 s, drove 0.251 m (sideways +0.044 m, turned +17.5 deg), wheels 3.06 / 1.26 rad/s, gripper 1.1 mm
[03vs] tuned : arm moved 0.001 rad in 2 s, drove 0.874 m (sideways +0.001 m, turned +0.1 deg), wheels 5.00 / 5.01 rad/s, gripper 19.0 mm
[03vs][check] ok tuned: arm holds its pose (moved 0.001 rad)
[03vs][check] ok tuned: drove 0.87 m (ideal 0.90 m)
[03vs][check] ok tuned: gripper open (19.0 mm)
[03vs][check] ok as imported: arm falls (moved 1.82 rad)
[03vs][check] ok as imported: gripper does not open (1.1 mm)
[03vs][test] PASS
- The imported arm has no stiffness, so it falls over by about 105° in the first 2 s.
- The imported wheels turn at only about 3 and 1 rad/s instead of 5, and the robot covers a quarter of a metre and veers. The caster pads cause it (see Friction and combine modes).
- The imported gripper has no drive, so the command to open it does nothing.
- The left robot's drive is sensitive to small changes in the scene: moving the robots by a few centimetres gave 0.23–0.25 m and 17–19°. So the check tests only its arm and gripper. The tuned robot must pass the same test as above.
Full script: isaac/03_before_after.py
# SPDX-FileCopyrightText: 2026 An (an-robotics)
# SPDX-License-Identifier: Apache-2.0
"""Tutorial 03 - before and after: the robot as imported next to the tuned robot, same test.
python isaac/03_before_after.py # watch it in the GUI
python isaac/03_before_after.py --headless --test
Two Limes stand side by side and get the drive test of 03_tune_robot.py: wait 2 s, both wheels at 5 rad/s
for 3 s, then open the gripper.
* "as imported": the asset exactly as tutorial 02 imported it, with ONE change: its wheels get the same
velocity-drive damping as the tuned robot (set at runtime). Without it the wheels could not follow the
speed command at all, and there would be nothing to compare.
* "tuned": the robot from tutorial 03 (assets/usd/turtlebot3_lime_tuned.usda).
Run 03_tune_robot.py first: this script only reads the two assets, it writes none.
"""
import math
import sys
from common.cli import parse_args
args = parse_args(__doc__.splitlines()[0])
from isaacsim import SimulationApp
simulation_app = SimulationApp({"headless": args.headless, "width": 1280, "height": 720})
import isaacsim.core.experimental.utils.app as app_utils
import isaacsim.core.experimental.utils.stage as stage_utils
import numpy as np
from common import lime
from common.paths import LIME_IMPORTED_USD
from isaacsim.core.experimental.objects import GroundPlane
from isaacsim.core.experimental.prims import Articulation, XformPrim
from isaacsim.core.simulation_manager import SimulationManager
from pxr import Gf, UsdGeom, UsdLux
WHEEL_SPEED = 5.0 # rad/s, as in 03_tune_robot.py: 5 * 0.06 = 0.3 m/s, 0.9 m in 3 s
WHEEL_DAMPING = 100.0 # N*m*s/rad, the tuned robot's wheel drive (03_tune_robot.py: WHEEL_DRIVE)
LANES = {"as imported": -0.4, "tuned": 0.4} # y of each robot's lane, m (seen from the front: left, right)
stage = stage_utils.create_new_stage(template="sunlight")
UsdLux.DomeLight.Define(stage, "/World/DomeLight").GetIntensityAttr().Set(500.0)
GroundPlane("/World/GroundPlane")
# The robot as imported (tutorial 02): pick the PhysX variant, place it. Nothing else.
stage_utils.add_reference_to_stage(str(LIME_IMPORTED_USD), "/World/as_imported", variants=[("Physics", "physx")])
XformPrim("/World/as_imported", reset_xform_op_properties=True).set_world_poses(positions=[[0.0, LANES["as imported"], 0.0]])
# The tuned robot (tutorial 03).
lime.add_lime("/World/tuned", position=(0.0, LANES["tuned"], 0.0))
def floor_line(path, x, y, length, colour):
"""A thin painted line on the floor across a lane (looks only: no collider)."""
line = UsdGeom.Cube.Define(stage, path)
line.CreateSizeAttr(1.0)
line.CreateDisplayColorAttr([Gf.Vec3f(*colour)])
xform = UsdGeom.Xformable(line.GetPrim())
xform.AddTranslateOp().Set(Gf.Vec3d(x, y, 0.001))
xform.AddScaleOp().Set(Gf.Vec3f(0.015, length, 0.002))
for name, y in LANES.items():
tag = name.replace(" ", "_")
floor_line(f"/World/Lines/start_{tag}", 0.0, y, 0.5, (0.1, 0.1, 0.1))
floor_line(f"/World/Lines/ideal_{tag}", WHEEL_SPEED * lime.WHEEL_RADIUS * 3.0, y, 0.5, (0.9, 0.5, 0.05))
recorder = None
if args.record:
from common.recorder import Recorder
# A fixed camera in front of the two lanes: "as imported" on the left, "tuned" on the right.
recorder = Recorder(args.record, eye=(4.0, 0.0, 1.75), target=(0.55, 0.0, 0.12), focal_length=24.0)
SimulationManager.setup_simulation(dt=1.0 / 60.0)
app_utils.play()
simulation_app.update()
robots = {
"as imported": Articulation(f"/World/as_imported/{lime.ARTICULATION_ROOT}"),
"tuned": Articulation(f"/World/tuned/{lime.ARTICULATION_ROOT}"),
}
# The ONE change to the imported robot: a velocity drive on the wheels (stiffness 0, damping as tuned).
# The Python API takes SI units (N*m*s/rad); it changes the running simulation only, not the asset.
before = robots["as imported"]
wheels = before.get_dof_indices(lime.WHEEL_JOINTS)
before.set_dof_gains(stiffnesses=[[0.0, 0.0]], dampings=[[WHEEL_DAMPING, WHEEL_DAMPING]], dof_indices=wheels)
def pose(robot):
"""x, y (m) and yaw (rad) of the robot's base."""
p, q = robot.get_world_poses()
w, x, y, z = q.numpy()[0]
return float(p.numpy()[0, 0]), float(p.numpy()[0, 1]), math.atan2(2 * (w * z + x * y), 1 - 2 * (y * y + z * z))
def arm(robot):
return robot.get_dof_positions(dof_indices=robot.get_dof_indices(lime.ARM_JOINTS)).numpy()[0]
def gripper(robot):
return float(robot.get_dof_positions(dof_indices=robot.get_dof_indices([lime.GRIPPER_JOINT])).numpy()[0, 0])
start_arm = {name: arm(robot) for name, robot in robots.items()}
frames = [] # what the overlay prints on each recorded frame
results = {name: {"wheel_speeds": []} for name in robots}
step = 0
while simulation_app.is_running():
for name, robot in robots.items():
r = results[name]
wheel_idx = robot.get_dof_indices(lime.WHEEL_JOINTS)
if step == 120: # t = 2 s: how far did the arm move by itself? Then drive.
r["arm_moved"] = float(np.max(np.abs(arm(robot) - start_arm[name])))
r["start"] = pose(robot)
robot.set_dof_velocity_targets([[WHEEL_SPEED, WHEEL_SPEED]], dof_indices=wheel_idx)
if 210 <= step < 300: # the last 1.5 s of the drive: wheel speeds
r["wheel_speeds"].append(robot.get_dof_velocities(dof_indices=wheel_idx).numpy()[0])
if step == 300: # t = 5 s: stop, open the gripper
x0, y0, yaw0 = r["start"]
x, y, yaw = pose(robot)
r["distance"], r["drift"], r["turn"] = math.hypot(x - x0, y - y0), y - y0, math.degrees(yaw - yaw0)
robot.set_dof_velocity_targets([[0.0, 0.0]], dof_indices=wheel_idx)
robot.set_dof_position_targets([[lime.GRIPPER_OPEN]], dof_indices=robot.get_dof_indices([lime.GRIPPER_JOINT]))
if step == 420: # t = 7 s
r["gripper"] = gripper(robot)
simulation_app.update()
if recorder:
n = len(recorder.frames)
recorder.capture()
if len(recorder.frames) > n: # a frame was recorded: note what to print on it
live = {}
for name, robot in robots.items():
r = results[name]
x, y, yaw = pose(robot)
x0, y0, yaw0 = r.get("start", (x, y, yaw))
driven, turn = (r["distance"], r["turn"]) if "distance" in r else (math.hypot(x - x0, y - y0), math.degrees(yaw - yaw0))
live[name] = dict(arm=float(np.max(np.abs(arm(robot) - start_arm[name]))), driven=driven, turn=turn,
gripper=gripper(robot))
frames.append((step / 60.0, live))
step += 1
if (args.test or args.record) and step > 430:
break
ok = True
if all("gripper" in r for r in results.values()):
for name, r in results.items():
left, right = np.mean(r["wheel_speeds"], axis=0)
print(f"[03vs] {name:12s}: arm moved {r['arm_moved']:.3f} rad in 2 s, drove {r['distance']:.3f} m "
f"(sideways {r['drift']:+.3f} m, turned {r['turn']:+.1f} deg), wheels {left:.2f} / {right:.2f} rad/s, "
f"gripper {r['gripper'] * 1000:.1f} mm")
if args.test:
ideal = WHEEL_SPEED * lime.WHEEL_RADIUS * 3.0
tuned, imported = results["tuned"], results["as imported"]
checks = [ # the tuned robot passes tutorial 03's test; the imported one fails where it must
(tuned["arm_moved"] < 0.05, f"tuned: arm holds its pose (moved {tuned['arm_moved']:.3f} rad)"),
(abs(tuned["distance"] - ideal) < 0.2 * ideal, f"tuned: drove {tuned['distance']:.2f} m (ideal {ideal:.2f} m)"),
(abs(tuned["gripper"] - lime.GRIPPER_OPEN) < 0.003, f"tuned: gripper open ({tuned['gripper'] * 1000:.1f} mm)"),
(imported["arm_moved"] > 0.5, f"as imported: arm falls (moved {imported['arm_moved']:.2f} rad)"),
(imported["gripper"] < 0.005, f"as imported: gripper does not open ({imported['gripper'] * 1000:.1f} mm)"),
]
for passed, text in checks:
print(f"[03vs][check] {'ok ' if passed else 'FAIL'} {text}")
ok = all(passed for passed, _ in checks)
print(f"[03vs][test] {'PASS' if ok else 'FAIL'}")
else:
ok = False
if recorder:
# Print the live numbers on the frames, hold the last frame for 2 s, save.
from PIL import Image, ImageDraw, ImageFont
big, small = ImageFont.load_default(size=28), ImageFont.load_default(size=22)
TITLES = {"as imported": "As imported (+ wheel drive)", "tuned": "Tuned"}
def phase(t):
if t < 2.0:
return f"t = {t:.1f} s waiting: does the arm hold its pose?"
if t < 5.0:
return f"t = {t:.1f} s both wheels 5 rad/s for 3 s (ideal 0.90 m)"
return f"t = {t:.1f} s stop, open the gripper"
def show(value, spec):
"""format() without a "-0.0" for values that round to zero."""
return format(float(format(value, spec)) + 0.0, spec)
def annotate(frame, t, live):
img = Image.fromarray(frame)
draw = ImageDraw.Draw(img, "RGBA")
width, height = img.size
text = phase(t)
w = draw.textlength(text, font=big)
draw.rounded_rectangle(((width - w) / 2 - 16, 14, (width + w) / 2 + 16, 62), 10, fill=(0, 0, 0, 160))
draw.text(((width - w) / 2, 22), text, font=big, fill="white")
for i, name in enumerate(TITLES):
v = live[name]
lines = [("arm moved", f"{show(math.degrees(v['arm']), '.1f')} deg"), ("driven", f"{show(v['driven'], '.2f')} m"),
("turned", f"{show(v['turn'], '+.1f')} deg"), ("gripper", f"{show(v['gripper'] * 1000, '.1f')} mm")]
x0 = 24 if i == 0 else width - 24 - 380
draw.rounded_rectangle((x0, height - 176, x0 + 380, height - 20), 10, fill=(0, 0, 0, 160))
draw.text((x0 + 16, height - 168), TITLES[name], font=big, fill=(255, 210, 120) if i == 0 else (170, 240, 120))
for k, (label, value) in enumerate(lines):
draw.text((x0 + 16, height - 128 + k * 26), label, font=small, fill="white")
draw.text((x0 + 180, height - 128 + k * 26), value, font=small, fill="white")
return np.asarray(img)
recorder.frames = [annotate(f, t, live) for f, (t, live) in zip(recorder.frames, frames)]
recorder.frames += [recorder.frames[-1]] * 60
recorder.save()
app_utils.stop()
simulation_app.close(exit_code=0 if ok else 1)
sys.exit(0 if ok else 1)
From now on every tutorial loads assets/usd/turtlebot3_lime_tuned.usda. In Python that is
common.lime.add_lime().
Next: 04 · Move it from Python