Tune parameters¶
Tuning is guesswork on a live robot. Say what you want instead, in your own words. Quatern Code tries parameter changes on your robot's recordings, measures each one, and hands you the one that helps as a diff, with before and after numbers per recording. Nothing moves and nothing deploys.
More ways to run it:
quatern tune --robot c101 "stop oscillating at goals" --world "reach (3, 3)"
quatern tune --robot c101 "less drift" --recording c101.default_2026-10-02_hallway_v1
quatern tune --robot c101 "less drift" --out tuned_localizer/ # write the tuned module
quatern tune --robot c101 "less drift" --save --world "reach (3, 3)" # verify it as a stack
quatern tune --robot c101 "less drift" --agent # the agent proposes changes too
In the REPL: /tune <goal> with the selected robot.
What it tunes¶
Your words pick an objective:
| Objective | Words that pick it | Module | Metric | Knobs tried |
|---|---|---|---|---|
drift |
drift, localization, lost, jumps, pose, SLAM, map | localizer | drift_at_end per recording |
smoothing_window, loop_closure_threshold, keyframe_stride, live_map_weight |
goal_oscillation |
oscillating, wiggles, jitter, overshoot, settle, arriving | planner | Command reversals after the plan ends | goal_tolerance, velocity_scale |
Anything else is refused, with the list above. With --agent, the agent can also try change sets of its own, on any parameter path (for example nav2.cost_scaling_factor).
It starts from the pinned stack, else the newest ready stack, else the generated defaults, and replays on the robot's newest three recordings (or every --recording you name).
What you get¶
$ quatern tune --robot turtlebot4 "less drift"
quatern tune — turtlebot4.default: less localization drift ('less drift')
starting from generated defaults (no verified stack yet); replayed on 1 recording(s), 11 trial(s)
metric: drift_at_end, how far the localizer's pose ends from where the recording says the robot was
recording metric before after change
turtlebot4.default_2026-10-03_sample_v1 drift_at_end 0.0642 0.0542 -16%
loop_closures 0 0 same
loop_closure_error 0 0 same
changes: live_map_weight = 0.4
params.json:
--- a/params.json
+++ b/params.json
@@ -1,6 +1,7 @@
{
"actuator_response": {},
"keyframe_stride": 12,
+ "live_map_weight": 0.4,
"loop_closure_threshold": 0.75,
"smoothing_window": 4,
"source_weights": {
nothing was applied: --out writes the tuned module, --save verifies it as a stack; only `quatern deploy` runs one
How a candidate is judged¶
- Drift. The candidate localizer replays each recording exactly as
quatern verifyreplays it, in the sandbox; the metric isdrift_at_end. A change is kept only when it cuts the mean by 2% or more, and is ruled out if it makes loop closures unreliable (mean closure error over the warning limit where it was under). - Goal oscillation. The planner plans on each recording's map. The end of the plan, and the settle window after it, run through the deploy follower in closed loop, against a model with the calibration's measured actuator lag and each recording's measured localization noise (three noise draws per recording). The metric is how often the command reverses after the plan ends. Fewer reversals win; then the smaller error at the goal; then the shorter plan. A plan that gets 1.5× slower is ruled out.
The search tries one knob at a time and keeps what helps. Every trial is reported; --json lists them, with why any was ruled out.
goal_tolerance trades accuracy for stillness
Once the plan has ended and every DOF is within its tolerance of the goal, the deploy follower stops correcting and stays stopped, as Nav2's stateful goal checker does. The report shows the cost: the goal error before and after. For a Nav2 stack (Nav2 and SLAM Toolbox adapters, preview: untested on real ROS 2), the arrival replayed is Quatern Code's follower, not Nav2's controller, so Nav2's own goal checker in nav2_params.yaml is left alone. Other tuned parameters are written into the stack's parameter file (for SLAM Toolbox, loop_closure_threshold becomes loop_match_minimum_response_fine).
Never on the robot without the gate¶
Tuning moves nothing and deploys nothing. Its replays write their maps and results to a scratch store, so a candidate's map never becomes the map a deploy localizes against. The output is a diff:
--out DIRwrites the tuned module;quatern verify --module DIRchecks it.--saveverifies the tuned module as a new stack, exactly asquatern verify --modulewould. It isn't pinned:quatern pinandquatern deploy, where the gate asks you, are the only way it runs.
Flags¶
| Flag | Default | Meaning |
|---|---|---|
goal |
required | What you want, for example 'less drift in the hallway' or 'stop oscillating at goals'. |
--robot R |
required | Robot name or config path. |
--recording ID |
the newest three | Recording to replay. Repeatable. |
--stack ID |
pinned, else newest ready | Stack whose parameters to start from. |
--world W |
Goal the planner plans for, when no stack gives one. | |
--max-trials N |
24 | Cap on the number of trials. |
--out DIR |
Write the tuned module here. | |
--save |
Verify the tuned module as a new stack (never deployed). | |
--agent |
Have the agent propose and try changes too. | |
--json |
Every trial, as JSON. |
Tuned on a few recordings, a change can still lose on another. Run quatern regress before deploying.