mani_skill.trajectory.replay_trajectory ======================================= .. py:module:: mani_skill.trajectory.replay_trajectory .. autoapi-nested-parse:: Replay ManiSkill trajectories stored in HDF5 (.h5) format The replayed trajectory can use different observation modes and control modes. We support translating actions from certain controllers to a limited number of controllers. The script is only tested for Panda, and may include some Panda-specific hardcode. Classes ------- .. autoapisummary:: mani_skill.trajectory.replay_trajectory.Args mani_skill.trajectory.replay_trajectory.ReplayResult Functions --------- .. autoapisummary:: mani_skill.trajectory.replay_trajectory._main mani_skill.trajectory.replay_trajectory._main_helper mani_skill.trajectory.replay_trajectory.main mani_skill.trajectory.replay_trajectory.parse_args mani_skill.trajectory.replay_trajectory.replay_cpu_sim mani_skill.trajectory.replay_trajectory.replay_parallelized_sim mani_skill.trajectory.replay_trajectory.sanity_check_and_format_seed Module Contents --------------- .. py:class:: Args .. py:attribute:: allow_failure :type: bool :value: False Whether to include episodes that fail in saved videos and trajectory data based on the environment's evaluation returned "success" label .. py:attribute:: count :type: Optional[int] :value: None Number of demonstrations to replay before exiting. By default will replay all demonstrations .. py:attribute:: discard_timeout :type: bool :value: False Whether to discard episodes that timeout and are truncated (depends on the max_episode_steps parameter of task) .. py:attribute:: max_retry :type: int :value: 0 Maximum number of times to try and replay a trajectory until the task reaches a success state at the end. .. py:attribute:: num_envs :type: Annotated[int, tyro.conf.arg(aliases=['-n'])] :value: 1 Number of environments to run to replay trajectories. With CPU backends typically this is parallelized via python multiprocessing. For parallelized simulation backends like physx_gpu, this is parallelized within a single python process by leveraging the GPU. .. py:attribute:: obs_mode :type: Annotated[Optional[str], tyro.conf.arg(aliases=['-o'])] :value: None Target observation mode to record in the trajectory. See https://maniskill.readthedocs.io/en/latest/user_guide/concepts/observation.html for a full list of supported observation modes. .. py:attribute:: record_rewards :type: bool :value: False Whether the replayed trajectory should include rewards .. py:attribute:: render_mode :type: str :value: 'rgb_array' The render mode used for saving videos. Typically there is also 'sensors' and 'all' render modes which further render all sensor outputs like cameras. .. py:attribute:: reward_mode :type: Optional[str] :value: None Specifies the reward type that the env should use. By default it will pick the first supported reward mode. Most environments support 'sparse', 'none', and some further support 'normalized_dense' and 'dense' reward modes .. py:attribute:: save_traj :type: bool :value: False Whether to save trajectories to disk. This will not override the original trajectory file. .. py:attribute:: save_video :type: bool :value: False Whether to save videos .. py:attribute:: shader :type: Optional[str] :value: None Change shader used for rendering for all cameras. Default is none meaning it will use whatever was used in the original data collection or the environment default. Can also be 'rt' for ray tracing and generating photo-realistic renders. Can also be 'rt-fast' for a faster but lower quality ray-traced renderer .. py:attribute:: sim_backend :type: Annotated[Optional[str], tyro.conf.arg(aliases=['-b'])] :value: None Which simulation backend to use. Can be 'physx_cpu', 'physx_gpu'. If not specified the backend used is the same as the one used to collect the trajectory data. .. py:attribute:: target_control_mode :type: Annotated[Optional[str], tyro.conf.arg(aliases=['-c'])] :value: None Target control mode to convert the demonstration actions to. Note that not all control modes can be converted to others successfully and not all robots have easy to convert control modes. Currently the Panda robots are the best supported when it comes to control mode conversion. Furthermore control mode conversion is not supported in GPU parallelized environments. .. py:attribute:: traj_path :type: str Path to the trajectory .h5 file to replay .. py:attribute:: use_env_states :type: bool :value: False Whether to replay by environment states instead of actions. This guarantees that the environment will look exactly the same as the original trajectory at every step. .. py:attribute:: use_first_env_state :type: bool :value: False Use the first env state in the trajectory to set initial state. This can be useful for trying to replay demonstrations collected in the CPU simulation in the GPU simulation by first starting with the same initial state as GPU simulated tasks will randomize initial states differently despite given the same seed compared to CPU sim. .. py:attribute:: verbose :type: bool :value: False Whether to print verbose information during trajectory replays .. py:attribute:: video_fps :type: Optional[int] :value: None The FPS of saved videos. Defaults to the control frequency .. py:attribute:: vis :type: bool :value: False Whether to visualize the trajectory replay via the GUI. .. py:class:: ReplayResult .. py:attribute:: num_replays :type: int .. py:attribute:: successful_replays :type: int .. py:function:: _main(args, use_cpu_backend, env_id, env_kwargs, ori_env_kwargs, record_episode_kwargs, proc_id = 0, num_procs=1) .. py:function:: _main_helper(x) .. py:function:: main(args) .. py:function:: parse_args(args=None) .. py:function:: replay_cpu_sim(args, env, ori_env, pbar, episodes, trajectories) .. py:function:: replay_parallelized_sim(args, env, pbar, episodes, trajectories) .. py:function:: sanity_check_and_format_seed(episode) sanity checks the trajectory seed aligns with the episode seed. reformats the reset kwargs seed if missing or formatted wrong