Scene prep bug fix#354
Open
krrishj18 wants to merge 11 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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.Sceneissues. - Extend overhead camera helpers to support
center_x_m/center_y_mand publish the values via new Float32 topics. - Update environment root-prim referencing to skip both
/Worldand the source USD’sdefaultPrim, 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 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. | ||
|
|
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, | ||
| ) |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| ENV_URL = f"omniverse://{NUCLEUS_SERVER}/Projects/AirStack/scenes/urban/allegheny_county_fire_academy/fire_academy.scene.usd" | ||
| #f"omniverse://{NUCLEUS_SERVER}/Library/Assets/FireAcademyFaro/fire_academy_faro.usd" | ||
| #f"omniverse://{NUCLEUS_SERVER}/Projects/AirStack/RayFronts-Planner/FireAcademy.scene.usd" | ||
| #f"omniverse://{NUCLEUS_SERVER}/Library/Assets/Fire_Academy_Digital_Twin/fire_academy.usd" |
Collaborator
There was a problem hiding this comment.
Do we not want to keep these examples? Especially since it's an example file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What features did you add and/or bugs did you address?
Which GitHub issue does this address?
addresses recurring sim-setup bugs and adds a couple of new knobs to
scene_prep.pythat came up while authoring custom multi-drone scenes.Fixes
UsdPhysics.Scenedesync. Isaac'sWorldauto-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. Newdedupe_physics_scenes(stage)keeps the first scene and deactivates the rest (usesSetActive(False)for prims that come in via a referenced sublayer and can't beRemovePrim-ed from the root layer).reference_root_prims_under_worldre-referenced the defaultPrim.pg.load_environmentalready 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 bothWorldand the defaultPrim.save_scene_as_contained_usdwas flattening folder hierarchy. The Collector was called withflat_collection=Truebut with a misleading comment claiming the opposite — corrected the comment to match the actual flattened behaviour we want for offline scenes.New knobs
add_orthographic_cameraandadd_overhead_camera_publishernow acceptcenter_x_m/center_y_mso 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.pypicks up the new args, switches fromadd_ouster_lidar_subgraphtoadd_rtx_lidar_subgraphto match main's lidar update, callsdedupe_physics_scenes.How did you implement it?
dedupe_physics_scenes(stage)—stage.Traverse()for everyUsdPhysics.Scene. Keep the first; for the rest, attemptRemovePrimon the root-layer spec, falling back toSetActive(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 usesGf.Vec3d(center_x_m * sf, center_y_m * sf, altitude_m * sf). Default values are0.0, so existing callers are unaffected.add_overhead_camera_publisher(..., center_x_m, center_y_m, center_x_topic, center_y_topic)— two newConstantFloat -> ROS2Publisherbranches added to the OmniGraph alongside the existing spec/coverage branch. Topics default to/sim/overhead/center_xand/sim/overhead/center_yso existing GCS configs keep working.reference_root_prims_under_world— readssource_layer.defaultPrimand adds it to theskipset alongsideWorld. If the source has no defaultPrim, behaviour matches the oldcode.
How do you run and use it?
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.
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
.envfile according to semantic versioning?Yes -> "0.18.0-alpha.11"