fix(oid): correct FIFO bias in karman_blk and collect_controlled

- collect_karman_blk.py: bias_arr[4]=front (was -4U0, should be 0),
  bias_arr[5]=bottom (was +4U0, should be -4U0),
  bias_arr[6]=top (was 0, should be +4U0).
  Matches legacy_karman_env.py:179-182.
- collect_controlled.py: same fix for Karman branch.
- Add missing import data_dir_for_scene in collect_controlled.py

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Frank14f 2026-06-30 15:55:15 +08:00
parent 8df40fb5bd
commit 5c55c5bdf7
2 changed files with 9 additions and 7 deletions

View File

@ -41,7 +41,7 @@ from OID_analysis.utils.cfd_interface import ( # noqa: E402
calc_lag, calc_dtw_sim, analyze_harmonics, gen_target_states_at,
)
from OID_analysis.configs import ( # noqa: E402
get_scene, get_scene_list, model_path_for_scene, LEGACY_CFG_DIR,
get_scene, get_scene_list, model_path_for_scene, data_dir_for_scene, LEGACY_CFG_DIR,
)
DATA_TYPE = np.float32
@ -117,12 +117,13 @@ def collect_single(scene_name: str, device_id: int, n_steps: int) -> dict:
"sens_deviation": sens_deviation.tolist(),
"sens_norm_fact": sens_norm_fact.tolist()}
# Preset-action FIFO (matches legacy env)
# Preset-action FIFO (matches legacy env: front=0, bottom=-4*U0, top=+4*U0)
ff.apply_ddf()
bias_arr = np.zeros(n_obj, dtype=DATA_TYPE)
if cfg["has_disturbance"]:
bias_arr[4] = -4.0 * u0
bias_arr[5] = 4.0 * u0
bias_arr[4] = 0.0 # front = 0
bias_arr[5] = -4.0 * u0 # bottom = -4*U0
bias_arr[6] = 4.0 * u0 # top = +4*U0
else:
bias_arr[4] = -1.0 * u0
bias_arr[5] = 1.0 * u0

View File

@ -91,11 +91,12 @@ def collect(device_id: int, n_steps: int) -> str:
}
print(f" norm: force_norm_fact={force_norm_fact:.6f}")
# Bias-action FIFO init (cloak: [0, -4*U0, 4*U0])
# Bias-action FIFO init (cloak: front=0, bottom=-4*U0, top=+4*U0)
ff.apply_ddf()
bias_arr = np.zeros(n_obj, dtype=DATA_TYPE)
bias_arr[4] = -4.0 * u0 # front=0, bottom=-4U0, top=4U0
bias_arr[5] = 4.0 * u0
bias_arr[4] = 0.0 # front = 0
bias_arr[5] = -4.0 * u0 # bottom = -4*U0
bias_arr[6] = 4.0 * u0 # top = +4*U0
fifo.clear()
for _ in range(FIFO_LEN):
ff.run(si, bias_arr)