Skip to content

[Fix] add_new_robot tutorial wheel-velocity action on GPU device#5776

Draft
hujc7 wants to merge 1 commit into
isaac-sim:developfrom
hujc7:jichuanh/tutorial-add-new-robot-cpu-device
Draft

[Fix] add_new_robot tutorial wheel-velocity action on GPU device#5776
hujc7 wants to merge 1 commit into
isaac-sim:developfrom
hujc7:jichuanh/tutorial-add-new-robot-cpu-device

Conversation

@hujc7
Copy link
Copy Markdown
Collaborator

@hujc7 hujc7 commented May 26, 2026

1. Summary

  • scripts/tutorials/01_assets/add_new_robot.py errored at runtime: the wheel-velocity action was a CPU torch.Tensor and set_joint_velocity_target dispatches to a GPU Warp kernel that rejects CPU tensors at type check.
  • Allocate the two wheel-velocity templates once on sim.device, reuse across the loop, and call set_joint_velocity_target_index (also silences the deprecation warning visible in the bug report's first line).
  • Scope: tutorial only. 1 file, +12 −3 plus a changelog fragment.

2. Why it broke

The bug has therefore been latent since #4551 and surfaced now that more users are running the tutorial on v3.0.0-beta.

3. Why only this tutorial

A grep across scripts/tutorials/**.py for tensor literals fed into set_joint_*_target* / write_*_to_sim_index shows add_new_robot.py is the only file constructing tensors without a device= kwarg. Every other tutorial either reads from a .torch accessor (already on device) or uses torch.tensor(..., device=sim.device).

4. Test plan

  • Reproduced the customer's error in isolation: CPU torch.Tensorwp.launchargument 'in_data' expects an array of type array(ndim=2, dtype=float32), but passed value has type Tensor.
  • Same launch with a GPU tensor (.cuda()) succeeds.
  • Pre-commit clean on changed files.
  • Manual smoke: ./isaaclab.sh -p scripts/tutorials/01_assets/add_new_robot.py --num_envs 1 --headless runs through several reset cycles.

5. Out of scope

  • The underlying API in isaaclab_physx silently accepts CPU torch tensors at the Python boundary and only fails inside wp.launch. Auto-moving CPU tensors to self.device in set_joint_*_target_index would prevent users from hitting this from other scripts. Not in scope here per the bug-report preference for a tutorial-only fix; flagging for follow-up.

Refs NVBug 6156303

scripts/tutorials/01_assets/add_new_robot.py built the Jetbot wheel-
velocity action with torch.Tensor([[10.0, 10.0]]) — a CPU tensor — and
forwarded it to the deprecated set_joint_velocity_target wrapper. The
underlying wp.launch in isaaclab_physx rejects CPU torch tensors at
kernel-argument type check, so the tutorial errored at runtime.

Allocate the two wheel-velocity templates once on sim.device, reuse
them across the loop iterations, and call the recommended
set_joint_velocity_target_index variant (silences the deprecation
warning the bug report also captured).

The reset block in the same file already used the GPU device through
data.default_joint_pos.torch.clone(); the per-step action block was the
only remaining CPU-tensor site.

This pattern is unique to add_new_robot.py — every other tutorial
script under scripts/tutorials/ either pulls tensors from .torch
accessors (already on device) or constructs them with
torch.tensor(..., device=sim.device). Confirmed by a grep across
the tutorials tree.

Refs NVBug 6156303
@github-actions github-actions Bot added the isaac-lab Related to Isaac Lab team label May 26, 2026
Copy link
Copy Markdown

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

This PR correctly fixes a runtime error in the add_new_robot.py tutorial caused by passing CPU tensors to GPU Warp kernels. The fix is well-structured and follows established patterns in other Isaac Lab tutorials.

Strengths

  • Root cause addressed: Pre-allocating tensors on sim.device ensures compatibility with the GPU-based asset layer.
  • API modernization: Migrating from the deprecated set_joint_velocity_target() to set_joint_velocity_target_index() addresses the deprecation warning noted in the bug report.
  • Efficient pattern: Allocating tensors once outside the loop rather than per-iteration is the correct approach.
  • Thorough PR description: The root cause analysis and historical context (PRs #289, #4551, #4911) help reviewers understand why this bug existed and why only this tutorial was affected.

Minor Observations

No blocking issues found. The implementation is clean and matches the patterns used in other tutorials (e.g., run_articulation.py).

CI Note

The "Check for Broken Links" CI failure is unrelated to this PR — it's caused by an external site (threedworld.org) returning HTTP 403.

LGTM from a code perspective.


# wheel-velocity templates allocated once on the simulation device; the joint
# target setters dispatch to GPU Warp kernels and reject CPU tensors.
straight_action = torch.tensor([[10.0, 10.0]], device=sim.device)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good practice: pre-allocating these tensors on the correct device outside the loop avoids per-iteration allocation overhead and ensures GPU compatibility.

@hujc7 hujc7 changed the title [Docs] Fix add_new_robot tutorial wheel-velocity action on GPU device [Fix] add_new_robot tutorial wheel-velocity action on GPU device May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant