mani_skill.trajectory.convert_to_lerobot#

Converts ManiSkill HDF5 trajectory files to LeRobot v3.0 format.

Usage:

python convert_maniskill_to_lerobot.py input.h5 output_dir –task-name “Pick cube”

For more information: huggingface/lerobot

Attributes#

Classes#

Functions#

calculate_statistics(all_dataframes, ...)

create_directory_structure(output_dir, rgb_cameras, ...)

create_meta_files(base_path, episode_lengths, ...[, ...])

create_video_from_frames(frames, output_path, fps, ...)

detect_rgb_cameras(obs_group)

load_metadata(h5_file)

load_trajectory_from_h5(h5_file)

main(args)

parse_image_size(size_str)

process_episode(episode_data, episode_idx, has_state, fps)

resize_image_with_padding(image, target_size)

Module Contents#

class mani_skill.trajectory.convert_to_lerobot.Args[source]#
chunks_size: int = 1000[source]#
Type:

Episodes per chunk (default

fps: int = 30[source]#
Type:

Video FPS (default

image_size: str = '640x480'[source]#

640x480)

Type:

Output image size as WIDTHxHEIGHT or single value for square (default

output_dir: str[source]#

Output directory for LeRobot dataset

robot_type: str | None = None[source]#

auto-detected, e.g., “panda”, “ur5”)

Type:

Robot type (default

task_name: str | None = None[source]#

auto-detected from metadata)

Type:

Task description (default

traj_path: str[source]#

Path to ManiSkill .h5 trajectory file

mani_skill.trajectory.convert_to_lerobot.calculate_statistics(all_dataframes, all_rgb_data_by_camera, has_state)[source]#
Parameters:
  • all_dataframes (List[pandas.DataFrame]) –

  • all_rgb_data_by_camera (Dict[str, List[numpy.ndarray]]) –

  • has_state (bool) –

Return type:

Dict[str, Any]

mani_skill.trajectory.convert_to_lerobot.create_directory_structure(output_dir, rgb_cameras, num_episodes, chunks_size=DEFAULT_CHUNKS_SIZE)[source]#
Parameters:
  • output_dir (str) –

  • rgb_cameras (List[str]) –

  • num_episodes (int) –

  • chunks_size (int) –

Return type:

pathlib.Path

mani_skill.trajectory.convert_to_lerobot.create_meta_files(base_path, episode_lengths, total_frames, action_dim, state_dim, rgb_cameras, metadata, task_name, chunks_size, fps, image_width, image_height, all_dataframes, all_rgb_data_by_camera, robot_type_override=None)[source]#
Parameters:
  • base_path (pathlib.Path) –

  • episode_lengths (List[int]) –

  • total_frames (int) –

  • action_dim (int) –

  • state_dim (Optional[int]) –

  • rgb_cameras (List[str]) –

  • metadata (Dict[str, Any]) –

  • task_name (str) –

  • chunks_size (int) –

  • fps (int) –

  • image_width (int) –

  • image_height (int) –

  • all_dataframes (List[pandas.DataFrame]) –

  • all_rgb_data_by_camera (Dict[str, List[numpy.ndarray]]) –

  • robot_type_override (Optional[str]) –

Return type:

None

mani_skill.trajectory.convert_to_lerobot.create_video_from_frames(frames, output_path, fps, image_width, image_height)[source]#
Parameters:
  • frames (numpy.ndarray) –

  • output_path (pathlib.Path) –

  • fps (int) –

  • image_width (int) –

  • image_height (int) –

Return type:

None

mani_skill.trajectory.convert_to_lerobot.detect_rgb_cameras(obs_group)[source]#
Parameters:

obs_group (h5py.Group) –

Return type:

List[str]

mani_skill.trajectory.convert_to_lerobot.load_metadata(h5_file)[source]#
Parameters:

h5_file (pathlib.Path) –

Return type:

Dict[str, Any]

mani_skill.trajectory.convert_to_lerobot.load_trajectory_from_h5(h5_file)[source]#
Parameters:

h5_file (pathlib.Path) –

Return type:

Tuple[List[Dict[str, numpy.ndarray]], Dict[str, Any]]

mani_skill.trajectory.convert_to_lerobot.main(args)[source]#
Parameters:

args (Args) –

mani_skill.trajectory.convert_to_lerobot.parse_image_size(size_str)[source]#
Parameters:

size_str (str) –

Return type:

Tuple[int, int]

mani_skill.trajectory.convert_to_lerobot.process_episode(episode_data, episode_idx, has_state, fps, task_index=0, task_name='Unknown task')[source]#
Parameters:
  • episode_data (Dict[str, numpy.ndarray]) –

  • episode_idx (int) –

  • has_state (bool) –

  • fps (int) –

  • task_index (int) –

  • task_name (str) –

Return type:

pandas.DataFrame

mani_skill.trajectory.convert_to_lerobot.resize_image_with_padding(image, target_size)[source]#
Parameters:
  • image (numpy.ndarray) –

  • target_size (Tuple[int, int]) –

Return type:

numpy.ndarray

mani_skill.trajectory.convert_to_lerobot.DEFAULT_CHUNKS_SIZE = 1000[source]#
mani_skill.trajectory.convert_to_lerobot.DEFAULT_FPS = 30[source]#
mani_skill.trajectory.convert_to_lerobot.DEFAULT_IMAGE_SIZE = '640x480'[source]#
mani_skill.trajectory.convert_to_lerobot.logger[source]#
mani_skill.trajectory.convert_to_lerobot.parsed_args = None[source]#