-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathlaunch_sim.py
35 lines (28 loc) · 1.04 KB
/
launch_sim.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import stretch_mujoco
import click
import cv2
from stretch_mujoco.enums.stretch_cameras import StretchCameras
@click.command()
@click.option("--scene-xml-path", help="Path to a scene xml file")
@click.option("--headless", is_flag=True, help="Run the simulation headless")
@click.option("--imagery", is_flag=True, help="Show the cameras' imagery")
def main(
scene_xml_path: str,
headless: bool,
imagery: bool
) -> None:
sim = stretch_mujoco.StretchMujocoSimulator(scene_xml_path)
sim.start(headless=headless)
cameras_to_use = StretchCameras.all() if imagery else StretchCameras.none()
try:
while sim.is_running():
if imagery: # display camera feeds
camera_data = sim.pull_camera_data()
for camera in cameras_to_use:
image = cv2.cvtColor(camera_data.get_camera_data(camera), cv2.COLOR_RGB2BGR)
cv2.imshow(camera.name, image)
except KeyboardInterrupt:
sim.stop()
cv2.destroyAllWindows()
if __name__ == "__main__":
main()