Repository navigation
Autonomous: Score lap time against a reference lap computed from the course - #233
Conversation
|
Important Review skippedIgnore keyword(s) in the title. ⛔ Ignored keywords: 1
Please check the settings in the CodeRabbit UI or the
|
|
Safe to merge. I found no bugs in the reference-lap maths, the scorer wiring or the launch forwarding. The comment from the earlier push is outdated and I'm dropping it. What I checkedChecked:
Didn't check:
Assumed:
Ultron reviewed 5924b93 · it re-reviews on new pushes |
| except (OSError, ValueError) as error: # a bad world fails lap_time, not the score | ||
| ref, row['invalid_reason'] = None, f'reference lap: {error}' |
There was a problem hiding this comment.
🟡 Minor | Reliability
Catch XML parse errors from the reference world, and keep the lap's own invalid reason
If the .sdf found by course_reference is malformed or truncated, world_geometry raises ET.ParseError. That is a SyntaxError subclass, not ValueError or OSError, so it is not caught here. The whole score_gate.py run aborts and no results.csv or summary.md is written for any run, which contradicts the comment on this handler. I confirmed ParseError's MRO is ParseError, SyntaxError, Exception. The handler also overwrites invalid_reason, which held the metrics node's lap_invalid_reason, so that reason is lost from the CSV.
| except (OSError, ValueError) as error: # a bad world fails lap_time, not the score | |
| ref, row['invalid_reason'] = None, f'reference lap: {error}' | |
| except (OSError, ValueError, SyntaxError) as error: # a bad world fails lap_time, not the score | |
| ref = None | |
| row['invalid_reason'] = '; '.join( | |
| x for x in (row['invalid_reason'], f'reference lap: {error}') if x) |
🤖 Prompt for AI agents
In autonomy/testing/tools/gate/score_gate.py around lines 198-199:
Add SyntaxError (ET.ParseError's base) to the except tuple around course_reference so a malformed world file fails only that run's lap_time. Append the 'reference lap: ...' message to the existing row['invalid_reason'] instead of replacing it.
The gate now scores lap time against a reference lap computed from the course, not a truth-stack run. The reference is the fastest standing-start lap of the world's reference centerline under the run's own speed limits, so it is the same on every machine and cannot fail the way the truth stack does (pass criteria v2).
What changed
lhr_metrics/reference_lap.py(new). Plain Python. It samples the centerline every 0.5 m and caps speed at each sample byv_maxand bya_lat_max(floored atv_min, aspursuit_nodefloors it). Curvature comes from the circle through the points 3 m either side. A forward pass from rest at the start/finish gate appliesmax_accel, and a backward pass appliesmax_decel.gazebo_demo.launch.pyforwards the speed limits tometrics_node(lookahead_dist,a_lat_max,v_min,v_max,max_accel,max_decel, typed doubles). Before this, every Gazebo metrics row logged them as 0.0, so a row could not say what the car ran under. This is the only change inlhr_gazebo. It sits in themetrics_nodeblock that Autonomous: drive Gazebo sensors from the FMU in lockstep #221, Autonomous: Keep FMU and Gazebo steps synchronized #222, Autonomous: import real competition track layouts #223 and Autonomous: Add fixed extreme autocross scenarios #218 also touch, so expect a small conflict for whichever lands second.score_gate.py:lap_timepasses at no more than 1.5 times the course reference. New columnsreference_lap_sandlap_reference, and a reference-lap table in the summary. Campaigns recorded before this change have zeros for the limits and fall back to their truth-stack baselines, so they score as before.run_gate.sh:BASELINEdefaults to 0, which takes the matrix without skidpad from 23 runs to 18.BASELINE=1still adds the truth-stack runs for comparison.lhr_metricsandlhr_gazeboREADMEs, and the pass criteria.Testing
reference_lapunit tests:v_maxand by lateral acceleration, both within 0.05%v_minfloormetrics_nodeas doubles, with defaults and whole-number overrides, in both perception branches, through node startup.course_referencefinds the world from a foreign path, returns nothing for rows that logged zeros, and the course reference wins over a baseline.colcon testforlhr_metricsandlhr_gazeboran 365 tests with 0 failures. flake8 and pep257 are clean, andmkdocs build --strictpasses.The car can beat the reference slightly because pure pursuit cuts inside the centerline. 1.5 leaves room for honest variation and still catches a car that crawls or stalls.
Closes #232