mechanism/direction_check.hpp — THE DIRECTION CHECK's judgement.
This header declares 4 types (22 members), 4 free functions, and 1 constant.
Extracted from include/shulib/mechanism/direction_check.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.
enum class PersonSawstruct DirectionObservationenum class DirectionFindingchangeHere— free functionwireHere— free functionstruct DirectionVerdictjudgeDirection— free functionkNothingOrSomethingElseMoved— constantjudgePneumatic— free function
enum class PersonSaw : std::uint8_tWhat the person answered after the jog — the page's THREE buttons, plus "not asked yet".
enum class, declared at include/shulib/mechanism/direction_check.hpp:61.
NotAsked = 0the question has not been answered yet
enumerator, declared at include/shulib/mechanism/direction_check.hpp:62.
ItsPlusWayTHIS mechanism moved, the way its "+" should
enumerator, declared at include/shulib/mechanism/direction_check.hpp:63.
TheOtherWayTHIS mechanism moved, the OTHER way
enumerator, declared at include/shulib/mechanism/direction_check.hpp:64.
NothingOrSomethingElseMovedit did NOT move — or ANOTHER mechanism moved
enumerator, declared at include/shulib/mechanism/direction_check.hpp:65.
struct DirectionObservationWhat the page recorded over one jog of ONE motor mechanism.
struct, declared at include/shulib/mechanism/direction_check.hpp:69.
double commandVolts = 0.0The jog's signed command, volts — the robot file's "+" way when positive. Finite, not 0.
field, declared at include/shulib/mechanism/direction_check.hpp:71.
double motorDeltaRad[kMaxMotorRoles]{}Each motor role's encoder change over the jog, radians (role order: the declaration's).
field, declared at include/shulib/mechanism/direction_check.hpp:73.
double motorPeakAmps[kMaxMotorRoles]{}Each motor role's highest current during the jog, amps.
field, declared at include/shulib/mechanism/direction_check.hpp:75.
bool hasAngleSensor = falseThe mechanism has an angle sensor and the page read it.
field, declared at include/shulib/mechanism/direction_check.hpp:77.
double sensorDeltaRad = 0.0The angle sensor's change over the jog, radians (as the declaration's mounting reads it).
field, declared at include/shulib/mechanism/direction_check.hpp:79.
PersonSaw person = PersonSaw::NotAskedThe person's answer.
field, declared at include/shulib/mechanism/direction_check.hpp:81.
enum class DirectionFinding : std::uint8_tThe judgement's finding.
enum class, declared at include/shulib/mechanism/direction_check.hpp:85.
Okit moved its + way (or a pneumatic went where it was told)
enumerator, declared at include/shulib/mechanism/direction_check.hpp:86.
DidNotMovea motor neither moved nor drew current: its cable, or its port
enumerator, declared at include/shulib/mechanism/direction_check.hpp:87.
MotorFightsa motor turned AGAINST its command while a mate turned WITH its own: the mate drags it
enumerator, declared at include/shulib/mechanism/direction_check.hpp:88.
FightOrJamevery motor still, every one drawing: they fight, or it is jammed
enumerator, declared at include/shulib/mechanism/direction_check.hpp:89.
SensorReversedthe angle sensor reads against the motors
enumerator, declared at include/shulib/mechanism/direction_check.hpp:90.
MechanismReversedit moved the OTHER way (or a pneumatic went to another position)
enumerator, declared at include/shulib/mechanism/direction_check.hpp:91.
CableOnAnotherMechanismit did not move although commanded: its cable or line is elsewhere
enumerator, declared at include/shulib/mechanism/direction_check.hpp:92.
AwaitingPersonthe encoders found nothing: ask "ONLY '' should move: which way?"
enumerator, declared at include/shulib/mechanism/direction_check.hpp:93.
BackDrivenevery motor that moved went AGAINST its command: gravity or a load beat the jog
enumerator, declared at include/shulib/mechanism/direction_check.hpp:94.
inline void changeHere(char* out, std::size_t cap, const char* source, const char* file, std::uint32_t line, const MechanismSpec& s)"Change it HERE" (file header): source when stated (a generated robot file's JSON path), else file:line (where the team wrote it), else the declaration's own line, else the robot file by name. Writes at most cap bytes, NUL-terminated.
free function, declared at include/shulib/mechanism/direction_check.hpp:100.
inline void wireHere(char* out, std::size_t cap, const MechanismWiring& w, const MechanismSpec& s)The mechanism's WIRING line (its wire(...)), where a cable on the wrong port is fixed; the wiring list by name when the line was not captured. Writes at most cap bytes, NUL-terminated.
free function, declared at include/shulib/mechanism/direction_check.hpp:114.
struct DirectionVerdictThe judgement: a finding, the motor role it names (where it names one), and the sentence — the robot-file line to change, or what to check.
struct, declared at include/shulib/mechanism/direction_check.hpp:124.
DirectionFinding finding = DirectionFinding::AwaitingPersonWhat was found.
field, declared at include/shulib/mechanism/direction_check.hpp:126.
std::uint8_t role = 0The motor role the finding names (0-based; 0 where it names none).
field, declared at include/shulib/mechanism/direction_check.hpp:128.
char fix[384]{}The sentence (empty while awaiting the person).
field, declared at include/shulib/mechanism/direction_check.hpp:130.
[[nodiscard]] inline DirectionVerdict judgeDirection(const MechanismSpec& s, const MechanismWiring& w, const DirectionObservation& o, double minMoveRad, double drawAmps)THE JUDGEMENT for a MOTOR mechanism (file header), in this order: every motor still and every one drawing → FightOrJam; a motor that neither moved nor drew → DidNotMove (its cable, its wire line); a motor that moved AGAINST the command while another moved WITH it → MotorFights (that role's Forward/Reversed); motors that moved, every one AGAINST the command → BackDriven (no line named: jog harder or from another pose); the angle sensor against the command → SensorReversed; then the person's answer — NotAsked → AwaitingPerson, TheOtherWay → MechanismReversed (swap EVERY Forward and Reversed), NothingOrSomethingElseMoved → CableOnAnotherMechanism (its wire line), ItsPlusWay → Ok. PRECONDITIONS: s is a motor kind (one to four motor roles); o.commandVolts finite and not 0; minMoveRad and drawAmps finite and above 0 (the page's stated numbers).
free function, declared at include/shulib/mechanism/direction_check.hpp:143.
inline constexpr std::uint8_t kNothingOrSomethingElseMoved = 0xFFA pneumatic's answer "it did NOT move, or ANOTHER mechanism moved" (judgePneumatic's sawPosition).
constant, declared at include/shulib/mechanism/direction_check.hpp:291.
[[nodiscard]] inline DirectionVerdict judgePneumatic(const MechanismSpec& s, const MechanismWiring& w, std::uint8_t commanded, std::uint8_t sawPosition)THE JUDGEMENT for a PNEUMATIC mechanism: the page commanded position commanded (after the person confirmed the robot was safe) and the person says which named position it went to — or kNothingOrSomethingElseMoved. The commanded one → Ok; another → MechanismReversed (its line levels are swapped, named where they are stated); nothing or something else → CableOnAnotherMechanism (its valve is not on the line the wiring says, or is unplugged, or has no air — its wire line). PRECONDITIONS: s is a pneumatic; commanded one of its positions; sawPosition one of its positions or kNothingOrSomethingElseMoved.
free function, declared at include/shulib/mechanism/direction_check.hpp:300.
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 — 46 lines, click to expand
mechanism/direction_check.hpp — THE DIRECTION CHECK's judgement (the mechanism core, chunk MECH-A4,
2026-10-22; its bench page is MECH-A6's station 13). Pure, host-tested, PROS-free.
── What it is for ─────────────────────────────────────────────────────────────────────
The boot names every role's port and sees a cable on the WRONG KIND of device, but two cables of
the SAME kind swapped between mechanisms, a motor declared the wrong way, or an angle sensor
mounted backwards all look fine at boot. The direction check jogs ONE mechanism a little (the page
commands it, under its own gates), records what the encoders saw, and asks the person ONE question
— "ONLY '<name>' should have moved: did it go its + way, the OTHER way, or did it NOT move (or
something ELSE moved)?" — and this file turns the two halves into a finding and the exact place to
change: the declaration's line for a direction, the `wire(...)` line for a cable on the wrong
mechanism. It REPORTS; it cannot save a flip (the team lead's Q1 (a): the robot file is the only
place a direction lives — edit it, rebuild, upload).
── What the encoders can see, and what only a person can ──────────────────────────
A V5 motor reverses its command AND its encoder together, so a motor's own encoder cannot see that
motor declared the wrong way (the brief's landmine 17). What the encoders CAN see:
* a motor whose encoder moves AGAINST its command WHILE A MATE MOVES WITH ITS OWN — the mate
drags it: a FIGHT, and THAT motor's Forward/Reversed is the one to flip;
* every motor that moved went AGAINST its command (one motor, or all of them alike) — no mate
dragged it: the mechanism was BACK-DRIVEN by something stronger than the jog (gravity, a
load). No declaration is wrong, and none is named (the review's finding: "make motor 1
Reversed" for a sagging one-motor arm would break a correct declaration);
* every motor still while every one draws current — two motors of equals declared against each
other stall TOGETHER, or the mechanism is JAMMED / at a stop (never "check motor 1's cable");
* a motor that neither moved nor drew — its cable, or its port in the wiring;
* an angle sensor reading against the motors — the sensor's mounting is declared backwards.
What only the person can say: which way the MECHANISM moved, and whether it was THIS mechanism at
all — a same-kind cable swap moves ANOTHER mechanism, whose encoder agrees with its command (the
re-check's D6: the THIRD answer names the wiring line, not the declaration).
── "Change it HERE" ─────────────────────────────────────────────────────────────────
A role's place, in order: its stated `changeAt` (a GENERATED robot file's JSON path — G3a), else
the file and line the declaration was written on (captured by the `.name` word — no string typed
by hand, so it cannot go stale when a line moves), else the declaration's own line. A cable on the
wrong mechanism is fixed at its `wire(...)` line (captured where motors(...) / lines(...) is
written). A captured path is the one the compiler opened, so host and brain differ: a test pins
its SUFFIX.
── The thresholds are the PAGE's ───────────────────────────────────────────────────
`minMoveRad` (an encoder change below it is "did not move") and `drawAmps` (a still motor drawing
at least it is pushing on something) are the bench page's STATED numbers (HA-182's page entries,
MECH-A6) — never invented here.
Allocation-free; every sentence bounded and NUL-terminated in the verdict's own buffer.