nepyope commited on
Commit
66e65e2
·
verified ·
1 Parent(s): 931f9d9

Update run_sim.py

Browse files
Files changed (1) hide show
  1. run_sim.py +14 -18
run_sim.py CHANGED
@@ -1,6 +1,5 @@
1
  #!/usr/bin/env python3
2
  """Standalone MuJoCo simulator for Unitree G1"""
3
- import argparse
4
  import sys
5
  from pathlib import Path
6
 
@@ -10,23 +9,20 @@ sys.path.insert(0, str(Path(__file__).parent))
10
  import yaml
11
  from sim.simulator_factory import SimulatorFactory, init_channel
12
 
13
- def main():
14
- parser = argparse.ArgumentParser(description="Unitree G1 MuJoCo Simulator")
15
- parser.add_argument("--publish-images", action="store_true",
16
- help="Enable camera image publishing via ZMQ (requires offscreen rendering)")
17
- parser.add_argument("--camera-port", type=int, default=5554,
18
- help="ZMQ port for camera publishing (default: 5555)")
19
- parser.add_argument("--cameras", type=str, nargs="+", default=None,
20
- help="Camera names to publish (default: head_camera)")
21
- args = parser.parse_args()
22
 
23
  # Load config
24
  config_path = Path(__file__).parent / "config.yaml"
25
  with open(config_path) as f:
26
  config = yaml.safe_load(f)
27
 
28
- # Override config with command line args
29
- enable_offscreen = args.publish_images or config.get("ENABLE_OFFSCREEN", False)
30
 
31
  print("="*60)
32
  print("🤖 Starting Unitree G1 MuJoCo Simulator")
@@ -38,10 +34,10 @@ def main():
38
  # Configure cameras if requested
39
  camera_configs = {}
40
  if enable_offscreen:
41
- camera_list = args.cameras or ["head_camera"]
42
  for cam_name in camera_list:
43
  camera_configs[cam_name] = {"height": 480, "width": 640}
44
- print(f"📷 Cameras: {', '.join(camera_list)} → ZMQ port {args.camera_port}")
45
 
46
  print("="*60)
47
 
@@ -59,14 +55,14 @@ def main():
59
 
60
  # Start simulator (blocking)
61
  print("\nSimulator running. Press Ctrl+C to exit.")
62
- if enable_offscreen and args.publish_images:
63
- print(f"Camera images publishing on tcp://localhost:{args.camera_port}")
64
  try:
65
  SimulatorFactory.start_simulator(
66
  sim,
67
  as_thread=False,
68
- enable_image_publish=args.publish_images,
69
- camera_port=args.camera_port,
70
  )
71
  except KeyboardInterrupt:
72
  print("\nShutting down simulator...")
 
1
  #!/usr/bin/env python3
2
  """Standalone MuJoCo simulator for Unitree G1"""
 
3
  import sys
4
  from pathlib import Path
5
 
 
9
  import yaml
10
  from sim.simulator_factory import SimulatorFactory, init_channel
11
 
12
+ def main(n_envs=1, use_async_envs: bool = False,
13
+ publish_images=True, camera_port=5554, cameras=None, **kwargs):
14
+ # Use default values
15
+ publish_images = True
16
+ camera_port = 5554
17
+ cameras = None
 
 
 
18
 
19
  # Load config
20
  config_path = Path(__file__).parent / "config.yaml"
21
  with open(config_path) as f:
22
  config = yaml.safe_load(f)
23
 
24
+ # Override config with default values
25
+ enable_offscreen = publish_images or config.get("ENABLE_OFFSCREEN", False)
26
 
27
  print("="*60)
28
  print("🤖 Starting Unitree G1 MuJoCo Simulator")
 
34
  # Configure cameras if requested
35
  camera_configs = {}
36
  if enable_offscreen:
37
+ camera_list = cameras or ["head_camera"]
38
  for cam_name in camera_list:
39
  camera_configs[cam_name] = {"height": 480, "width": 640}
40
+ print(f"📷 Cameras: {', '.join(camera_list)} → ZMQ port {camera_port}")
41
 
42
  print("="*60)
43
 
 
55
 
56
  # Start simulator (blocking)
57
  print("\nSimulator running. Press Ctrl+C to exit.")
58
+ if enable_offscreen and publish_images:
59
+ print(f"Camera images publishing on tcp://localhost:{camera_port}")
60
  try:
61
  SimulatorFactory.start_simulator(
62
  sim,
63
  as_thread=False,
64
+ enable_image_publish=publish_images,
65
+ camera_port=camera_port,
66
  )
67
  except KeyboardInterrupt:
68
  print("\nShutting down simulator...")