Commit a972182b authored by Mayank Mittal's avatar Mayank Mittal

Fixes formatting issues in the robot loading benchmark script

parent 92dcb8c0
...@@ -22,9 +22,9 @@ from omni.isaac.lab.app import AppLauncher ...@@ -22,9 +22,9 @@ from omni.isaac.lab.app import AppLauncher
parser = argparse.ArgumentParser(description="Benchmark loading different robots.") parser = argparse.ArgumentParser(description="Benchmark loading different robots.")
parser.add_argument("--num_envs", type=int, default=32, help="Number of robots to simulate.") parser.add_argument("--num_envs", type=int, default=32, help="Number of robots to simulate.")
parser.add_argument( parser.add_argument(
"--robot", "--robot",
type=str, type=str,
choices=['anymal_d', 'h1', 'g1'], choices=["anymal_d", "h1", "g1"],
default="h1", default="h1",
help="Choose which robot to load: anymal_d, h1, or g1.", help="Choose which robot to load: anymal_d, h1, or g1.",
) )
...@@ -69,6 +69,7 @@ imports_time_end = time.perf_counter_ns() ...@@ -69,6 +69,7 @@ imports_time_end = time.perf_counter_ns()
print(f"[INFO]: Imports time: {(imports_time_end - imports_time_begin) / 1e6:.2f} ms") print(f"[INFO]: Imports time: {(imports_time_end - imports_time_begin) / 1e6:.2f} ms")
@configclass @configclass
class RobotSceneCfg(InteractiveSceneCfg): class RobotSceneCfg(InteractiveSceneCfg):
"""Configuration for a simple scene with a robot.""" """Configuration for a simple scene with a robot."""
...@@ -91,6 +92,7 @@ class RobotSceneCfg(InteractiveSceneCfg): ...@@ -91,6 +92,7 @@ class RobotSceneCfg(InteractiveSceneCfg):
else: else:
raise ValueError(f"Unsupported robot type: {args_cli.robot}.") raise ValueError(f"Unsupported robot type: {args_cli.robot}.")
def run_simulator(sim: sim_utils.SimulationContext, scene: InteractiveScene): def run_simulator(sim: sim_utils.SimulationContext, scene: InteractiveScene):
"""Runs the simulation loop.""" """Runs the simulation loop."""
# Extract scene entities # Extract scene entities
...@@ -98,18 +100,15 @@ def run_simulator(sim: sim_utils.SimulationContext, scene: InteractiveScene): ...@@ -98,18 +100,15 @@ def run_simulator(sim: sim_utils.SimulationContext, scene: InteractiveScene):
robot = scene["robot"] robot = scene["robot"]
# Define simulation stepping # Define simulation stepping
sim_dt = sim.get_physics_dt() sim_dt = sim.get_physics_dt()
count = 0
# Start the timer for creating the scene # Start the timer for creating the scene
step_time_begin = time.perf_counter_ns() step_time_begin = time.perf_counter_ns()
num_steps = 2000 num_steps = 2000
# Simulation loop # Simulation loop
for _ in range(num_steps): for count in range(num_steps):
# Reset # Reset
if count % 500 == 0: if count % 500 == 0:
# reset counter
count = 0
# reset the scene entities # reset the scene entities
# root state # root state
# we offset the root state by the origin since the states are written in simulation world frame # we offset the root state by the origin since the states are written in simulation world frame
...@@ -132,11 +131,9 @@ def run_simulator(sim: sim_utils.SimulationContext, scene: InteractiveScene): ...@@ -132,11 +131,9 @@ def run_simulator(sim: sim_utils.SimulationContext, scene: InteractiveScene):
scene.write_data_to_sim() scene.write_data_to_sim()
# Perform step # Perform step
sim.step() sim.step()
# Increment counter
count += 1
# Update buffers # Update buffers
scene.update(sim_dt) scene.update(sim_dt)
# Stop the timer for reset # Stop the timer for reset
step_time_end = time.perf_counter_ns() step_time_end = time.perf_counter_ns()
print(f"[INFO]: Per step time: {(step_time_end - step_time_begin) / num_steps / 1e6:.2f} ms") print(f"[INFO]: Per step time: {(step_time_end - step_time_begin) / num_steps / 1e6:.2f} ms")
...@@ -149,7 +146,7 @@ def main(): ...@@ -149,7 +146,7 @@ def main():
sim = SimulationContext(sim_cfg) sim = SimulationContext(sim_cfg)
# Set main camera # Set main camera
sim.set_camera_view([2.5, 0.0, 4.0], [0.0, 0.0, 2.0]) sim.set_camera_view([2.5, 0.0, 4.0], [0.0, 0.0, 2.0])
# Start the timer for creating the scene # Start the timer for creating the scene
setup_time_begin = time.perf_counter_ns() setup_time_begin = time.perf_counter_ns()
# Design scene # Design scene
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment