Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/find_best_checkpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def main():
"""Main function to process all model directories."""
# Define paths - handle both host and Docker container paths
script_dir = Path(__file__).parent.resolve()
base_dir = script_dir / "insert/Dev-IK-Rel-Insert-v0"
base_dir = script_dir / "/workspace/isaaclab/robomimic/Dev-IK-Rel-Insert-v0"

Copilot AI Feb 25, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard-coded absolute Docker path reduces portability. Consider using relative paths or making this configurable to work in different environments.

Suggested change
base_dir = script_dir / "/workspace/isaaclab/robomimic/Dev-IK-Rel-Insert-v0"
# Default to a directory relative to this script, but allow override via env var
default_base_dir = script_dir / "Dev-IK-Rel-Insert-v0"
base_dir = Path(os.environ.get("DEV_IK_REL_INSERT_BASE_DIR", default_base_dir))

Copilot uses AI. Check for mistakes.
output_dir = base_dir / "best_models"

# Create output directory (including parent directories if needed)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
{
"algo_name": "bc",
"experiment": {
"name": "vial_insert",
"validate": true,
"logging": {
"terminal_output_to_txt": true,
"log_tb": true,
"log_wandb": true,
"wandb_proj_name": "vial_insert"
},
"save": {
"enabled": true,
"every_n_seconds": null,
"every_n_epochs": null,
"epochs": [],
"on_best_validation": true,
"on_best_rollout_return": true,
"on_best_rollout_success_rate": true
},
"epoch_every_n_steps": 100,
"validation_epoch_every_n_steps": 10,
"env": "Dev-IK-Rel-Insert-v0",
"additional_envs": null,
"render": false,
"render_video": true,
"keep_all_videos": false,
"video_skip": 5,
"rollout": {
"enabled": false,
"n": 50,
"horizon": 400,
"rate": 50,
"warmstart": 0,
"terminate_on_success": true
},
"env_meta_update_dict": {},
"ckpt_path": null
},
"train": {
"data": [
{
"path": "docs/insert/glassware_lift_demos_generated_split.hdf5"
}
],
"output_dir": "/workspace/isaaclab/robomimic/Dev-IK-Rel-Insert-v0/model14/",
"normalize_weights_by_ds_size": false,
"num_data_workers": 4,
"hdf5_cache_mode": "low_dim",
"hdf5_use_swmr": true,
"hdf5_load_next_obs": false,
"hdf5_normalize_obs": false,
"hdf5_filter_key": "train",
"hdf5_validation_filter_key": "valid",
"seq_length": 16,
"pad_seq_length": true,
"frame_stack": 1,
"pad_frame_stack": true,
"dataset_keys": [
"actions",
"rewards",
"dones"
],
"action_keys": [
"actions"
],
"action_config": {
"actions": {
"normalization": null
}
},
"goal_mode": null,
"cuda": true,
"batch_size": 100,
"num_epochs": 1000,
"seed": 101,
"max_grad_norm": null
},
"algo": {
"optim_params": {
"policy": {
"optimizer_type": "adam",
"learning_rate": {
"initial": 0.0001,
"decay_factor": 0.01,
"epoch_schedule": [],
"scheduler_type": "multistep"
},
"regularization": {
"L2": 0.0
}
}
},
"loss": {
"l2_weight": 1.0,
"l1_weight": 0.0,
"cos_weight": 0.0
},
"actor_layer_dims": [
1024,
1024
],
"gaussian": {
"enabled": false,
"fixed_std": false,
"init_std": 0.1,
"min_std": 0.01,
"std_activation": "softplus",
"low_noise_eval": true
},
"gmm": {
"enabled": true,
"num_modes": 10,
"min_std": 0.0001,
"std_activation": "softplus",
"low_noise_eval": true
},
"vae": {
"enabled": false,
"latent_dim": 14,
"latent_clip": null,
"kl_weight": 1.0,
"decoder": {
"is_conditioned": true,
"reconstruction_sum_across_elements": false
},
"prior": {
"learn": false,
"is_conditioned": false,
"use_gmm": false,
"gmm_num_modes": 10,
"gmm_learn_weights": false,
"use_categorical": false,
"categorical_dim": 10,
"categorical_gumbel_softmax_hard": false,
"categorical_init_temp": 1.0,
"categorical_temp_anneal_step": 0.001,
"categorical_min_temp": 0.3
},
"encoder_layer_dims": [
300,
400
],
"decoder_layer_dims": [
300,
400
],
"prior_layer_dims": [
300,
400
]
},
"rnn": {
"enabled": true,
"horizon": 100,
"hidden_dim": 400,
"rnn_type": "LSTM",
"num_layers": 2,
"open_loop": false,
"kwargs": {
"bidirectional": false
}
},
"transformer": {
"enabled": false,
"context_length": 10,
"embed_dim": 512,
"num_layers": 6,
"num_heads": 8,
"emb_dropout": 0.1,
"attn_dropout": 0.1,
"block_output_dropout": 0.1,
"sinusoidal_embedding": false,
"activation": "gelu",
"supervise_all_steps": false,
"nn_parameter_for_timesteps": true,
"pred_future_acs": false
}
},
"observation": {
"modalities": {
"obs": {
"low_dim": [
"eef_pos",
"eef_quat",
"gripper_pos",
"object_position",
"target_object_position",
"joint_pos",
"joint_vel",
"actions"
],
"rgb": [],
"depth": [],
"scan": []
},
"goal": {
"low_dim": [],
"rgb": [],
"depth": [],
"scan": []
}
},
"encoder": {
"low_dim": {
"core_class": null,
"core_kwargs": {},
"obs_randomizer_class": null,
"obs_randomizer_kwargs": {}
},
"rgb": {
"core_class": "VisualCore",
"core_kwargs": {},
"obs_randomizer_class": null,
"obs_randomizer_kwargs": {}
},
"depth": {
"core_class": "VisualCore",
"core_kwargs": {},
"obs_randomizer_class": null,
"obs_randomizer_kwargs": {}
},
"scan": {
"core_class": "ScanCore",
"core_kwargs": {},
"obs_randomizer_class": null,
"obs_randomizer_kwargs": {}
}
}
},
"meta": {
"hp_base_config_file": null,
"hp_keys": [],
"hp_values": []
}
}
58 changes: 29 additions & 29 deletions docs/run_experiments.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,15 @@

## script to run experiments in the background

task="Dev-IK-Rel-v1"
horizon=500
task="Dev-IK-Rel-Insert-v0"
horizon=1000
num_rollouts=100
run_file="scripts/imitation_learning/robomimic/play_ensemble_v05.py"
exp_type="lift_none"
exp_type="insert_low_calib"

##### this now runs the experiments

# ## ensemble 15
# ensemble_size=15
# seed=101
# exp_name="${task}_ensemble_${ensemble_size}_seed_${seed}_${exp_type}"
# ./isaaclab.sh -p $run_file --task $task --horizon $horizon --num_rollouts $num_rollouts --ensemble_size $ensemble_size --seed $seed --exp_name $exp_name --headless

# seed=107
# exp_name="${task}_ensemble_${ensemble_size}_seed_${seed}_${exp_type}"
# ./isaaclab.sh -p $run_file --task $task --horizon $horizon --num_rollouts $num_rollouts --ensemble_size $ensemble_size --seed $seed --exp_name $exp_name --headless

# seed=115
# exp_name="${task}_ensemble_${ensemble_size}_seed_${seed}_${exp_type}"
# ./isaaclab.sh -p $run_file --task $task --horizon $horizon --num_rollouts $num_rollouts --ensemble_size $ensemble_size --seed $seed --exp_name $exp_name --headless

## ensemble 10
# # ## ensemble 15
ensemble_size=10
seed=101
exp_name="${task}_ensemble_${ensemble_size}_seed_${seed}_${exp_type}"
Expand All @@ -38,16 +24,30 @@ seed=115
exp_name="${task}_ensemble_${ensemble_size}_seed_${seed}_${exp_type}"
./isaaclab.sh -p $run_file --task $task --horizon $horizon --num_rollouts $num_rollouts --ensemble_size $ensemble_size --seed $seed --exp_name $exp_name --headless

## ensemble 5
ensemble_size=5
seed=101
exp_name="${task}_ensemble_${ensemble_size}_seed_${seed}_${exp_type}"
./isaaclab.sh -p $run_file --task $task --horizon $horizon --num_rollouts $num_rollouts --ensemble_size $ensemble_size --seed $seed --exp_name $exp_name --headless
# # ## ensemble 10
# ensemble_size=10
# seed=101
# exp_name="${task}_ensemble_${ensemble_size}_seed_${seed}_${exp_type}"
# ./isaaclab.sh -p $run_file --task $task --horizon $horizon --num_rollouts $num_rollouts --ensemble_size $ensemble_size --seed $seed --exp_name $exp_name --headless

seed=107
exp_name="${task}_ensemble_${ensemble_size}_seed_${seed}_${exp_type}"
./isaaclab.sh -p $run_file --task $task --horizon $horizon --num_rollouts $num_rollouts --ensemble_size $ensemble_size --seed $seed --exp_name $exp_name --headless
# seed=107
# exp_name="${task}_ensemble_${ensemble_size}_seed_${seed}_${exp_type}"
# ./isaaclab.sh -p $run_file --task $task --horizon $horizon --num_rollouts $num_rollouts --ensemble_size $ensemble_size --seed $seed --exp_name $exp_name --headless

seed=115
exp_name="${task}_ensemble_${ensemble_size}_seed_${seed}_${exp_type}"
./isaaclab.sh -p $run_file --task $task --horizon $horizon --num_rollouts $num_rollouts --ensemble_size $ensemble_size --seed $seed --exp_name $exp_name --headless
# seed=115
# exp_name="${task}_ensemble_${ensemble_size}_seed_${seed}_${exp_type}"
# ./isaaclab.sh -p $run_file --task $task --horizon $horizon --num_rollouts $num_rollouts --ensemble_size $ensemble_size --seed $seed --exp_name $exp_name --headless

# ## ensemble 5
# ensemble_size=5
# seed=101
# exp_name="${task}_ensemble_${ensemble_size}_seed_${seed}_${exp_type}"
# ./isaaclab.sh -p $run_file --task $task --horizon $horizon --num_rollouts $num_rollouts --ensemble_size $ensemble_size --seed $seed --exp_name $exp_name --headless

# seed=107
# exp_name="${task}_ensemble_${ensemble_size}_seed_${seed}_${exp_type}"
# ./isaaclab.sh -p $run_file --task $task --horizon $horizon --num_rollouts $num_rollouts --ensemble_size $ensemble_size --seed $seed --exp_name $exp_name --headless

# seed=115
# exp_name="${task}_ensemble_${ensemble_size}_seed_${seed}_${exp_type}"
# ./isaaclab.sh -p $run_file --task $task --horizon $horizon --num_rollouts $num_rollouts --ensemble_size $ensemble_size --seed $seed --exp_name $exp_name --headless
Comment on lines +27 to +53

Copilot AI Feb 25, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Large blocks of commented-out code reduce script readability. Consider removing these commented sections if they are no longer needed, or document why they are preserved for future reference.

Copilot uses AI. Check for mistakes.
25 changes: 20 additions & 5 deletions scripts/imitation_learning/robomimic/backup_controller_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from backup_controller import BackupControllerSM
from backup_controller_place import BackupControllerPlaceSM
from backup_controller_insert import BackupControllerInsertSM
from backup_controller_insert_top import BackupControllerInsertSM
Comment on lines 8 to +9

Copilot AI Feb 25, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import statement on line 9 conflicts with the import on line 8. Both are importing BackupControllerInsertSM but from different modules (backup_controller_insert and backup_controller_insert_top). This will cause the second import to override the first, leading to unexpected behavior. These should have different names or be conditionally imported.

Copilot uses AI. Check for mistakes.
import torch


Expand Down Expand Up @@ -41,7 +42,10 @@ def _get_controller(self):
print(f"[DEBUG] Using Place Backup Controller")
return BackupControllerPlaceSM(dt=0.01*2, num_envs=self.num_envs, position_threshold=0.02, device='cuda', offset = torch.tensor([[-0.1, 0, 0.1]], device='cuda:0'), goal_quat = self.object_goal_rot, goal_pos= self.object_goal_pos)
case "insert":
return BackupControllerInsertSM(0.01*2, self.num_envs,'cuda' , 0.02)
return BackupControllerInsertSM(dt=0.01*2, num_envs=self.num_envs, position_threshold=0.02, device='cuda', offset = torch.tensor([[-0.1, 0, 0.1]], device='cuda:0'), goal_quat = self.object_goal_rot, goal_pos= self.object_goal_pos)
case "insert_top":
### check this quat
return BackupControllerInsertSM(dt=0.01*2, num_envs=self.num_envs, position_threshold=0.02, device='cuda', offset = torch.tensor([[-0.1, 0, 0.1]], device='cuda:0'), goal_quat = self.object_goal_rot, goal_pos= self.object_goal_pos)
case _:
raise ValueError(f"Unknown task type {self.tasktype} for backup controller")

Expand All @@ -55,7 +59,9 @@ def _get_goal_pos(self):
goal_pos = self.env.unwrapped.scene["scale"].data.root_pose_w
# print(f"[DEBUG] Getting goal pos for place task {goal_pos}")
return self.env.unwrapped.scene["scale"].data.root_pose_w

case "insert_top":
# still vial rack
return self.env.unwrapped.scene["vialrack"].data.root_pose_w
case "insert":
return self.env.unwrapped.scene["vialrack"].data.root_pose_w

Expand All @@ -69,9 +75,12 @@ def _get_goal_rot(self):
goal_rot = self.env.unwrapped.command_manager.get_command("object_pose")
print(f"[DEBUG] Getting goal quat for place task {goal_rot}")
return self.env.unwrapped.command_manager.get_command("object_pose")

case "insert_top":
goal_rot = torch.tensor([[0,1,0,0]], device=self.device)#self.env.unwrapped.command_manager.get_command("object_pose")
return goal_rot #self.env.unwrapped.command_manager.get_command("object_pose")
case "insert":
return self.env.unwrapped.scene["vialrack"].data.root_pose_w
goal_rot = self.env.unwrapped.command_manager.get_command("object_pose")
return self.env.unwrapped.command_manager.get_command("object_pose")

def reset(self):
self.backup_controller.reset_idx()
Expand All @@ -89,9 +98,15 @@ def _get_rest_pos(self):
# lets change this into the 6 element tensor they are expecting
roll,pitch,yaw = euler_xyz_from_quat(ee_recovery_rot)
rest_pos = torch.cat([rest_pos, ee_recovery_rot], dim =-1)

#print(f"rpy version :{torch.cat([rest_pos,roll.unsqueeze(0), pitch.unsqueeze(0), yaw.unsqueeze(0)], dim =-1)}")
if self.tasktype == "insert_top":
rest_pos = torch.tensor([[ 0.6226, -0.0621, 0.3555]], device=self.device)
rest_rot = tensor([[ 0, 1, 0, 0]], device=self.device)

Copilot AI Feb 25, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing import statement for 'tensor'. The code uses 'tensor' on line 105 but it's not imported. This should be 'torch.tensor' to avoid a NameError.

Suggested change
rest_rot = tensor([[ 0, 1, 0, 0]], device=self.device)
rest_rot = torch.tensor([[ 0, 1, 0, 0]], device=self.device)

Copilot uses AI. Check for mistakes.
roll,pitch,yaw = euler_xyz_from_quat(rest_rot)
rest_pos = torch.cat([rest_pos,rest_rot], dim =-1)
print(f"Rest pos {rest_pos}")
print(f"rpy : {roll}, {pitch}, {yaw}")
#print(f"rpy version :{torch.cat([rest_pos,roll.unsqueeze(0), pitch.unsqueeze(0), yaw.unsqueeze(0)], dim =-1)}")
return rest_pos

def _setup_robot(self):
Expand Down
Loading
Loading