-
Notifications
You must be signed in to change notification settings - Fork 2k
Support video frame output for Cosmos #2005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c5b6e3f
d704709
44312fc
b7b4b6d
70e58db
fdaf1a1
ba5c11c
c495589
d0653a4
964ced1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,9 @@ | |
|
||
from __future__ import annotations | ||
|
||
import os | ||
import torch | ||
from torchvision.utils import save_image | ||
from typing import TYPE_CHECKING | ||
|
||
import isaaclab.utils.math as math_utils | ||
|
@@ -237,6 +239,8 @@ def image( | |
data_type: str = "rgb", | ||
convert_perspective_to_orthogonal: bool = False, | ||
normalize: bool = True, | ||
save_image_to_file: bool = False, | ||
image_path: str = "image", | ||
) -> torch.Tensor: | ||
"""Images of a specific datatype from the camera sensor. | ||
|
||
|
@@ -276,6 +280,18 @@ def image( | |
images -= mean_tensor | ||
elif "distance_to" in data_type or "depth" in data_type: | ||
images[images == float("inf")] = 0 | ||
elif data_type == "normals": | ||
images = (images + 1.0) * 0.5 | ||
|
||
if save_image_to_file: | ||
dir_path, _ = os.path.split(image_path) | ||
if dir_path: | ||
os.makedirs(dir_path, exist_ok=True) | ||
if images.dtype == torch.uint8: | ||
images = images.float() / 255.0 | ||
for tile in range(images.shape[0]): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would be good to have an option to save all tiles to a single file or save each tile individually. this might get a bit too much when we have lots of tiles. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. My inclination would be to use a callback pattern - then the user can do any post-processing they'd like - perhaps save only ever 100 observation, or save only RGB, etc. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah yes, that's a good idea! |
||
tile_chw = torch.swapaxes(images[tile : tile + 1].unsqueeze(1), 1, -1).squeeze(-1) | ||
save_image(tile_chw, f"{image_path}_{data_type}_{tile}_{env.common_step_counter}.png") | ||
|
||
return images.clone() | ||
|
||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
# Copyright (c) 2024-2025, The Isaac Lab Project Developers. | ||
# All rights reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from isaaclab.envs.mimic_env_cfg import MimicEnvCfg, SubTaskConfig | ||
from isaaclab.utils import configclass | ||
|
||
from isaaclab_tasks.manager_based.manipulation.stack.config.franka.stack_ik_rel_blueprint_env_cfg import ( | ||
FrankaCubeStackBlueprintEnvCfg, | ||
) | ||
|
||
|
||
@configclass | ||
class FrankaCubeStackIKRelBlueprintMimicEnvCfg(FrankaCubeStackBlueprintEnvCfg, MimicEnvCfg): | ||
""" | ||
Isaac Lab Mimic environment config class for Franka Cube Stack IK Rel env. | ||
""" | ||
|
||
def __post_init__(self): | ||
# post init of parents | ||
super().__post_init__() | ||
|
||
# Override the existing values | ||
self.datagen_config.name = "isaac_lab_franka_stack_ik_rel_blueprint_D0" | ||
self.datagen_config.generation_guarantee = True | ||
self.datagen_config.generation_keep_failed = True | ||
self.datagen_config.generation_num_trials = 10 | ||
self.datagen_config.generation_select_src_per_subtask = True | ||
self.datagen_config.generation_transform_first_robot_pose = False | ||
self.datagen_config.generation_interpolate_from_last_target_pose = True | ||
self.datagen_config.max_num_failures = 25 | ||
self.datagen_config.seed = 1 | ||
|
||
# The following are the subtask configurations for the stack task. | ||
subtask_configs = [] | ||
subtask_configs.append( | ||
SubTaskConfig( | ||
# Each subtask involves manipulation with respect to a single object frame. | ||
object_ref="cube_2", | ||
# This key corresponds to the binary indicator in "datagen_info" that signals | ||
# when this subtask is finished (e.g., on a 0 to 1 edge). | ||
subtask_term_signal="grasp_1", | ||
# Specifies time offsets for data generation when splitting a trajectory into | ||
# subtask segments. Random offsets are added to the termination boundary. | ||
subtask_term_offset_range=(10, 20), | ||
# Selection strategy for the source subtask segment during data generation | ||
selection_strategy="nearest_neighbor_object", | ||
# Optional parameters for the selection strategy function | ||
selection_strategy_kwargs={"nn_k": 3}, | ||
# Amount of action noise to apply during this subtask | ||
action_noise=0.03, | ||
# Number of interpolation steps to bridge to this subtask segment | ||
num_interpolation_steps=5, | ||
# Additional fixed steps for the robot to reach the necessary pose | ||
num_fixed_steps=0, | ||
# If True, apply action noise during the interpolation phase and execution | ||
apply_noise_during_interpolation=False, | ||
) | ||
) | ||
subtask_configs.append( | ||
SubTaskConfig( | ||
# Each subtask involves manipulation with respect to a single object frame. | ||
object_ref="cube_1", | ||
# Corresponding key for the binary indicator in "datagen_info" for completion | ||
subtask_term_signal="stack_1", | ||
# Time offsets for data generation when splitting a trajectory | ||
subtask_term_offset_range=(10, 20), | ||
# Selection strategy for source subtask segment | ||
selection_strategy="nearest_neighbor_object", | ||
# Optional parameters for the selection strategy function | ||
selection_strategy_kwargs={"nn_k": 3}, | ||
# Amount of action noise to apply during this subtask | ||
action_noise=0.03, | ||
# Number of interpolation steps to bridge to this subtask segment | ||
num_interpolation_steps=5, | ||
# Additional fixed steps for the robot to reach the necessary pose | ||
num_fixed_steps=0, | ||
# If True, apply action noise during the interpolation phase and execution | ||
apply_noise_during_interpolation=False, | ||
) | ||
) | ||
subtask_configs.append( | ||
SubTaskConfig( | ||
# Each subtask involves manipulation with respect to a single object frame. | ||
object_ref="cube_3", | ||
# Corresponding key for the binary indicator in "datagen_info" for completion | ||
subtask_term_signal="grasp_2", | ||
# Time offsets for data generation when splitting a trajectory | ||
subtask_term_offset_range=(10, 20), | ||
# Selection strategy for source subtask segment | ||
selection_strategy="nearest_neighbor_object", | ||
# Optional parameters for the selection strategy function | ||
selection_strategy_kwargs={"nn_k": 3}, | ||
# Amount of action noise to apply during this subtask | ||
action_noise=0.03, | ||
# Number of interpolation steps to bridge to this subtask segment | ||
num_interpolation_steps=5, | ||
# Additional fixed steps for the robot to reach the necessary pose | ||
num_fixed_steps=0, | ||
# If True, apply action noise during the interpolation phase and execution | ||
apply_noise_during_interpolation=False, | ||
) | ||
) | ||
subtask_configs.append( | ||
SubTaskConfig( | ||
# Each subtask involves manipulation with respect to a single object frame. | ||
object_ref="cube_2", | ||
# End of final subtask does not need to be detected | ||
subtask_term_signal=None, | ||
# No time offsets for the final subtask | ||
subtask_term_offset_range=(0, 0), | ||
# Selection strategy for source subtask segment | ||
selection_strategy="nearest_neighbor_object", | ||
# Optional parameters for the selection strategy function | ||
selection_strategy_kwargs={"nn_k": 3}, | ||
# Amount of action noise to apply during this subtask | ||
action_noise=0.03, | ||
# Number of interpolation steps to bridge to this subtask segment | ||
num_interpolation_steps=5, | ||
# Additional fixed steps for the robot to reach the necessary pose | ||
num_fixed_steps=0, | ||
# If True, apply action noise during the interpolation phase and execution | ||
apply_noise_during_interpolation=False, | ||
) | ||
) | ||
self.subtask_configs["franka"] = subtask_configs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's include these in the docstring as well