Skip to content

Scene prep bug fix#354

Merged
andrewjong merged 11 commits into
mainfrom
scene-prep-bug-fix
May 20, 2026
Merged

Scene prep bug fix#354
andrewjong merged 11 commits into
mainfrom
scene-prep-bug-fix

Conversation

@krrishj18
Copy link
Copy Markdown
Collaborator

@krrishj18 krrishj18 commented May 18, 2026

What features did you add and/or bugs did you address?

  • Which GitHub issue does this address?

    • Additional description if not fully described in the GitHub issue

addresses recurring sim-setup bugs and adds a couple of new knobs to scene_prep.py that came up while authoring custom multi-drone scenes.

Fixes

  • Duplicate UsdPhysics.Scene desync. Isaac's World auto-creates a PhysicsScene and many Kit-saved USDs bake one in too. PhysX can only step a single scene coherently, which triggered "Physics scenes stepping is not the same" warnings and desynced sensors. New dedupe_physics_scenes(stage) keeps the first scene and deactivates the rest (uses SetActive(False) for prims that come in via a referenced sublayer and can't be RemovePrim-ed from the root layer).
  • reference_root_prims_under_world re-referenced the defaultPrim. pg.load_environment already references the source USD's defaultPrim into /World/stage. The helper used to skip only /World, so on stages whose defaultPrim was something else (e.g. Stage) it pulled the same geometry in a second time. Now it skips both World and the defaultPrim.
  • save_scene_as_contained_usd was flattening folder hierarchy. The Collector was called with flat_collection=True but with a misleading comment claiming the opposite — corrected the comment to match the actual flattened behaviour we want for offline scenes.

New knobs

  • Off-origin overhead camera. add_orthographic_camera and add_overhead_camera_publisher now accept center_x_m / center_y_m so the topdown texture can be aimed at an arbitrary point instead of world origin. The publisher emits both values on two new Float32 spec topics (/sim/overhead/center_x, /sim/overhead/center_y) so the GCS visualizer can auto-place the texture without manual configuration.
  • example_multi_drone_scene_import.py picks up the new args, switches from add_ouster_lidar_subgraph to add_rtx_lidar_subgraph to match main's lidar update, calls dedupe_physics_scenes.

How did you implement it?

  • dedupe_physics_scenes(stage)stage.Traverse() for every UsdPhysics.Scene. Keep the first; for the rest, attempt RemovePrim on the root-layer spec, falling back to SetActive(False) for prims that live in a referenced sublayer (where there's no spec in the live layer to remove).

  • add_orthographic_camera(..., center_x_m, center_y_m) — the camera prim's translate op now uses
    Gf.Vec3d(center_x_m * sf, center_y_m * sf, altitude_m * sf). Default values are 0.0, so existing callers are unaffected.

  • add_overhead_camera_publisher(..., center_x_m, center_y_m, center_x_topic, center_y_topic) — two new ConstantFloat -> ROS2Publisher branches added to the OmniGraph alongside the existing spec/coverage branch. Topics default to /sim/overhead/center_x and /sim/overhead/center_y so existing GCS configs keep working.

  • reference_root_prims_under_world — reads source_layer.defaultPrim and adds it to the skip set alongside World. If the source has no defaultPrim, behaviour matches the old
    code.

How do you run and use it?

  • Standard multi-drone sim bring-up — nothing in the launch flow changes from a user's perspective; the bug fixes are automatic and the new overhead-camera knobs are opt-in.

Was facing these issues on scenes such as 'MilitaryBase' or 'Retro Neighborhood'
I changed the ENV_URL in simulation/isaac-sim/launch_scripts/example_multi_drone_scene_import.py to
'/Library/Stages/RetroNeighborhood/RetroNeighborhood.stage.usd' or
'/Library/Stages/Dmytro/MilitaryBase_t_x1100_y200_z0_o_x0_y0_z90.scene.usd'

In Military Base the camera region needs to be changed in simulation/isaac-sim/launch_scripts/example_multi_drone_scene_import.py:

OVERHEAD_ALTITUDE_M = 165.0
OVERHEAD_COVERAGE_M = 225.0
OVERHEAD_CENTER_X_M = 1100.0 # world-X of texture center
OVERHEAD_CENTER_Y_M = 200.0 # world-Y of texture center

For both files they already had PhysicsScene prims in the usd files so previously isaac-sim would crash on clicking play, after adding the dedupe function it works.

airstack up 

and then clicking play in isaac-sim should show that it works.

Testing with PyTest

No new PyTests were added. These fixes will already be tested by existing 'liveliness' and 'sensors'. Furthermore, it only applies to certain scenes/usd files.

Documentation

spawning_drones.md and overhead_camera.md were updated so they have information regarding the new functions.

Versioning

Yes -> "0.18.0-alpha.11"

@krrishj18 krrishj18 marked this pull request as ready for review May 18, 2026 18:06
@krrishj18 krrishj18 requested a review from Copilot May 18, 2026 18:07
@krrishj18 krrishj18 self-assigned this May 18, 2026
@krrishj18 krrishj18 requested a review from andrewjong May 18, 2026 18:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates Isaac Sim scene preparation utilities and example launch scripts to reduce recurring sim-setup issues (duplicate physics scenes, duplicated environment references) and adds new overhead camera centering “knobs” (including publishing center X/Y as ROS topics) to support off-origin environments.

Changes:

  • Add dedupe_physics_scenes(stage) and call it from the multi-drone example to avoid multi-UsdPhysics.Scene issues.
  • Extend overhead camera helpers to support center_x_m / center_y_m and publish the values via new Float32 topics.
  • Update environment root-prim referencing to skip both /World and the source USD’s defaultPrim, and refresh docs + version bump.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
simulation/isaac-sim/utils/scene_prep.py Adds physics-scene dedupe, overhead camera centering + spec topics, and improves environment root-prim referencing.
simulation/isaac-sim/launch_scripts/example_multi_drone_scene_import.py Adopts new scene_prep knobs, calls physics-scene dedupe, and switches LiDAR subgraph to RTX.
docs/simulation/isaac_sim/spawning_drones.md Documents common scene_prep helpers and the new overhead camera centering options.
docs/simulation/isaac_sim/overhead_camera.md Updates overhead camera docs to use the new centering arguments/topics.
.env Bumps version to 0.18.0-alpha.11.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread simulation/isaac-sim/utils/scene_prep.py
Comment on lines +93 to +98
"""Keep the first UsdPhysics.Scene found in the stage; delete the rest.

Isaac's World autocreates a PhysicsScene on init, and Kit-saved USDs
often bake one in too. PhysX can only step a single scene coherently,
so duplicates trigger "Physics scenes stepping is not the same" and
desynced sensors. Returns the kept prim path (or None if no scene).
collect_dir=output_dir,
usd_only=False, # include textures, MDLs, etc.
flat_collection=True, # flatten asset references into one directory
flat_collection=True, # preserve source folder hierarchy

### Lighting — `add_dome_light`

Incase the scene is missing any lights, this adds a dome light that can act like an overhead 'sun'.
Comment on lines +148 to +149
The collected folder contains a standalone root USD with relative references — load it directly via `omniverse://localhost/...` or a local file path. The collected scene will include modifications for scale, colliders, etc applied before saving.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment on lines +324 to +345
(("inputs:domain_id", nodes["context"]), int(domain_id)),
(("inputs:cameraPrim", nodes["create_rp"]), camera_prim_path),
(("inputs:width", nodes["create_rp"]), res),
(("inputs:height", nodes["create_rp"]), res),
(("inputs:type", nodes["rgb"]), "rgb"),
(("inputs:value", nodes["frame"]), str(frame_id)),
(("inputs:value", nodes["topic"]), str(topic)),
(("inputs:value", nodes["spec_value"]), float(coverage_m)),
(("inputs:value", nodes["spec_topic"]), str(spec_topic)),
(("inputs:messageName", nodes["spec_pub"]), "Float32"),
(("inputs:messagePackage", nodes["spec_pub"]), "std_msgs"),
(("inputs:messageSubfolder", nodes["spec_pub"]), "msg"),
(("inputs:value", nodes["cx_value"]), float(center_x_m)),
(("inputs:value", nodes["cx_topic"]), str(center_x_topic)),
(("inputs:messageName", nodes["cx_pub"]), "Float32"),
(("inputs:messagePackage", nodes["cx_pub"]), "std_msgs"),
(("inputs:messageSubfolder", nodes["cx_pub"]), "msg"),
(("inputs:value", nodes["cy_value"]), float(center_y_m)),
(("inputs:value", nodes["cy_topic"]), str(center_y_topic)),
(("inputs:messageName", nodes["cy_pub"]), "Float32"),
(("inputs:messagePackage", nodes["cy_pub"]), "std_msgs"),
(("inputs:messageSubfolder", nodes["cy_pub"]), "msg"),
Comment on lines +63 to +67
from utils.scene_prep import (
get_stage_meters_per_unit, scale_stage_prim, add_colliders,
add_dome_light, save_scene_as_contained_usd,
add_orthographic_camera, add_overhead_camera_publisher,
)
Comment thread simulation/isaac-sim/launch_scripts/example_multi_drone_scene_import.py Outdated
krrishj18 and others added 2 commits May 18, 2026 14:43
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@krrishj18 krrishj18 requested review from JohnYanxinLiu and removed request for andrewjong May 20, 2026 16:22
@andrewjong andrewjong merged commit a26cb25 into main May 20, 2026
1 check passed
@andrewjong andrewjong deleted the scene-prep-bug-fix branch May 20, 2026 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants