mechanism/tune_program.hpp — "shulib Tune", the program that tunes a robot's MECHANISMS on the brain (chunk TUNE1-B1, 2026-11-10; the MECH-S/TUNE1 brief's D7 (a) and D8 (a), with its re-check amendments #3, #7, #8, #10 and #14).
This header declares 6 types (62 members), 4 free functions, and 24 constants.
Extracted from include/shulib/mechanism/tune_program.hpp — this page is that header's documentation, reformatted, so it cannot disagree with the code. Prose about how to think about the API lives in How it works; worked recipes live in Recipes; this page is the complete, mechanical list of what exists.
kTuneCompetitionDisabled— constantkTuneCompetitionAutonomous— constantkTuneCompetitionConnected— constantkTuneTestMostSeconds— constantkTuneTestPlanFactor— constantkTuneTestExtraSeconds— constantkTuneHoldSeconds— constantkTuneHomeSeconds— constantkTunePowerTestSeconds— constantkTuneSpeedTestSeconds— constantkTuneJogMostVolts— constantkTuneJogDeadband— constantkTuneMaxSamples— constantkTuneTag— constantkTuneTargetNameBytes— constantstruct TuneTargetstuneTargets— free functiontunePositionBound— free functionstruct TuneSamplestruct TuneMoveFactstuneReportFrom— free functiontuneTestLabel— free functionclass TuneIostruct TuneDeviceskGround— constantkText— constantkGrey— constantkGreyFill— constantkBlue— constantkLightBlue— constantkAmber— constantkGreen— constantkRed— constantclass TuneProgramTuneProgramTuneProgram (overload 2)operator=TuneProgram (overload 3)operator= (overload 2)~TuneProgrambootBannerrunstepentercopycopyChangeduncopiedpagemadeshownselecteddrawnreportmoveSamplesholdSampleslastBoundstatusbusytuningservicepartsconfirmedcapsWrittenBackcopiedAtExitresetAtExitundoTrackedDepth
inline constexpr std::uint8_t kTuneCompetitionDisabled = 0x01The competition status bit "disabled" (PROS's competition_get_status(); hal/pros/tune.hpp checks the three against PROS's own values at compile time). Hex: the API reference tool reads << as a bracket.
constant, declared at include/shulib/mechanism/tune_program.hpp:138.
inline constexpr std::uint8_t kTuneCompetitionAutonomous = 0x02The competition status bit "autonomous".
constant, declared at include/shulib/mechanism/tune_program.hpp:140.
inline constexpr std::uint8_t kTuneCompetitionConnected = 0x04The competition status bit "a field or switch is connected".
constant, declared at include/shulib/mechanism/tune_program.hpp:142.
inline constexpr double kTuneTestMostSeconds = 10.0A TEST move's time limit at most, seconds (the brief's re-check #7).
constant, declared at include/shulib/mechanism/tune_program.hpp:144.
inline constexpr double kTuneTestPlanFactor = 2.0A TEST move's time limit: the plan's time times this (re-check #7) ...
constant, declared at include/shulib/mechanism/tune_program.hpp:146.
inline constexpr double kTuneTestExtraSeconds = 0.5... plus the settle time plus this, seconds (re-check #7).
constant, declared at include/shulib/mechanism/tune_program.hpp:148.
inline constexpr double kTuneHoldSeconds = 1.0How long after a position or speed move SUCCEEDS the program records its hold (re-check #3: "the HOLD current over the second after it settles"), seconds.
constant, declared at include/shulib/mechanism/tune_program.hpp:151.
inline constexpr double kTuneHomeSeconds = 10.0HOME's time limit, seconds — INVENTED (a library choice: the TEST cap reused).
constant, declared at include/shulib/mechanism/tune_program.hpp:153.
inline constexpr double kTunePowerTestSeconds = 0.5A power mechanism's TEST run, seconds — INVENTED (a library choice).
constant, declared at include/shulib/mechanism/tune_program.hpp:155.
inline constexpr double kTuneSpeedTestSeconds = 5.0A flywheel's TEST spin-up time limit, seconds — INVENTED (a library choice; at most the TEST cap).
constant, declared at include/shulib/mechanism/tune_program.hpp:157.
inline constexpr double kTuneJogMostVolts = 6.0The stick's most volts on the shown mechanism — INVENTED (a library choice, half of full power).
constant, declared at include/shulib/mechanism/tune_program.hpp:159.
inline constexpr double kTuneJogDeadband = 0.15The stick's deadband, of full deflection — INVENTED (a resting thumb or drift moves nothing).
constant, declared at include/shulib/mechanism/tune_program.hpp:161.
inline constexpr std::size_t kTuneMaxSamples = 1200The most samples one test keeps: a 10 s move and its second at 10 ms, with room.
constant, declared at include/shulib/mechanism/tune_program.hpp:163.
inline constexpr const char* kTuneTag = "TUNEPG"The log tag of the program's own lines (the COPY block's is LiveTuning's "TUNE").
constant, declared at include/shulib/mechanism/tune_program.hpp:165.
inline constexpr std::size_t kTuneTargetNameBytes = sizeof(Preset::name)The longest test-target name, NUL included (a preset's name is at most 15 characters).
constant, declared at include/shulib/mechanism/tune_program.hpp:170.
struct TuneTargetsTEST A's and TEST B's targets for one mechanism (header): a position's or a flywheel's first and last preset, or (fewer than two) a quarter and three quarters of the range / half and nine tenths of the top speed; a power mechanism's +maxVolts and −maxVolts. A pneumatic has none (both 0).
struct, declared at include/shulib/mechanism/tune_program.hpp:175.
double a = 0.0TEST A's target (the mechanism's unit; volts for a power mechanism).
field, declared at include/shulib/mechanism/tune_program.hpp:177.
double b = 0.0TEST B's target.
field, declared at include/shulib/mechanism/tune_program.hpp:179.
char aName[kTuneTargetNameBytes]{}TEST A's name ("floor", "1/4 range", "forward").
field, declared at include/shulib/mechanism/tune_program.hpp:181.
char bName[kTuneTargetNameBytes]{}TEST B's name.
field, declared at include/shulib/mechanism/tune_program.hpp:183.
[[nodiscard]] inline TuneTargets tuneTargets(const MechanismSpec& s) noexceptThe targets of s (TuneTargets says how).
free function, declared at include/shulib/mechanism/tune_program.hpp:187.
[[nodiscard]] inline double tunePositionBound(const MechanismSpec& s, double fromDeg, double target)A position TEST move's TIME LIMIT (re-check #7): the plan's own time at the LIVE speed and acceleration — the trapezoid the service plans for that move, in output degrees from fromDeg (where it is now) to target clamped inside the live travel limits, by the service's one scale (the steepest units per degree, detail::unitsPerOutputDeg) — × kTuneTestPlanFactor, + the settle time + kTuneTestExtraSeconds, at most kTuneTestMostSeconds. PRECONDITION (the profile's): the live top speed and acceleration are finite and above 0 (live tuning never sets them to 0).
free function, declared at include/shulib/mechanism/tune_program.hpp:241.
struct TuneSampleOne sample of a test: after a tick, the clock, where it is (its unit) or how fast (output rpm), and the most current any of its motors draws.
struct, declared at include/shulib/mechanism/tune_program.hpp:257.
double t = 0.0The clock, s.
field, declared at include/shulib/mechanism/tune_program.hpp:259.
double x = 0.0Where it is, or how fast.
field, declared at include/shulib/mechanism/tune_program.hpp:261.
double amps = 0.0The most current any of its motors draws, A.
field, declared at include/shulib/mechanism/tune_program.hpp:263.
struct TuneMoveFactsWhat a test was, for tuneReportFrom().
struct, declared at include/shulib/mechanism/tune_program.hpp:267.
TuneTest test = TuneTest::NoneWhich test.
field, declared at include/shulib/mechanism/tune_program.hpp:269.
Kind kind = Kind::PositionThe mechanism's kind.
field, declared at include/shulib/mechanism/tune_program.hpp:271.
const char* unit = ""Its unit word.
field, declared at include/shulib/mechanism/tune_program.hpp:273.
double target = 0.0The target.
field, declared at include/shulib/mechanism/tune_program.hpp:275.
double start = 0.0Where it was (or how fast) when the test began.
field, declared at include/shulib/mechanism/tune_program.hpp:277.
double within = 0.0"Reached" (a position's within, units) or the at-speed band (a flywheel's, rpm).
field, declared at include/shulib/mechanism/tune_program.hpp:279.
manipulation::MechanismOutcome outcome = manipulation::MechanismOutcome::RunningThe verdict.
field, declared at include/shulib/mechanism/tune_program.hpp:281.
double seconds = 0.0Seconds from the command to the verdict.
field, declared at include/shulib/mechanism/tune_program.hpp:283.
double bound = 0.0The time limit.
field, declared at include/shulib/mechanism/tune_program.hpp:285.
double stallAmps = 0.0Its stall signature's amps (0: none).
field, declared at include/shulib/mechanism/tune_program.hpp:287.
double capAmps = 0.0Its current cap (0: none).
field, declared at include/shulib/mechanism/tune_program.hpp:289.
const char* stoppedBy = ""What stopped it (CANCELLED), else "".
field, declared at include/shulib/mechanism/tune_program.hpp:291.
[[nodiscard]] inline TuneReport tuneReportFrom(std::span<const TuneSample> move, std::span<const TuneSample> hold, const TuneMoveFacts& f) noexceptTHE REPORT (header) worked out of the samples: move from the first tick after the command to the tick that reached the verdict (inclusive), hold the second after a SUCCEEDED position or speed move. The direction of travel is the sign of (target − start) (+ when equal). Overshoot: the most any move sample is past the target in that direction, at least 0 (n/a for a power run). Settle: from the first move sample inside within of the target to the last move sample — SUCCEEDED only. Peak: the most amps over the move. Final error: the last move sample minus the target. Hold: the mean amps over hold (SUCCEEDED and at least one hold sample; else n/a). The warnings: a stated stall signature not above the hold; a stated cap not above the peak.
free function, declared at include/shulib/mechanism/tune_program.hpp:302.
inline void tuneTestLabel(char* out, std::size_t cap, char which, Kind k, double target) noexceptThe label of a TEST button: "A 22", "B -1.5", or a power run's "A FWD" / "B REV" — at most 7 characters (a target is shown clamped to ±9999).
free function, declared at include/shulib/mechanism/tune_program.hpp:351.
class TuneIoThe one thing the program reads that is on no HAL seam: the competition status byte. On the brain: hal::pros::ProsTuneIo (hal/pros/tune.hpp); on the host: a test's fake.
class, declared at include/shulib/mechanism/tune_program.hpp:368.
virtual ~TuneIo() = defaultPolymorphic-base boilerplate: a virtual destructor, the copy/move set re-defaulted.
function, declared at include/shulib/mechanism/tune_program.hpp:371.
TuneIo() = defaultPolymorphic-base boilerplate: a virtual destructor, the copy/move set re-defaulted. Default-constructible.
function, declared at include/shulib/mechanism/tune_program.hpp:373.
TuneIo(const TuneIo&) = defaultPolymorphic-base boilerplate: a virtual destructor, the copy/move set re-defaulted. Default-constructible. Copyable at the base.
function, declared at include/shulib/mechanism/tune_program.hpp:375.
TuneIo(TuneIo&&) = defaultPolymorphic-base boilerplate: a virtual destructor, the copy/move set re-defaulted. Default-constructible. Copyable at the base. Movable at the base.
function, declared at include/shulib/mechanism/tune_program.hpp:377.
TuneIo& operator=(const TuneIo&) = defaultPolymorphic-base boilerplate: a virtual destructor, the copy/move set re-defaulted. Default-constructible. Copyable at the base. Movable at the base. Copy-assignable at the base.
function, declared at include/shulib/mechanism/tune_program.hpp:379.
TuneIo& operator=(TuneIo&&) = defaultPolymorphic-base boilerplate: a virtual destructor, the copy/move set re-defaulted. Default-constructible. Copyable at the base. Movable at the base. Copy-assignable at the base. Move-assignable at the base.
function, declared at include/shulib/mechanism/tune_program.hpp:381.
[[nodiscard]] virtual std::uint8_t competitionStatus() = 0Polymorphic-base boilerplate: a virtual destructor, the copy/move set re-defaulted. Default-constructible. Copyable at the base. Movable at the base. Copy-assignable at the base. Move-assignable at the base. The competition status byte (the kTuneCompetition* bits).
function, declared at include/shulib/mechanism/tune_program.hpp:383.
struct TuneDevicesThe devices the program runs on, all BORROWED: each must outlive the program.
struct, declared at include/shulib/mechanism/tune_program.hpp:387.
hal::IDeviceProvider& devicesthe mechanisms' devices by port; the clock; the pacer; the sink
field, declared at include/shulib/mechanism/tune_program.hpp:388.
hal::IBrainScreen& screenthe brain's screen and touch
field, declared at include/shulib/mechanism/tune_program.hpp:389.
hal::IController& controllerthe master controller: every button a STOP; the stick
field, declared at include/shulib/mechanism/tune_program.hpp:390.
TuneIo& iothe competition status
field, declared at include/shulib/mechanism/tune_program.hpp:391.
inline constexpr std::uint32_t kGround = 0x000000The ground.
constant, declared at include/shulib/mechanism/tune_program.hpp:397.
inline constexpr std::uint32_t kText = 0xFFFFFFOrdinary text.
constant, declared at include/shulib/mechanism/tune_program.hpp:399.
inline constexpr std::uint32_t kGrey = 0x808080Grey (a quiet line, a greyed button's label).
constant, declared at include/shulib/mechanism/tune_program.hpp:401.
inline constexpr std::uint32_t kGreyFill = 0x303030A greyed button's fill.
constant, declared at include/shulib/mechanism/tune_program.hpp:403.
inline constexpr std::uint32_t kBlue = 0x1E5AA8Blue (a header, a button).
constant, declared at include/shulib/mechanism/tune_program.hpp:405.
inline constexpr std::uint32_t kLightBlue = 0x7FB2FFLight blue (a title's text).
constant, declared at include/shulib/mechanism/tune_program.hpp:407.
inline constexpr std::uint32_t kAmber = 0xF0C000Amber (attention).
constant, declared at include/shulib/mechanism/tune_program.hpp:409.
inline constexpr std::uint32_t kGreen = 0x30C030Green (good, GO).
constant, declared at include/shulib/mechanism/tune_program.hpp:411.
inline constexpr std::uint32_t kRed = 0xE03030Red (stopped, refused, STOP).
constant, declared at include/shulib/mechanism/tune_program.hpp:413.
class TuneProgram"SHULIB TUNE" (header). Construct it — in STATIC storage (PROS deletes the opcontrol task on a mode change; the service's slots point into this object) — over the robot's mechanism table and its devices; call bootBanner() from initialize() and run() from opcontrol(). Not copyable or movable.
class, declared at include/shulib/mechanism/tune_program.hpp:419.
TuneProgram(const MechanismTable& declared, TuneDevices d, const char* buildStamp)declared is the robot file's table (a constant that outlives the program); d and buildStamp are borrowed and must outlive it. Constructs NOTHING on the robot (no device is asked for).
function, declared at include/shulib/mechanism/tune_program.hpp:423.
TuneProgram(const TuneProgram&) = deleteNot copyable: it borrows the robot's devices, and the service's slots point into it.
function, declared at include/shulib/mechanism/tune_program.hpp:431.
TuneProgram& operator=(const TuneProgram&) = deleteNot copyable: it borrows the robot's devices, and the service's slots point into it. Not copy-assignable.
function, declared at include/shulib/mechanism/tune_program.hpp:433.
TuneProgram(TuneProgram&&) = deleteNot copyable: it borrows the robot's devices, and the service's slots point into it. Not copy-assignable. Not movable.
function, declared at include/shulib/mechanism/tune_program.hpp:435.
TuneProgram& operator=(TuneProgram&&) = deleteNot copyable: it borrows the robot's devices, and the service's slots point into it. Not copy-assignable. Not movable. Not move-assignable.
function, declared at include/shulib/mechanism/tune_program.hpp:437.
~TuneProgram() = defaultNot copyable: it borrows the robot's devices, and the service's slots point into it. Not copy-assignable. Not movable. Not move-assignable. The service ends any slot still holding its claim (its destructor); nothing else to release.
function, declared at include/shulib/mechanism/tune_program.hpp:439.
void bootBanner(const char* label, const char* statusWords)initialize(): the boot lines (constructs nothing, powers nothing). label is the build's beacon (or null), statusWords the competition status at boot in words (or null).
function, declared at include/shulib/mechanism/tune_program.hpp:443.
void run()opcontrol(): the loop, one pass every control tick, until VEXos reports the robot DISABLED or autonomous starting — every mechanism released first — or forever. Re-entered by PROS after a disable: the object carries on (the made mechanisms, the live numbers, the page).
function, declared at include/shulib/mechanism/tune_program.hpp:473.
bool step()ONE pass of the loop (header): read the status, the controller and the screen; stop on any abort cause; act on a touch or the stick; paint; tick the service once (it then advances the world); record a test's sample. False when driver control ended (everything released): the caller returns. Exposed for the host tests, which drive the loop pass by pass.
function, declared at include/shulib/mechanism/tune_program.hpp:483.
void enter()What run()/step() do when (re-)entered: the service's driver-control entry (a step left running by a deleted task CANCELLED, every motor mechanism made safe), a full repaint. Called by run().
function, declared at include/shulib/mechanism/tune_program.hpp:496.
int copy(std::size_t i)COPY mechanism i's block (LiveTuning::copyBlock) into the provider's sink — on the brain the terminal and the SD copy — and say how many lines on the page. Returns the count. PRECONDITION: i below the table's count.
function, declared at include/shulib/mechanism/tune_program.hpp:508.
int copyChanged()The COPY button (D9 (a): "for each mechanism changed, ONE block"): a block for EVERY mechanism whose numbers differ from the robot file's — or, when none does, the shown one's (0 lines, which says so). Returns the lines copied in all.
function, declared at include/shulib/mechanism/tune_program.hpp:528.
[[nodiscard]] bool uncopied(std::size_t i) constTrue when mechanism i's numbers differ from the robot file's AND from what its last COPY wrote (a change no COPY carries yet: what EXIT, or a cap going back, COPIES first).
function, declared at include/shulib/mechanism/tune_program.hpp:554.
[[nodiscard]] TunePage page() const noexceptThe page on the screen.
function, declared at include/shulib/mechanism/tune_program.hpp:560.
[[nodiscard]] bool made() const noexceptTrue once READY made the mechanisms.
function, declared at include/shulib/mechanism/tune_program.hpp:562.
[[nodiscard]] std::size_t shown() const noexceptThe shown mechanism's index.
function, declared at include/shulib/mechanism/tune_program.hpp:564.
[[nodiscard]] std::size_t selected() const noexceptThe selected number's position in the shown mechanism's list.
function, declared at include/shulib/mechanism/tune_program.hpp:566.
[[nodiscard]] const TuneView& drawn() const noexceptThe view last painted (what a touch is tested against).
function, declared at include/shulib/mechanism/tune_program.hpp:568.
[[nodiscard]] const TuneReport& report() const noexceptThe last TEST's report.
function, declared at include/shulib/mechanism/tune_program.hpp:570.
[[nodiscard]] std::span<const TuneSample> moveSamples() const noexceptThe last TEST's samples: the move's.
function, declared at include/shulib/mechanism/tune_program.hpp:572.
[[nodiscard]] std::span<const TuneSample> holdSamples() const noexcept... and its hold second's.
function, declared at include/shulib/mechanism/tune_program.hpp:576.
[[nodiscard]] double lastBound() const noexceptThe last TEST's time limit, s.
function, declared at include/shulib/mechanism/tune_program.hpp:580.
[[nodiscard]] const char* status() const noexceptThe status sentence on the page.
function, declared at include/shulib/mechanism/tune_program.hpp:582.
[[nodiscard]] bool busy() const noexceptA test, a homing or a test's hold second is running.
function, declared at include/shulib/mechanism/tune_program.hpp:584.
[[nodiscard]] LiveTuning& tuning() noexceptLive tuning (the table the service runs).
function, declared at include/shulib/mechanism/tune_program.hpp:586.
[[nodiscard]] MechanismService& service() noexceptThe service (bound once made).
function, declared at include/shulib/mechanism/tune_program.hpp:588.
[[nodiscard]] const robot::MechanismParts& parts() const noexceptThe built parts.
function, declared at include/shulib/mechanism/tune_program.hpp:590.
[[nodiscard]] bool confirmed(std::size_t i) const noexceptWhether mechanism i passed stage 2 of the clear confirm this session.
function, declared at include/shulib/mechanism/tune_program.hpp:592.
[[nodiscard]] int capsWrittenBack() const noexceptHow many current caps EXIT (or leaving a page) wrote back, in all.
function, declared at include/shulib/mechanism/tune_program.hpp:594.
[[nodiscard]] int copiedAtExit() const noexceptHow many mechanisms the last EXIT COPIED (changed, never copied) and RESET (a cap that could not go back alone).
function, declared at include/shulib/mechanism/tune_program.hpp:597.
[[nodiscard]] int resetAtExit() const noexcept... and RESET.
function, declared at include/shulib/mechanism/tune_program.hpp:599.
[[nodiscard]] std::size_t undoTrackedDepth() const noexceptHow many undo records the program tracks (which mechanism each is): always LiveTuning's undoDepth() — every change goes through the tracking.
function, declared at include/shulib/mechanism/tune_program.hpp:602.
The header opens with the reasoning behind these shapes. It is reproduced here in full because a reference that only lists signatures teaches nobody why.
The header’s own reasoning — 95 lines, click to expand
mechanism/tune_program.hpp — "shulib Tune", the program that tunes a robot's MECHANISMS on the brain
(chunk TUNE1-B1, 2026-11-10; the MECH-S/TUNE1 brief's D7 (a) and D8 (a), with its re-check amendments
#3, #7, #8, #10 and #14). PROS-free: hal/pros/tune.hpp is its thin shell on a V5.
── Why its own program, and why in the library ─────────────────────────────────────
A mechanism's numbers are found ON THE ROBOT (the team lead, 2026-10-29: "things need to be able to
be tuned"): a string cascade's gains, top speed, homing push and current cap. The match programs run
EXACTLY the robot file's numbers, so tuning lives in a program of its own, uploaded beside them
(`make ROBOT=<any robot with mechanisms> PROGRAM=tune`, slot 7) — never a page of shulib Drive, where
one stray tap in practice would leave the robot driving on numbers nobody wrote down (D7 (b)). It is
LIBRARY code over the HAL's seams — the standard Calibrate's pattern (calibration/calibrate_program.hpp)
— so every robot, robot one's cascade and a robot made in the panel later, runs the same program:
nothing in THIS file names a robot. (The BUILD names each robot once, as it does for every program:
a robot that registers a mechanism table adds its ROBOT value to the Makefile's MECHANISM_ROBOTS, a
`<robot> && SHULIB_PROGRAM_TUNE` branch to src/build_selection.hpp's one chain and its define to that
file's Tune guard, and a `<robot>-tune` build to tools/src_build_gate.py's tables — the src build gate
fails a robot with mechanisms that is missing from any of them: its step 0, or the guard's #error.)
── What it builds, and what it never builds ────────────────────────────────────────
ONLY the robot's mechanisms: each one's config projected from the robot file
(mechanism::toMechanismConfig, kept in this object beside the parts it builds), robot::MechanismParts
over the provider, ONE MechanismService bound over a LiveTuning's COPY of the table (live_tuning.hpp).
It NEVER constructs a chassis, a drive motor or a Robot (landmine 17: a robot on blocks is not
assumed), and NOTHING is made before stage 1 of the clear confirm (READY): making a 3-wire line
drives it to its start level (HA-119 — robot two's claw moves at boot).
── Its safety rules: the Auton Tester's (re-check #7) ──────────────────────────────
* EVERY mechanism is released to its declared safe state (MechanismService::leaveDriverControl():
a running step CANCELLED, every motor mechanism inert in its safe brake mode, a pneumatic keeping
its level — HA-157) on ANY of the controller's twelve buttons, on the controller DISCONNECTING, on
a field or switch being plugged in, on the page's STOP, and when VEXos reports the robot DISABLED
or autonomous starting (then run() returns: PROS calls opcontrol() again later, and this object,
in the shell's static storage, carries on). A stop is applied BEFORE the tick that follows the
read that saw it — never a tick later.
* READY (which makes the mechanisms — a pneumatic moves), TEST, HOME, STRING CHECK and the stick are
REFUSED, each with one sentence, unless a controller is connected (it carries the stop), no
button is held, VEXos reports no field or switch, and (but READY) the mechanism is built (and,
for a position TEST, homed).
* The stick starts a jog only on a FRESH push (centred, then pushed): one held over a change of
mechanism, a stop, GO or another page moves nothing until it is let go and pushed again.
* STAGE 2 of the clear confirm: a mechanism's FIRST motion in the session waits for GO.
* A TEST move's time limit is the plan's own time at the live speed and acceleration, × 2, plus the
settle time and 0.5 s, at most 10 s (tunePositionBound()); the service reports TIMED_OUT there.
* A change is applied only BETWEEN steps: a running test greys every button but STOP, and live
tuning itself refuses a change while its mechanism's step runs (LiveTuning, rule 3).
── The current cap stays in the motor (re-check #8, D12 (b); A4 register HA-220) ─────
A cap changed live is WRITTEN into each motor and a motor keeps a limit after the program ends, and
the next program, stating no cap, writes nothing. So this program puts back EVERY limit it changed —
the robot file's cap, or the motor's 2.5 A default when the file states none — on RESET (LiveTuning
re-derives it), on LEAVING that mechanism's page (‹ ›) and on EXIT (restoreCap(): LiveTuning::apply of
the file's cap; on EXIT, a RESET when that is refused). The tuned cap then leaves the live numbers, so
restoreCap() first COPIES the mechanism's numbers to the log when no COPY carries them yet; a page
whose cap cannot go back (a live signature at or above the file's cap) is not left — the page says
"lower it, or RESET". ONLY the shown mechanism carries a live cap: LiveTuning's UNDO is global, so an
UNDO whose next undo would change ANOTHER mechanism's cap (the cap put back when its page was left, or
a RESET of a raised cap) is checked BEFORE it is made and waits — nothing changes, the page says "UNDO
it on its page" (undoWaitsOn(); every change is tracked to know whose each undo is). Stopping the program from the brain runs no
code: the CLEAR page and the TUNE page's safety line (any mechanism's cap changed) say "EXIT before you
stop".
── A TEST move and its report (re-check #3, #7) ────────────────────────────────────
TEST A / TEST B: a position mechanism moves to its first and last preset (with fewer than two, a
quarter and three quarters of its live range); a flywheel spins up to its first and last preset (with
fewer, half and nine tenths of its top speed — INVENTED); a power mechanism runs at +maxVolts / −maxVolts
for kTunePowerTestSeconds (INVENTED). Each is an ordinary service step. After every tick the program
records one sample (the clock, where it is or how fast, the most current any of its motors draws);
when a position or speed move SUCCEEDS it records ONE MORE SECOND (its hold, or its spin at speed)
with every button but STOP greyed. Then tuneReportFrom() works the report out of the samples — the
time to the verdict, the farthest past the target, the settle (the first sample inside "reached" to
the verdict), the most current, the final error, the HOLD current (the mean over that second) — and
a WARNING when the stall signature is not above that hold (an ordinary hold could trip it: V1) or the
cap not above the peak (the cap limited the move: landmine 18). A flywheel is stopped after its
second; a position mechanism goes on holding. The report is on the REPORT page and in the log (tag
TUNEPG, the terminal and the SD copy).
── COPY ────────────────────────────────────────────────────────────────────────────
LiveTuning::copyBlock() into the provider's sink: on the brain the terminal AND /usd/tune_log.txt,
APPENDED across boots (re-check #14 — hal/pros/tune.hpp). The COPY button writes ONE block for EVERY
mechanism changed (D9 (a)); EXIT writes one for every mechanism changed since its last COPY, so the
live numbers — which are not kept — are in the log before the program can be stopped. Until the
panel's import exists (TUNE1-B2, after the panel), a student copies the block's lines into the robot
file BY HAND.
── The stick (a delta from the brief, logged: D8 (a) says "a student jogs it to the right height and
reads the number off", and nothing else on the page can) ───────────────────────────
The LEFT stick's up/down moves the shown POSITION or POWER mechanism by hold-to-run (the service's
jog() / drive()) at up to kTuneJogMostVolts (INVENTED) beyond kTuneJogDeadband, and holds where it is
(or stops) when let go. Never a button: every button is a STOP. A position mechanism before homing
moves only by its declaration's `.unhomedVolts` (the service's rule) — 0 means not at all.
The live numbers never persist: leaving the program, or a reboot, runs the robot file's numbers again
(every program but this one always does). NOTHING HERE HAS RUN ON A ROBOT: its tests drive it over
FakeDeviceProvider and the host test plant (its constants invented — HA-183).