| | """ |
| | Convenience script to make a video out of initial environment |
| | configurations. This can be a useful debugging tool to understand |
| | what different sampled environment configurations look like. |
| | """ |
| |
|
| | import argparse |
| |
|
| | import imageio |
| | import numpy as np |
| |
|
| | import robosuite as suite |
| | from robosuite.utils.input_utils import * |
| |
|
| | if __name__ == "__main__": |
| | parser = argparse.ArgumentParser() |
| |
|
| | |
| | parser.add_argument( |
| | "--camera", |
| | type=str, |
| | default="agentview", |
| | ) |
| |
|
| | |
| | parser.add_argument( |
| | "--frames", |
| | type=int, |
| | default=10, |
| | ) |
| |
|
| | |
| | parser.add_argument( |
| | "--output", |
| | type=str, |
| | default="reset.mp4", |
| | ) |
| |
|
| | args = parser.parse_args() |
| | camera_name = args.camera |
| | num_frames = args.frames |
| | output_path = args.output |
| |
|
| | |
| | options = {} |
| |
|
| | |
| | print("Welcome to robosuite v{}!".format(suite.__version__)) |
| | print(suite.__logo__) |
| |
|
| | |
| | options["env_name"] = choose_environment() |
| |
|
| | |
| | if "TwoArm" in options["env_name"]: |
| | |
| | options["env_configuration"] = choose_multi_arm_config() |
| |
|
| | |
| | if options["env_configuration"] == "bimanual": |
| | options["robots"] = "Baxter" |
| | else: |
| | options["robots"] = [] |
| |
|
| | |
| | print("A multiple single-arm configuration was chosen.\n") |
| |
|
| | for i in range(2): |
| | print("Please choose Robot {}...\n".format(i)) |
| | options["robots"].append(choose_robots(exclude_bimanual=True)) |
| |
|
| | |
| | else: |
| | options["robots"] = choose_robots(exclude_bimanual=True) |
| |
|
| | |
| | env = suite.make( |
| | **options, |
| | has_renderer=False, |
| | has_offscreen_renderer=True, |
| | ignore_done=True, |
| | use_camera_obs=False, |
| | control_freq=20, |
| | ) |
| |
|
| | |
| | video_writer = imageio.get_writer(output_path, fps=5) |
| | for i in range(num_frames): |
| | env.reset() |
| | video_img = env.sim.render(height=512, width=512, camera_name=camera_name)[::-1] |
| | env.step(np.zeros_like(env.action_spec[0])) |
| | video_writer.append_data(video_img) |
| | video_writer.close() |
| |
|