TestRandomization / code /case1 /README_case1.md
harryzhang1018's picture
Add reproduction code and README
0c3dd1d verified
|
Raw History Blame Contribute Delete
14.5 kB

Case 1 (ART scale vehicle): reproduction package

This folder reproduces the Case 1 results of the paper: the recovery tests (test randomization, TR) of four controllers (MPC, NN-MPC, PID, NN-HD) in the Chrono digital twin of the 1/6-scale ART vehicle, and their comparison with 60 physical runs (Sim2Real).

Stage Folder What it does Needs the 20 GB logs?
0 runner/ Lock-step simulation runner and the batch (episode-list) generator runs only in the Docker image
1 extract/ Simulation logs -> one row of metrics per episode (data/per_start/) yes
2 physical/ Physical and nominal-simulation logs -> per-run MAE, Tables II-III no (14 MB, GitHub)
3 analysis/ Baseline orders; Tables I, IV, V, sensitivity, pair tests, Hoeffding no
4 mpc_failures/ MPC failures from large heading errors stage 4a only

data/ holds the small intermediate files, so stages 3 and 4b run in seconds without the raw logs. results/ holds the outputs that these commands produce.

Environment

  • Python 3.12.14 with numpy==2.5.2 and matplotlib==3.11.1 (requirements.txt; matplotlib only for the figure of stage 4). Stages 1-4 are plain scripts; all inputs and outputs are given as arguments.
  • The runner (stage 0) runs inside the Docker image uwsbel/ros:iros2024 (uwsbel/ros@sha256:60118a64d8e751c1adafef1abebebbc504a5814d63eae5bb46120de5f7b4554c, image Id sha256:73882e33184a5e9a586b5ce5167731ce0c569337104b273b05709a607730fa29; controller commit af8585558aab, Chrono fork commit 9d26ff7). The released batches were run with 12 workers on one AMD Ryzen 7 5800X host.
python3.12 -m venv .venv && .venv/bin/pip install -r requirements.txt
PY=.venv/bin/python        # all commands below are run from this folder (code/case1)

Inputs

  • Simulation logs: simulation_logs/case1_<batch>.tar.gz of this dataset (layout <batch>/episodes/<episode_id>/{episode_config.json, summary.json, ticks.csv.gz, state100.csv.gz, ...}). The paper uses B01, B03, B04, B05, B06 and B07. Unpack them so that the batch folders sit under logs/runs/: mkdir -p logs/runs && tar xzf case1_B01_main_tr.tar.gz -C logs/runs (and the same for the other five).
  • Physical runs and nominal-simulation logs: folder 2024/PathFollowingSim2real/TestingData of https://github.com/uwsbel/sbel-reproducibility (commit 1a098f37b6cdc69643bed9d9bf223ee2268e9fbc): rd_path (Path 1), syn_path (Path 2), lot17 (Path 3); five runs per controller and path, and one nominal simulation sim_<controller>.csv per path. The SHA256 of every physical log is in data/physical_runs.csv (log_sha256).
  • Reference waypoints of the Docker image (/sbel/Desktop/waypoints_paths): data/waypoints/.

Stage 0: runner and batch definitions (runner/)

Not runnable without the Docker image; the released logs are the output of this code.

  • src/art_lockstep.cpp: lock-step physics server. Vehicle and terrain setup are copied from the released demo_ROS_dART.cpp and linked against the Chrono libraries of the image. build.sh builds it inside the image (build/art_lockstep).
  • art_runner/: episode loop with the ros_emulated latency schedule (25 Hz state publication, 10 Hz controller and driver handlers, per-controller compute delay), bridge that runs the released controller code (path_follower.py, mpc_wpts.py, NN checkpoints) unchanged with stubbed rclpy executors, plug-ins (the NN-HD variants use plugin:wrapped_released with a steering scale), metrics and logging. Log columns: schemas/log_schema.md; config fields: schemas/episode_config.schema.json.
  • campaign.py + run_campaign.sh: batch driver (supervised worker pool, resume, provenance digest) and its network-isolated container launcher: bash runner/run_campaign.sh EPISODES.json OUTDIR 12.
  • default_config.json + default_episode.py: runner defaults and episode builders.
  • batches/generate_lists.py: builds the episode lists of B01, B03-B07 (seeds, scenario tables, CRN mapping; see its docstring). python3 runner/batches/generate_lists.py --out-root lists writes lists/<batch>/episodes.json, the scenario tables and generation_meta.json (about 2 s; numpy only). batches/steering_bias.json holds the steering-bias levels of D2a/D2b (0.013, 0.026).

Why the omitted modules of the original demo do not change the dynamics: the sensor manager (GPU camera, lidar), the ROS manager and its read-only handlers, the soft-real-time busy wait and the visual assets (waypoint boxes without collision) read the state but write no force or state; the only writer is the driver-inputs handler, which the runner reproduces. As a check, the original binary driven by an open-loop ROS publisher produced 263 pose messages that are bitwise identical to the server's states.

Batches used by the paper (episode counts as in the archives; V6 = MPC, NN-MPC, PID and NN-HD with ctrl_label nnhdx175, nnhdx150, nnhdx100; V5 = V6 without nnhdx100):

Batch Content Episodes
B01 S2 recovery tests, 400 starts x V6, logged 40 s, scored at H = 15/25/40 s 2,400
B03 Nominal simulation on Paths 1-3 x V6, controller phase {0, 20, 40, 60, 80} ms (phase 0 = nominal_role primary) 90
B04 Monte Carlo (RF-A): start jitter dx, dy in [-0.2, 0.2] m, dyaw in [-0.067, 0.067] rad, random phase; 20 runs per path x V5 300
B05 RF-B: B04 runs plus D5 (delay 0.10 s, steering bias 0.013, pose noise 0.02 m / 0.01 rad) 300
B06 Offset ranges S0, S1, S3, S4 (+ lateral-only, heading-only, Beta(3,3) shape), 200 starts each x V5, 25 s 9,000
B07 Channel conditions D1a-D5 on the first 200 S2 starts x V5, 25 s 9,000

The other archives (B02, B04w, B08-B13) are not used for the paper's results; their list generator is not included.

Note on default_config.json: the released episode configurations carry tags.default_config_sha256 = c63a5bab...f980, the hash of the original version of this file. The copy here has the same values for every field that the builders read and shorter descriptive text, so lists generated with it carry a different default_config_sha256. Any change to the runner files also changes the runner code digest in summary.json.

Stage 1: extract per-episode metrics (extract/extract_metrics.py)

for b in B01_main_tr B03_nominal B04_rf_a B05_rf_b B06_severity_shape B07_dist_recovery; do
  $PY extract/extract_metrics.py --out data/per_start --batch $b --workers 14 --run-label-root logs logs/runs/$b
done
$PY extract/extract_metrics.py --selftest
  • Inputs: unpacked batch folders; data/waypoints/ (default waypoint directory).
  • Outputs: data/per_start/<batch>/recovery_part*.csv.gz (B01, B06, B07) and fullpath_part*.csv.gz (B03-B05), one row per episode, plus MANIFEST.json and, if an episode cannot be read, errors_part*.jsonl. Column definitions are in the module docstring. The rank analysis uses T25_trk100_L010H010_first (bounded first entry into the 0.10 m / 0.10 rad tube, H = 25 s) and the other tube and horizon columns for the sensitivity; the baselines use mae_lat_m, mae_head_rad.
  • Runtime (14 workers): B01 71 s, B06 163 s, B07 157 s, B03-B05 3-10 s each. Unpacking the six archives needs about 10 GB of disk.
  • data/per_start/ in this package was produced by exactly these commands from the released archives (MANIFEST.json files are not included). Rows are written in shards of 2000 as the workers finish, so a rerun can put a row into a different shard; the set of rows and every value are the same.

Stage 2: physical runs and nominal simulations (physical/physical_runs.py)

$PY physical/physical_runs.py <sbel-reproducibility>/2024/PathFollowingSim2real/TestingData data/waypoints results
cp results/physical_runs.csv results/nominal_sim_runs.csv data/
  • Outputs: physical_runs.csv (60 runs: run MAEs and start quantities), nominal_sim_runs.csv (12 nominal runs), tables_II_III.json / .tex (mean and SD of the five run MAEs, nominal-simulation MAE), physical_pair_bootstrap.json (run-bootstrap interval of each pair difference), physical_summary.json (start spread). In this package, the two CSV files are in data/ and the other outputs in results/.
  • Runtime: about 3 s.

Stage 3: analysis (analysis/)

$PY analysis/baseline_orders.py data/per_start data/nominal_sim_runs.csv data/baseline_orders.json
$PY analysis/case1_rank_analysis.py data/per_start data/physical_runs.csv data/baseline_orders.json results \
    > results/case1_rank_analysis_console.txt
  • baseline_orders.py (about 1 s): predicted order of each baseline per path and metric (ascending run MAE): M-NOM (B03, phase 0), NOM-archived-2024 (nominal simulations of Tables II-III), RF-A (B04, mean of 20 runs), RF-B (B05). For the Chrono batches, the NN-HD column is ctrl_label nnhdx175 on Paths 1-2 and nnhdx150 on Path 3.
  • case1_rank_analysis.py (about 4 s): per-start ranks of the settling times (ties shared, failures = H), TR order by ascending mean rank, Kendall tau against the six physical orders, 2000 bootstrap replicates (seed 20261105), exact permutation tests (252 allocations) with Holm adjustment, sensitivity and ablation. Output: results/case1_rank_analysis.json. The TR order of Path 1-2 targets uses the nnhdx175 column and that of Path 3 targets the nnhdx150 column; the rank percentages of Table I use nnhdx175.

Stage 4: MPC failures (mpc_failures/)

$PY mpc_failures/first_tick.py logs/runs/B01_main_tr data/b01_mpc_first_tick.csv            # 4a, needs B01 logs
$PY mpc_failures/d3_range.py data/per_start data/b01_mpc_first_tick.csv \
    results/mpc_failures.json results/mpc_failure_geometry.png                                 # 4b
  • 4a (under 1 s on the unpacked B01): first controller tick of each of the 400 MPC episodes (e0, et0-et2).
  • 4b (about 1 s): classifies the 400 MPC starts (divergence / no entry / reached the tube) and counts the starts beyond the e_long = 0 boundary and beyond the ridge of the released MPC stage cost; writes a two-panel figure.

Paper item -> script -> output

Paper item Script Output file : key
Table I (rank %, mean rank, failed %, mean ST, tau per offset range S0-S4) analysis/case1_rank_analysis.py case1_rank_analysis.json : offset_sweep (rank_pct, mean_rank, fail_pct, n_all_recover, mean_st_all_recover, mean_tau_vs_physical)
Text on Table I: S2 pairwise win rates 0.90-0.91, NN-MPC beats PID 0.75 [0.71, 0.80] same offset_sweep[S2].pairwise_win_rate_ci95
Tables II-III (mean +- SD of five run MAEs; nominal simulation) physical/physical_runs.py tables_II_III.tex, tables_II_III.json
Physical starts within 0.28 m, initial lateral error <= 0.24 m same physical_summary.json
Point orders of Tables II-III (physical orders) analysis/case1_rank_analysis.py physical_order
Table IV (tau per path and metric, mean tau [95 % CI], best selected, resolved pairs correct) same (+ analysis/baseline_orders.py) method_comparison (rows TR (rank rule, S2), Nominal simulation (2024 archive) = nominal simulation of Tables II-III, Monte Carlo, start jitter (RF-A), Monte Carlo, jitter + disturbances (RF-B); row Nominal simulation = B03)
NN-MPC physical MAE 1.95-2.65 x MPC on Paths 1-2 same method_comparison[...].selected_error_ratio_to_best
TR minus nominal simulation +0.56, all 2000 replicates same tr_minus_nominal_tables_II_III
32 of 36 pairs resolved; adjusted p = 0.294 and 0.056; TR orders 30/32 same physical_pairwise_tests (p_perm, p_holm), method_comparison[TR...].resolved_pairs_correct
Path 3 NN-MPC - PID lateral: 0.0249 m, [-0.0101, 0.0615] m physical/physical_runs.py physical_pair_bootstrap.json : pairs.P3_lateral
Sensitivity: horizons 15/25/40 s and nine tubes analysis/case1_rank_analysis.py tube_horizon_sensitivity
Number of starts: 94.2 % (10), 99.9 % (25), 100 % (>= 50) same trial_number_sensitivity
Hoeffding: smallest adjacent mean-rank gap 0.511 (n bound 350) same hoeffding
Hoeffding: epsilon_n = 0.239 for K = 4, n = 400, alpha = 0.05 formula $PY -c "import math; print(3*math.sqrt(math.log(2*4/0.05)/(2*400)))" -> 0.2389
Table V (ablation by channel, D1a-D5) and "MPC fails from 8.5-10.5 %" analysis/case1_rank_analysis.py ablation_by_channel (order, mpc_first_pct, mean_tau_vs_physical, fail_pct)
MPC failures: 33/400 (29 divergences + 4 wheel-lock), boundary about 20-30 deg, 318 starts inside the boundary, none diverges mpc_failures/d3_range.py mpc_failures.json : summary (div, noentry, all.beyond_ridge = 82, boundaries_deg_away, divergence_rate_inside)

Verification of this package

The package was run in a fresh copy and compared with the outputs that the paper was produced from:

  • results/case1_rank_analysis.json: every number equal (926 numeric leaves); only the free-text label differs.
  • data/physical_runs.csv: all 60 rows equal in all 21 columns; nominal-simulation MAEs, Tables II-III and the 36 pair-bootstrap intervals bit-identical.
  • data/baseline_orders.json: orders and scores bit-identical for all four baselines and six targets.
  • data/per_start/: extracted from the released archives; all 21,090 rows of the six batches equal in every metric column. Differences are only in identity fields that the release changed: tags_json (ctrl_desc text, internal tags removed), config_hash (recomputed for the released config) and summary_sha256 (rewritten summary.json). All rows have chk_all = 1 (extractor values agree with the runner summaries).
  • runner/batches/generate_lists.py regenerates all 21,090 released episode configurations of B01 and B03-B07 exactly (after the runner's config.normalize), except tags.default_config_sha256 (see Stage 0).
  • results/mpc_failures.json: every number equal (2024 numeric leaves).

Notes

  • The steering-bias level 0.013 of D2a enters as a constant (runner/batches/steering_bias.json); the script that estimated it from the archived logs is not part of this package.
  • The physical and nominal-simulation logs are not copied here; they are public in the GitHub repository above.