UPDATE: new ckpt
Browse files
bb_collect.py
CHANGED
|
@@ -295,7 +295,7 @@ class PingPongEnv:
|
|
| 295 |
obs = obs[:18] #
|
| 296 |
obs[0:3] = obs[0:3] - obs[6:9] # board center
|
| 297 |
obs[3:6] = obs[3:6] - obs[12:15] # board center
|
| 298 |
-
obs = obs[
|
| 299 |
|
| 300 |
|
| 301 |
# Done condition: ball(x,y) out of [100,100] or z lower than board - 0.1m
|
|
|
|
| 295 |
obs = obs[:18] #
|
| 296 |
obs[0:3] = obs[0:3] - obs[6:9] # board center
|
| 297 |
obs[3:6] = obs[3:6] - obs[12:15] # board center
|
| 298 |
+
obs = obs[[0,1,2,3,4,5,9,10,11]]
|
| 299 |
|
| 300 |
|
| 301 |
# Done condition: ball(x,y) out of [100,100] or z lower than board - 0.1m
|
logs/run-20250921_185254-bj8djt57/checkpoint_step_214000_20250922_004234.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:963ac1e8401512a982e6b1ef8307e05e29f723ebf84a1f4a6f5dbe9b1e037325
|
| 3 |
+
size 1862585
|
logs/run-20250921_185254-bj8djt57/config.yaml
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_wandb:
|
| 2 |
+
value:
|
| 3 |
+
cli_version: 0.21.0
|
| 4 |
+
e:
|
| 5 |
+
cktml8c757zvaai93h400eufkxhuf5xi:
|
| 6 |
+
args:
|
| 7 |
+
- --config
|
| 8 |
+
- ICLR/config/bb6_reduced/bb6_switching_dim.yaml
|
| 9 |
+
- --gpu_id
|
| 10 |
+
- "2"
|
| 11 |
+
codePath: main_cheetah.py
|
| 12 |
+
codePathLocal: main_cheetah.py
|
| 13 |
+
cpu_count: 128
|
| 14 |
+
cpu_count_logical: 255
|
| 15 |
+
cudaVersion: "12.6"
|
| 16 |
+
disk:
|
| 17 |
+
/:
|
| 18 |
+
total: "6598647398400"
|
| 19 |
+
used: "2417479077888"
|
| 20 |
+
email: sangliteng@gmail.com
|
| 21 |
+
executable: /home/sangliteng/miniconda3/envs/learning-hybrid-systems/bin/python3
|
| 22 |
+
git:
|
| 23 |
+
commit: e65e9632c7a9d9bc1847e0a5a83e8e29db0ac56e
|
| 24 |
+
remote: git@github.com:SangliTeng/Leaning-Hybrid-Systems.git
|
| 25 |
+
gpu: NVIDIA RTX 6000 Ada Generation
|
| 26 |
+
gpu_count: 8
|
| 27 |
+
gpu_nvidia:
|
| 28 |
+
- architecture: Ada
|
| 29 |
+
cudaCores: 18176
|
| 30 |
+
memoryTotal: "51527024640"
|
| 31 |
+
name: NVIDIA RTX 6000 Ada Generation
|
| 32 |
+
uuid: GPU-45d30378-435b-de16-3aea-9fc48527fe61
|
| 33 |
+
- architecture: Ada
|
| 34 |
+
cudaCores: 18176
|
| 35 |
+
memoryTotal: "51527024640"
|
| 36 |
+
name: NVIDIA RTX 6000 Ada Generation
|
| 37 |
+
uuid: GPU-19a03a90-a9e0-a194-8d43-c2dcb7925140
|
| 38 |
+
- architecture: Ada
|
| 39 |
+
cudaCores: 18176
|
| 40 |
+
memoryTotal: "51527024640"
|
| 41 |
+
name: NVIDIA RTX 6000 Ada Generation
|
| 42 |
+
uuid: GPU-ea5b1c7d-baf5-6bcb-1ce1-0ee9ca4b5c8f
|
| 43 |
+
- architecture: Ada
|
| 44 |
+
cudaCores: 18176
|
| 45 |
+
memoryTotal: "51527024640"
|
| 46 |
+
name: NVIDIA RTX 6000 Ada Generation
|
| 47 |
+
uuid: GPU-b1a2e98c-e563-a0fe-47ce-cfa29028d5c7
|
| 48 |
+
- architecture: Ada
|
| 49 |
+
cudaCores: 18176
|
| 50 |
+
memoryTotal: "51527024640"
|
| 51 |
+
name: NVIDIA RTX 6000 Ada Generation
|
| 52 |
+
uuid: GPU-208eeaba-0174-d4e0-bc7a-2eb5f7983a6e
|
| 53 |
+
- architecture: Ada
|
| 54 |
+
cudaCores: 18176
|
| 55 |
+
memoryTotal: "51527024640"
|
| 56 |
+
name: NVIDIA RTX 6000 Ada Generation
|
| 57 |
+
uuid: GPU-81a0e787-8873-418d-6ff3-e3f59deb75a0
|
| 58 |
+
- architecture: Ada
|
| 59 |
+
cudaCores: 18176
|
| 60 |
+
memoryTotal: "51527024640"
|
| 61 |
+
name: NVIDIA RTX 6000 Ada Generation
|
| 62 |
+
uuid: GPU-8619099e-16b4-d667-b97f-518c3954df8c
|
| 63 |
+
- architecture: Ada
|
| 64 |
+
cudaCores: 18176
|
| 65 |
+
memoryTotal: "51527024640"
|
| 66 |
+
name: NVIDIA RTX 6000 Ada Generation
|
| 67 |
+
uuid: GPU-8042fac2-fd28-c8e9-668b-ceb33605fb49
|
| 68 |
+
host: hr-6000ada
|
| 69 |
+
memory:
|
| 70 |
+
total: "811164614656"
|
| 71 |
+
os: Linux-5.15.0-143-generic-x86_64-with-glibc2.35
|
| 72 |
+
program: /home/sangliteng/Research/Leaning-Hybrid-Systems/main_cheetah.py
|
| 73 |
+
python: CPython 3.12.11
|
| 74 |
+
root: ./ICLR/bb6_reduced
|
| 75 |
+
startedAt: "2025-09-21T18:52:54.190585Z"
|
| 76 |
+
writerId: cktml8c757zvaai93h400eufkxhuf5xi
|
| 77 |
+
m: []
|
| 78 |
+
python_version: 3.12.11
|
| 79 |
+
t:
|
| 80 |
+
"1":
|
| 81 |
+
- 1
|
| 82 |
+
"2":
|
| 83 |
+
- 1
|
| 84 |
+
"3":
|
| 85 |
+
- 2
|
| 86 |
+
- 13
|
| 87 |
+
- 15
|
| 88 |
+
- 16
|
| 89 |
+
"4": 3.12.11
|
| 90 |
+
"5": 0.21.0
|
| 91 |
+
"12": 0.21.0
|
| 92 |
+
"13": linux-x86_64
|
| 93 |
+
anti_collapse_weight:
|
| 94 |
+
value: 1000
|
| 95 |
+
batch_size:
|
| 96 |
+
value: 2048
|
| 97 |
+
data_path_test:
|
| 98 |
+
value: None
|
| 99 |
+
data_path_train:
|
| 100 |
+
value: /home/sangliteng/Research/DynaTraj/dataset/bb/bb_ball_reduced_v2_not_normalized.npz
|
| 101 |
+
decoder_batch_size:
|
| 102 |
+
value: 131072
|
| 103 |
+
decoder_finetune_steps:
|
| 104 |
+
value: 200000
|
| 105 |
+
decoder_lr:
|
| 106 |
+
value: 0.001
|
| 107 |
+
default_activation:
|
| 108 |
+
value: ReLU
|
| 109 |
+
dim_linear_in_decoder:
|
| 110 |
+
value:
|
| 111 |
+
- 0
|
| 112 |
+
- 0
|
| 113 |
+
dim_linear_in_encoder:
|
| 114 |
+
value:
|
| 115 |
+
- 0
|
| 116 |
+
- 0
|
| 117 |
+
dim_linear_in_vec_field:
|
| 118 |
+
value:
|
| 119 |
+
- 0
|
| 120 |
+
- 0
|
| 121 |
+
dim_linear_out_decoder:
|
| 122 |
+
value: 0
|
| 123 |
+
dim_linear_out_encoder:
|
| 124 |
+
value: 0
|
| 125 |
+
dim_linear_out_vec_field:
|
| 126 |
+
value: 0
|
| 127 |
+
dynamics_init_scale:
|
| 128 |
+
value: 0.005
|
| 129 |
+
dynamics_loss_type:
|
| 130 |
+
value: l2
|
| 131 |
+
dynamics_weight:
|
| 132 |
+
value: 10
|
| 133 |
+
encoder_lr:
|
| 134 |
+
value: 0.001
|
| 135 |
+
eval_batch_size:
|
| 136 |
+
value: 64
|
| 137 |
+
eval_every:
|
| 138 |
+
value: 2.5e+22
|
| 139 |
+
eval_trajectory_length:
|
| 140 |
+
value: 500
|
| 141 |
+
except_features:
|
| 142 |
+
value: []
|
| 143 |
+
external_input_dim:
|
| 144 |
+
value: 6
|
| 145 |
+
hidden_dim_linear_decoder:
|
| 146 |
+
value: []
|
| 147 |
+
hidden_dim_linear_encoder:
|
| 148 |
+
value: []
|
| 149 |
+
hidden_dim_linear_vec_field:
|
| 150 |
+
value: []
|
| 151 |
+
hidden_dims_dec:
|
| 152 |
+
value:
|
| 153 |
+
- 128
|
| 154 |
+
- 128
|
| 155 |
+
- 128
|
| 156 |
+
- 128
|
| 157 |
+
- 128
|
| 158 |
+
- 128
|
| 159 |
+
- 128
|
| 160 |
+
- 128
|
| 161 |
+
hidden_dims_enc:
|
| 162 |
+
value:
|
| 163 |
+
- 64
|
| 164 |
+
- 64
|
| 165 |
+
- 64
|
| 166 |
+
hidden_dims_vector_field:
|
| 167 |
+
value:
|
| 168 |
+
- 128
|
| 169 |
+
- 128
|
| 170 |
+
input_dim:
|
| 171 |
+
value: 9
|
| 172 |
+
is_lagrangian_system:
|
| 173 |
+
value: true
|
| 174 |
+
isometry_loss_weight:
|
| 175 |
+
value: 1
|
| 176 |
+
latent_dim:
|
| 177 |
+
value: 18
|
| 178 |
+
learning_rate:
|
| 179 |
+
value: 0.0005
|
| 180 |
+
log_interval:
|
| 181 |
+
value: 50
|
| 182 |
+
loss_mode:
|
| 183 |
+
value: z
|
| 184 |
+
max_iso_samples:
|
| 185 |
+
value: 16384
|
| 186 |
+
min_covariance_threshold:
|
| 187 |
+
value: 0.09
|
| 188 |
+
model_type:
|
| 189 |
+
value: hybrid
|
| 190 |
+
normalize_data:
|
| 191 |
+
value: false
|
| 192 |
+
ode_method:
|
| 193 |
+
value: rk4
|
| 194 |
+
project_name:
|
| 195 |
+
value: debug architecture
|
| 196 |
+
reconstruction_loss_type:
|
| 197 |
+
value: l2
|
| 198 |
+
run_name:
|
| 199 |
+
value: bb reduced - dim 9 unnormalized
|
| 200 |
+
save_checkpoint_every:
|
| 201 |
+
value: 250
|
| 202 |
+
smooth_budget:
|
| 203 |
+
value: 0.0001
|
| 204 |
+
smooth_weight:
|
| 205 |
+
value: 0
|
| 206 |
+
steps_per_length:
|
| 207 |
+
value: 2000
|
| 208 |
+
switching_dim:
|
| 209 |
+
value:
|
| 210 |
+
- 0
|
| 211 |
+
- 1
|
| 212 |
+
- 2
|
| 213 |
+
- 3
|
| 214 |
+
- 4
|
| 215 |
+
- 5
|
| 216 |
+
switching_threshold_scale:
|
| 217 |
+
value: 1.5
|
| 218 |
+
switching_weight_multiplier:
|
| 219 |
+
value: 2
|
| 220 |
+
test_info:
|
| 221 |
+
value: same profile as bb, much larger network, no isometry loss
|
| 222 |
+
time_step:
|
| 223 |
+
value: 0.01
|
| 224 |
+
train_test_ratio:
|
| 225 |
+
value: 0.95
|
| 226 |
+
trajectory_lengths:
|
| 227 |
+
value:
|
| 228 |
+
- 10
|
| 229 |
+
- 20
|
| 230 |
+
- 40
|
| 231 |
+
- 80
|
| 232 |
+
- 150
|
| 233 |
+
- 200
|
| 234 |
+
- 200
|
| 235 |
+
use_switching_weights:
|
| 236 |
+
value: true
|
| 237 |
+
use_weight_smoothing:
|
| 238 |
+
value: false
|
| 239 |
+
vector_field_lr:
|
| 240 |
+
value: 0.001
|
| 241 |
+
viz_interval:
|
| 242 |
+
value: 50
|
| 243 |
+
wandb_base_dir:
|
| 244 |
+
value: ./ICLR/bb6_reduced
|
| 245 |
+
weight_smoothing_window:
|
| 246 |
+
value: 0
|
| 247 |
+
z_continuity_weight:
|
| 248 |
+
value: 10
|
mppi/task/bb_track.py
CHANGED
|
@@ -26,66 +26,6 @@ from mppi.mppi.mppi import MPPIController
|
|
| 26 |
from models import create_model, interpolate_trajectory
|
| 27 |
|
| 28 |
|
| 29 |
-
def obs_normalize(obs):
|
| 30 |
-
"""Normalize observations for network input"""
|
| 31 |
-
obs_mean = np.array([4.1115395e-06, 7.5212418e-05, 5.6337732e-01, -1.3034559e-04,
|
| 32 |
-
-6.7626464e-04, -9.7243134e-03, -1.0762236e-03, 8.8590048e-02,
|
| 33 |
-
5.4583937e-01, -5.2461156e-04, -1.1820005e-04, 4.9850909e-04])
|
| 34 |
-
obs_std = np.array([0.008502, 0.00853375, 0.6281913, 0.36238843, 0.36033645, 2.388929,
|
| 35 |
-
2.4867563, 2.5405889, 0.08288698, 0.05330177, 0.05352837, 0.05296409])
|
| 36 |
-
|
| 37 |
-
# Handle both numpy arrays and torch tensors
|
| 38 |
-
if isinstance(obs, torch.Tensor):
|
| 39 |
-
obs_mean = torch.tensor(obs_mean, device=obs.device, dtype=obs.dtype)
|
| 40 |
-
obs_std = torch.tensor(obs_std, device=obs.device, dtype=obs.dtype)
|
| 41 |
-
|
| 42 |
-
obs_normalized = (obs - obs_mean) / obs_std
|
| 43 |
-
return obs_normalized
|
| 44 |
-
|
| 45 |
-
def obs_denormalize(obs):
|
| 46 |
-
"""Denormalize observations from network output"""
|
| 47 |
-
obs_mean = np.array([4.1115395e-06, 7.5212418e-05, 5.6337732e-01, -1.3034559e-04,
|
| 48 |
-
-6.7626464e-04, -9.7243134e-03, -1.0762236e-03, 8.8590048e-02,
|
| 49 |
-
5.4583937e-01, -5.2461156e-04, -1.1820005e-04, 4.9850909e-04])
|
| 50 |
-
obs_std = np.array([0.008502, 0.00853375, 0.6281913, 0.36238843, 0.36033645, 2.388929,
|
| 51 |
-
2.4867563, 2.5405889, 0.08288698, 0.05330177, 0.05352837, 0.05296409])
|
| 52 |
-
|
| 53 |
-
# Handle both numpy arrays and torch tensors
|
| 54 |
-
if isinstance(obs, torch.Tensor):
|
| 55 |
-
obs_mean = torch.tensor(obs_mean, device=obs.device, dtype=obs.dtype)
|
| 56 |
-
obs_std = torch.tensor(obs_std, device=obs.device, dtype=obs.dtype)
|
| 57 |
-
|
| 58 |
-
obs_denormalized = obs * obs_std + obs_mean
|
| 59 |
-
return obs_denormalized
|
| 60 |
-
|
| 61 |
-
def action_normalize(action):
|
| 62 |
-
"""Normalize actions for network processing"""
|
| 63 |
-
action_mean = np.array([1.8646908e-03, 3.1277258e-02, 3.7151906e-01, 3.1675972e-04,
|
| 64 |
-
-1.5510405e-04, -7.3288589e-05])
|
| 65 |
-
action_std = np.array([1.2320997, 1.2293005, 3.7507675, 0.33227754, 0.33331886, 0.33228952])
|
| 66 |
-
|
| 67 |
-
# Handle both numpy arrays and torch tensors
|
| 68 |
-
if isinstance(action, torch.Tensor):
|
| 69 |
-
action_mean = torch.tensor(action_mean, device=action.device, dtype=action.dtype)
|
| 70 |
-
action_std = torch.tensor(action_std, device=action.device, dtype=action.dtype)
|
| 71 |
-
|
| 72 |
-
action_normalized = (action - action_mean) / action_std
|
| 73 |
-
return action_normalized
|
| 74 |
-
|
| 75 |
-
def action_denormalize(action):
|
| 76 |
-
"""Denormalize actions from network output"""
|
| 77 |
-
action_mean = np.array([1.8646908e-03, 3.1277258e-02, 3.7151906e-01, 3.1675972e-04,
|
| 78 |
-
-1.5510405e-04, -7.3288589e-05])
|
| 79 |
-
action_std = np.array([1.2320997, 1.2293005, 3.7507675, 0.33227754, 0.33331886, 0.33228952])
|
| 80 |
-
|
| 81 |
-
# Handle both numpy arrays and torch tensors
|
| 82 |
-
if isinstance(action, torch.Tensor):
|
| 83 |
-
action_mean = torch.tensor(action_mean, device=action.device, dtype=action.dtype)
|
| 84 |
-
action_std = torch.tensor(action_std, device=action.device, dtype=action.dtype)
|
| 85 |
-
|
| 86 |
-
action_denormalized = action * action_std + action_mean
|
| 87 |
-
return action_denormalized
|
| 88 |
-
|
| 89 |
class NeuralHybridDynamics:
|
| 90 |
def __init__(self, weights_dir: str, dt, horizon, device: str = "cpu"):
|
| 91 |
self.weights_dir = weights_dir
|
|
@@ -213,8 +153,6 @@ class NeuralHybridDynamics:
|
|
| 213 |
assert state0.ndim == 3 and state0.size(1) == 1, f"Expected x0 [B,1,Dx], got {tuple(state0.shape)}"
|
| 214 |
assert action.ndim == 3 and action.size(1) == self.horizon, f"u time dim {action.size(1)} != horizon {self.horizon}"
|
| 215 |
|
| 216 |
-
state0 = obs_normalize(state0)
|
| 217 |
-
action = action_normalize(action)
|
| 218 |
|
| 219 |
|
| 220 |
B, _, Dx = state0.shape
|
|
@@ -242,16 +180,15 @@ class NeuralHybridDynamics:
|
|
| 242 |
|
| 243 |
# Interpolate from t_eval to our target sampling times
|
| 244 |
x_pred = interpolate_trajectory(t_eval, t_batch - t_batch[:, :1], x_traj) # [B, H, Dx]
|
| 245 |
-
x_pred = obs_denormalize(x_pred)
|
| 246 |
return x_pred
|
| 247 |
|
| 248 |
class BBTrack:
|
| 249 |
def __init__(self):
|
| 250 |
self.parser = self.parse_bb_track_args()
|
| 251 |
self.control_dt = 1/50 # 50Hz
|
| 252 |
-
self.horizon =
|
| 253 |
self.iterations = 20
|
| 254 |
-
self.state_dims =
|
| 255 |
self.num_samples = 100
|
| 256 |
self.num_elites = 10
|
| 257 |
self.device = "cuda:0"
|
|
@@ -294,7 +231,7 @@ class BBTrack:
|
|
| 294 |
parser.add_argument("--realtime", action="store_true", help="Match simulation speed to real time")
|
| 295 |
parser.add_argument("--seed", type=int, default=42, help="Random seed")
|
| 296 |
parser.add_argument("--headless", action="store_true", help="Run in headless mode (no rendering)")
|
| 297 |
-
parser.add_argument("--weights_dir", type=str, default="/home/lau/sim/DynaTraj/logs/run-
|
| 298 |
|
| 299 |
return parser.parse_args()
|
| 300 |
|
|
|
|
| 26 |
from models import create_model, interpolate_trajectory
|
| 27 |
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
class NeuralHybridDynamics:
|
| 30 |
def __init__(self, weights_dir: str, dt, horizon, device: str = "cpu"):
|
| 31 |
self.weights_dir = weights_dir
|
|
|
|
| 153 |
assert state0.ndim == 3 and state0.size(1) == 1, f"Expected x0 [B,1,Dx], got {tuple(state0.shape)}"
|
| 154 |
assert action.ndim == 3 and action.size(1) == self.horizon, f"u time dim {action.size(1)} != horizon {self.horizon}"
|
| 155 |
|
|
|
|
|
|
|
| 156 |
|
| 157 |
|
| 158 |
B, _, Dx = state0.shape
|
|
|
|
| 180 |
|
| 181 |
# Interpolate from t_eval to our target sampling times
|
| 182 |
x_pred = interpolate_trajectory(t_eval, t_batch - t_batch[:, :1], x_traj) # [B, H, Dx]
|
|
|
|
| 183 |
return x_pred
|
| 184 |
|
| 185 |
class BBTrack:
|
| 186 |
def __init__(self):
|
| 187 |
self.parser = self.parse_bb_track_args()
|
| 188 |
self.control_dt = 1/50 # 50Hz
|
| 189 |
+
self.horizon = 20
|
| 190 |
self.iterations = 20
|
| 191 |
+
self.state_dims = 9
|
| 192 |
self.num_samples = 100
|
| 193 |
self.num_elites = 10
|
| 194 |
self.device = "cuda:0"
|
|
|
|
| 231 |
parser.add_argument("--realtime", action="store_true", help="Match simulation speed to real time")
|
| 232 |
parser.add_argument("--seed", type=int, default=42, help="Random seed")
|
| 233 |
parser.add_argument("--headless", action="store_true", help="Run in headless mode (no rendering)")
|
| 234 |
+
parser.add_argument("--weights_dir", type=str, default="/home/lau/sim/DynaTraj/logs/run-20250921_185254-bj8djt57", help="absolute path to the weights directory")
|
| 235 |
|
| 236 |
return parser.parse_args()
|
| 237 |
|