"""ROM evaluation conditions: nominal ROM and test-randomization (TR) variants. Sim2Sim only. Each variant = per-episode parameter distributions + number of trials K per goal. Distributions: ('const', v), ('normal', mu, sd), ('uniform', lo, hi), ('loguniform', lo, hi), ('choice', [values]). Parameters (see rom_batch.DEFAULTS): tau0, omega0, sig_thr, sig_steer, delay, steer_rate, hold, wheelbase, vmax, x0, y0, yaw0, v0, gx_scale, g_rot, obs_pos_sig. Every exploration variant tried on goal set A is listed here and in results/exploration_report.md. Condition names also seed the random streams (run_rom.seed_of), so they are kept unchanged; 'paper_tr' is the noise-only TR (action and powertrain noise). """ import numpy as np PI = float(np.pi) REL = dict(tau0=('normal', 1000.0, 50.0), omega0=('normal', 2600.0, 100.0), sig_thr=('const', 0.05), sig_steer=('const', 0.05)) # noise-only TR (noise of the release training script) def scaled_release(c): return dict(tau0=('normal', 1000.0, 50.0 * c), omega0=('normal', 2600.0, 100.0 * c), sig_thr=('const', 0.05 * c), sig_steer=('const', 0.05 * c)) def agnostic(c): return dict(wheelbase=('loguniform', 1.0 / c, 1.0 * c), tau0=('loguniform', 1000.0 / c, 1000.0 * c), omega0=('loguniform', 2600.0 / c, 2600.0 * c), vmax=('loguniform', 5.0 / c, 5.0 * c), sig_thr=('const', 0.05), sig_steer=('const', 0.05)) EXPLORE = { # baseline 'nominal': (1, {}), # family 1: noise-only TR and scaled versions 'paper_tr': (20, REL), 'paper_tr_x2': (20, scaled_release(2)), 'paper_tr_x4': (20, scaled_release(4)), # family 2: action noise only 'act_0.1': (20, dict(sig_thr=('const', 0.1), sig_steer=('const', 0.1))), 'act_0.2': (20, dict(sig_thr=('const', 0.2), sig_steer=('const', 0.2))), 'act_0.3': (20, dict(sig_thr=('const', 0.3), sig_steer=('const', 0.3))), # family 3: actuation delay (0.1 s steps) 'delay_1': (1, dict(delay=('const', 1))), 'delay_2': (1, dict(delay=('const', 2))), 'delay_3': (1, dict(delay=('const', 3))), 'delay_rand03': (20, dict(delay=('choice', [0, 1, 2, 3]))), # family 4: steering-rate limit and start hold (deployment-loop details, deterministic) 'rate_0.1': (1, dict(steer_rate=('const', 0.1))), 'rate_rand': (20, dict(steer_rate=('loguniform', 0.05, 0.5))), 'hold_1s': (1, dict(hold=('const', 10))), 'loop_rate_hold': (1, dict(steer_rate=('const', 0.1), hold=('const', 10))), # family 5: powertrain parameters (broad) and speed cap 'tau0_logu': (20, dict(tau0=('loguniform', 100.0, 1000.0))), 'vmax_u': (20, dict(vmax=('uniform', 5.0, 15.0))), 'powertrain_speed': (20, dict(tau0=('loguniform', 100.0, 1000.0), vmax=('uniform', 5.0, 15.0))), # family 6: steering authority (ROM wheelbase) 'wb_2': (1, dict(wheelbase=('const', 2.0))), 'wb_3.4': (1, dict(wheelbase=('const', 3.378))), 'wb_u1_4': (20, dict(wheelbase=('uniform', 1.0, 4.0))), 'wb_logu1_8': (20, dict(wheelbase=('loguniform', 1.0, 8.0))), # family 7: initial pose and goal shift 'pose_release': (20, dict(x0=('uniform', -1.0, 1.0), y0=('uniform', -1.0, 1.0), yaw0=('uniform', -PI, PI))), 'yaw_45': (20, dict(yaw0=('uniform', -PI / 4, PI / 4))), 'goal_far': (20, dict(gx_scale=('uniform', 1.0, 2.0))), 'goal_rot': (20, dict(g_rot=('uniform', -PI / 6, PI / 6))), # family 8: observation noise 'obs_0.5': (20, dict(obs_pos_sig=('const', 0.5))), # family 9: agnostic parameter TR. Every ROM model parameter x LogUniform(1/c, c) around its nominal value, # plus the action noise of the noise-only TR. No direction of model error is assumed. 'agn_c2': (20, agnostic(2.0)), 'agn_c4': (20, agnostic(4.0)), 'agn_c8': (20, agnostic(8.0)), 'agn_c4_loop': (20, {**agnostic(4.0), 'steer_rate': ('const', 0.1), 'hold': ('const', 10)}), 'agn_c8_loop': (20, {**agnostic(8.0), 'steer_rate': ('const', 0.1), 'hold': ('const', 10)}), # family 10: deterministic "calibrated" ROM baselines (not TR): HMMWV wheelbase and/or the deployment loop 'calib_wb_loop': (1, dict(wheelbase=('const', 3.378), steer_rate=('const', 0.1), hold=('const', 10))), # family 11 (added after a first analysis of the set-A results): actuator TR = random steering-rate limit and # random delay, alone and with the noise-only TR 'act_rate_delay': (20, dict(steer_rate=('loguniform', 0.05, 0.5), delay=('choice', [0, 1, 2, 3]))), 'act_rate_delay_paper': (20, {**REL, 'steer_rate': ('loguniform', 0.05, 0.5), 'delay': ('choice', [0, 1, 2, 3])}), 'rate_rand_paper': (20, {**REL, 'steer_rate': ('loguniform', 0.05, 0.5)}), } def sample(spec, n, rng): """spec: dict param -> distribution. Returns dict param -> (n,) array.""" out = {} for k, d in spec.items(): kind = d[0] if kind == 'const': out[k] = np.full(n, float(d[1])) elif kind == 'normal': out[k] = rng.normal(d[1], d[2], n) elif kind == 'uniform': out[k] = rng.uniform(d[1], d[2], n) elif kind == 'loguniform': out[k] = np.exp(rng.uniform(np.log(d[1]), np.log(d[2]), n)) elif kind == 'choice': out[k] = rng.choice(np.asarray(d[1], dtype=np.float64), n) else: raise ValueError(kind) return out