|
| 1 | +# Copyright (c) 2022-2025, 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 | +""" |
| 7 | +This script checks if the app can be launched with non-headless app and start the simulation. |
| 8 | +""" |
| 9 | + |
| 10 | +"""Launch Isaac Sim Simulator first.""" |
| 11 | + |
| 12 | + |
| 13 | +import pytest |
| 14 | + |
| 15 | +from isaaclab.app import AppLauncher |
| 16 | + |
| 17 | +# launch omniverse app |
| 18 | +app_launcher = AppLauncher(experience="isaaclab.python.kit", headless=True) |
| 19 | +simulation_app = app_launcher.app |
| 20 | + |
| 21 | +"""Rest everything follows.""" |
| 22 | + |
| 23 | +import isaaclab.sim as sim_utils |
| 24 | +from isaaclab.assets import AssetBaseCfg |
| 25 | +from isaaclab.scene import InteractiveScene, InteractiveSceneCfg |
| 26 | +from isaaclab.utils import configclass |
| 27 | + |
| 28 | + |
| 29 | +@configclass |
| 30 | +class SensorsSceneCfg(InteractiveSceneCfg): |
| 31 | + """Design the scene with sensors on the robot.""" |
| 32 | + |
| 33 | + # ground plane |
| 34 | + ground = AssetBaseCfg(prim_path="/World/defaultGroundPlane", spawn=sim_utils.GroundPlaneCfg()) |
| 35 | + |
| 36 | + |
| 37 | +def run_simulator( |
| 38 | + sim: sim_utils.SimulationContext, |
| 39 | +): |
| 40 | + """Run the simulator.""" |
| 41 | + |
| 42 | + count = 0 |
| 43 | + |
| 44 | + # Simulate physics |
| 45 | + while simulation_app.is_running() and count < 100: |
| 46 | + # perform step |
| 47 | + sim.step() |
| 48 | + count += 1 |
| 49 | + |
| 50 | + |
| 51 | +@pytest.mark.isaacsim_ci |
| 52 | +def test_non_headless_launch(): |
| 53 | + # Initialize the simulation context |
| 54 | + sim_cfg = sim_utils.SimulationCfg(dt=0.005) |
| 55 | + sim = sim_utils.SimulationContext(sim_cfg) |
| 56 | + # design scene |
| 57 | + scene_cfg = SensorsSceneCfg(num_envs=1, env_spacing=2.0) |
| 58 | + scene = InteractiveScene(scene_cfg) |
| 59 | + print(scene) |
| 60 | + # Play the simulator |
| 61 | + sim.reset() |
| 62 | + # Now we are ready! |
| 63 | + print("[INFO]: Setup complete...") |
| 64 | + # Run the simulator |
| 65 | + run_simulator(sim) |
0 commit comments