competition::checkAndFlipToggle — the Toggle flip for a SKILLS run, as ONE route step.
This header declares 8 types (100 members), 17 free functions, and 2 constants.
Extracted from include/shulib/competition/toggle_visit.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.
kToggleVisitTickSeconds— constantkToggleVisitWaitSlackSeconds— constantstruct FlipperGoalstruct ToggleVisitRequestenum class ToggleVisitProblemtoggleVisitProblemOf— free functiontoggleVisitProblemSentence— free functiontoggleVisitRequestProblem— free functiontoggleVisit— free functiontoggleVisitCeilTick— free functiontoggleVisitNeedSeconds— free functionworstCaseSeconds— free functionenum class ToggleVisitVerdicttoggleVisitWord— free functiontoggleColourOf— free functionoursFor— free functionstruct ToggleVisitReportstruct ExplicitToggleCamerastruct TogglePoseBoundbandAtLookSpotProblem— free functiontowardWallRadians— free functioncheckAndFlipToggle— free functionlookAtToggle— free functioncheckAndFlipToggle (overload 2)— free functionlookAtToggle (overload 2)— free functiontoggleVisitBlockProblem— free function
inline constexpr double kToggleVisitTickSeconds = 0.010The control tick the time check rounds every bound UP to, seconds: the brain's 10-ms tick (hal::pros::ProsTickPacer::kTickMs, A4 register HA-32) — the grid every wait ends on.
constant, declared at include/shulib/competition/toggle_visit.hpp:217.
inline constexpr double kToggleVisitWaitSlackSeconds = 0.25Slack past a wait's own bound given to its backstop timeout, seconds. Unreachable by construction (each wait's predicate, the mechanism service's deadline or the motion's watchdog ends it first); code-level belt and braces, not an HA entry (Routine's kMechanismWaitSlackSeconds is the same idea).
constant, declared at include/shulib/competition/toggle_visit.hpp:222.
struct FlipperGoalWHICH flipper and which of its goals — a preset of ONE Arm or Lift, a position of ONE Pneumatic, or (default-constructed) a PASSIVE flipper: a fixed bar the robot's own drive in and out strokes. It converts IMPLICITLY from a mechanism goal, so .flipper = flipper["flip"].
struct, declared at include/shulib/competition/toggle_visit.hpp:227.
Kind kind = Kind::PassiveThe kind (Passive when default-constructed).
field, declared at include/shulib/competition/toggle_visit.hpp:235.
mechanism::PositionGoal position{}The goal when Position.
field, declared at include/shulib/competition/toggle_visit.hpp:237.
mechanism::PneumaticGoal pneumatic{}The goal when Pneumatic.
field, declared at include/shulib/competition/toggle_visit.hpp:239.
constexpr FlipperGoal() noexcept = defaultA PASSIVE flipper.
function, declared at include/shulib/competition/toggle_visit.hpp:242.
constexpr FlipperGoal(const mechanism::PositionGoal& g) noexceptA PASSIVE flipper. An Arm's or a Lift's goal (arm["flip"], lift.to(6_in)).
function, declared at include/shulib/competition/toggle_visit.hpp:244.
constexpr FlipperGoal(const mechanism::PneumaticGoal& g) noexceptA Pneumatic's position (flipper["out"]).
function, declared at include/shulib/competition/toggle_visit.hpp:247.
[[nodiscard]] constexpr bool passive() const noexceptTrue for a passive flipper.
function, declared at include/shulib/competition/toggle_visit.hpp:251.
[[nodiscard]] constexpr const char* mechanismName() const noexceptThe mechanism's name ("" for a passive one).
function, declared at include/shulib/competition/toggle_visit.hpp:253.
enum class Kind : std::uint8_tWhich kind of flipper the goal is for.
enum class, declared at include/shulib/competition/toggle_visit.hpp:229.
Passive = 0no mechanism: the drive in and out is the stroke (default)
enumerator, declared at include/shulib/competition/toggle_visit.hpp:230.
Positionan Arm's or a Lift's preset or constant
enumerator, declared at include/shulib/competition/toggle_visit.hpp:231.
Pneumatica Pneumatic's named position
enumerator, declared at include/shulib/competition/toggle_visit.hpp:232.
struct ToggleVisitRequestOne visit's numbers — every one the TEAM's, from Step 0 at the robot; 0 = UNSET and refused by name (the core's rule: no library default). flipBound and backBound may stay 0 for a PASSIVE flipper (nothing is commanded); any value given is still counted in the time check.
struct, declared at include/shulib/competition/toggle_visit.hpp:264.
vision::override2026::ToggleId toggle{}WHICH Toggle (toggles::kRedWall). "Ours" is its Quadrant's colour (HA-243).
field, declared at include/shulib/competition/toggle_visit.hpp:266.
FlipperGoal flipper{}The push: a preset of ONE Arm or Lift, a position of ONE Pneumatic, or default = PASSIVE.
field, declared at include/shulib/competition/toggle_visit.hpp:268.
FlipperGoal back{}The retract: another goal of the SAME mechanism (default = PASSIVE, with a passive flipper).
field, declared at include/shulib/competition/toggle_visit.hpp:270.
units::Length lookFrom{}The LOOK SPOT: lens to the Toggle's face, horizontal, inches (Step 0.4). That the camera names the colour from there on a real field is A4 register HA-245 (the host camera model's prediction, unmeasured). With a FIELD start it is ALSO compared with the estimate's lens distance from the wall's INNER face — the face taken to sit at that inner face (A4 register HA-201: UNVERIFIED).
field, declared at include/shulib/competition/toggle_visit.hpp:275.
units::Length offBy{}How far off the look spot is accepted: the larger half-width of the range interval the bench page prints AT the look spot, plus the route's arrival allowance, inches (Step 0.4 — no default). A COARSE check: where the flipper lands is the route's driving (A4 register HA-244).
field, declared at include/shulib/competition/toggle_visit.hpp:279.
units::Length pushFrom{}The PUSH SPOT: lens to the face where the flipper (or the bar) rolls the Toggle, inches (Step 0.5; HA-244).
field, declared at include/shulib/competition/toggle_visit.hpp:281.
units::Time lookWithin{}The longest a look waits for a sure colour, seconds (Step 0.3).
field, declared at include/shulib/competition/toggle_visit.hpp:283.
units::Time flipBound{}The push's own time limit, seconds (Step 0.1: the worst of five). It, or the flipper's stall signature, ends a push a sticky Toggle stops before it damages the Toggle — A4 register HA-235. For a pneumatic it must be at least the cylinder's move time plus its confirm window (else FLIPPER NOT READY).
field, declared at include/shulib/competition/toggle_visit.hpp:287.
units::Time backBound{}The retract's own time limit, seconds (Step 0.1). For a pneumatic, at least its move time plus its confirm window, as flipBound.
field, declared at include/shulib/competition/toggle_visit.hpp:290.
units::Time settle{}How long the Toggle takes to sit flat after the retract, seconds (Step 0.1; HA-232).
field, declared at include/shulib/competition/toggle_visit.hpp:292.
units::Time driveBound{}The drive in's — and the drive out's — own time limit, seconds (Step 0.6; HA-244).
field, declared at include/shulib/competition/toggle_visit.hpp:294.
units::Time margin{}Spare time kept at the end of the visit, seconds.
field, declared at include/shulib/competition/toggle_visit.hpp:296.
units::Time maxImageAge{}The camera's image age at its read, seconds (Step 0.2; HA-192) — rule 2's pose bound, rule 5's frozen check (how long the drive in may HOLD to tell a frozen camera from a lagging one — counted in rule 4) and rule 6's "a picture from after the retract".
field, declared at include/shulib/competition/toggle_visit.hpp:300.
std::uint8_t maxPushes = 2At most this many pushes: 1 or 2 (a 3 is refused). On the research's reading every skills Toggle needs TWO from yellow, through the other colour (A4 register HA-231) — the rule holds either way.
field, declared at include/shulib/competition/toggle_visit.hpp:303.
enum class ToggleVisitProblem : std::uint8_tWhat is wrong with a request, if anything (each a refusal, at build through toggleVisit(...) or at run time as a precondition).
enum class, declared at include/shulib/competition/toggle_visit.hpp:308.
None = 0nothing
enumerator, declared at include/shulib/competition/toggle_visit.hpp:309.
ToggleUnsetno Toggle named
enumerator, declared at include/shulib/competition/toggle_visit.hpp:310.
NotFinitea number is NaN or infinite
enumerator, declared at include/shulib/competition/toggle_visit.hpp:311.
LookFromUnsetlookFrom UNSET
enumerator, declared at include/shulib/competition/toggle_visit.hpp:312.
OffByUnsetoffBy UNSET
enumerator, declared at include/shulib/competition/toggle_visit.hpp:313.
PushFromUnsetpushFrom UNSET
enumerator, declared at include/shulib/competition/toggle_visit.hpp:314.
PushNotNearerpushFrom >= lookFrom: the push spot must be nearer than the look spot
enumerator, declared at include/shulib/competition/toggle_visit.hpp:315.
OffByTooLargeoffBy >= lookFrom: the window would reach the face
enumerator, declared at include/shulib/competition/toggle_visit.hpp:316.
LookWithinUnsetlookWithin UNSET
enumerator, declared at include/shulib/competition/toggle_visit.hpp:317.
FlipBoundUnsetflipBound UNSET for a mechanism flipper (or negative)
enumerator, declared at include/shulib/competition/toggle_visit.hpp:318.
BackBoundUnsetbackBound UNSET for a mechanism flipper (or negative)
enumerator, declared at include/shulib/competition/toggle_visit.hpp:319.
SettleUnsetsettle UNSET
enumerator, declared at include/shulib/competition/toggle_visit.hpp:320.
DriveBoundUnsetdriveBound UNSET
enumerator, declared at include/shulib/competition/toggle_visit.hpp:321.
MarginUnsetmargin UNSET
enumerator, declared at include/shulib/competition/toggle_visit.hpp:322.
MaxImageAgeUnsetmaxImageAge UNSET
enumerator, declared at include/shulib/competition/toggle_visit.hpp:323.
MaxPushesmaxPushes not 1 or 2
enumerator, declared at include/shulib/competition/toggle_visit.hpp:324.
FlipperKindsDifferthe flipper and the back are of different kinds (one passive, or arm vs pneumatic)
enumerator, declared at include/shulib/competition/toggle_visit.hpp:325.
TwoMechanismsthe flipper and the back name two mechanisms
enumerator, declared at include/shulib/competition/toggle_visit.hpp:326.
SameGoalTwicethe flipper and the back are the same goal: no stroke
enumerator, declared at include/shulib/competition/toggle_visit.hpp:327.
[[nodiscard]] constexpr ToggleVisitProblem toggleVisitProblemOf(const ToggleVisitRequest& r) noexceptThe first problem with r, or None. Pure, total, constexpr.
free function, declared at include/shulib/competition/toggle_visit.hpp:380.
[[nodiscard]] constexpr const char* toggleVisitProblemSentence(ToggleVisitProblem p) noexceptThe problem as a sentence for a person, or nullptr for None.
free function, declared at include/shulib/competition/toggle_visit.hpp:436.
[[nodiscard]] constexpr const char* toggleVisitRequestProblem(const ToggleVisitRequest& r) noexceptThe first problem with r as a sentence, or nullptr.
free function, declared at include/shulib/competition/toggle_visit.hpp:462.
[[nodiscard]] consteval ToggleVisitRequest toggleVisit(ToggleVisitRequest r)A request checked AT BUILD: inline constexpr auto kRedWallVisit = competition::toggleVisit({...}); — a problem stops the build, naming it (the core's build-check idiom). A request built while the auton runs is checked by the step itself, as a precondition.
free function, declared at include/shulib/competition/toggle_visit.hpp:469.
[[nodiscard]] inline double toggleVisitCeilTick(double x) noexceptx seconds rounded UP to the 10-ms tick (a value already on the grid stays).
free function, declared at include/shulib/competition/toggle_visit.hpp:497.
[[nodiscard]] inline double toggleVisitNeedSeconds(const ToggleVisitRequest& r, int pushes) noexceptRule 4's need(n), seconds: n x (ceil(driveBound) + ceil(maxImageAge) + ceil(flipBound) + ceil(backBound) + ceil(settle) + ceil(driveBound) + ceil(lookWithin) + 2 ticks) + margin — every bound rounded UP to the tick; ceil(maxImageAge) is the most the drive in may HOLD on "camera frozen?" (rule 5).
free function, declared at include/shulib/competition/toggle_visit.hpp:504.
[[nodiscard]] inline double worstCaseSeconds(const ToggleVisitRequest& r) noexceptThe time check's own sum for the whole visit: need(maxPushes), seconds — what a route's budget (and the route preview, RPV1) should allow for this step after the look before it (itself at most lookWithin). The ideal host plant flips in less; the robot will not.
free function, declared at include/shulib/competition/toggle_visit.hpp:516.
enum class ToggleVisitVerdict : std::uint8_tHow a visit ended (appended-only, like every enum a route shares).
enum class, declared at include/shulib/competition/toggle_visit.hpp:521.
Unset = 0a default report — no visit ran (never returned by the step)
enumerator, declared at include/shulib/competition/toggle_visit.hpp:522.
AlreadyOursSUCCEEDS: it showed ours before; nothing pushed (seating not checked)
enumerator, declared at include/shulib/competition/toggle_visit.hpp:523.
FlippedSUCCEEDS: it showed ours after a FULL stroke (seating not checked)
enumerator, declared at include/shulib/competition/toggle_visit.hpp:524.
NotSkillsnot a SKILLS auton: no "ours" (the alliance's comes with ALLY1)
enumerator, declared at include/shulib/competition/toggle_visit.hpp:525.
NoCamerano usable camera for this step
enumerator, declared at include/shulib/competition/toggle_visit.hpp:526.
FlipperNotReadythe flipper absent, not homed, busy, or not at back (never moved there)
enumerator, declared at include/shulib/competition/toggle_visit.hpp:527.
WrongWalla FIELD start, and the robot does not face the named Toggle's wall
enumerator, declared at include/shulib/competition/toggle_visit.hpp:528.
UnknownBeforeno sure colour at the look (the tracker's reason): nothing pushed
enumerator, declared at include/shulib/competition/toggle_visit.hpp:529.
NotAtSpotthe band is not wholly inside the look spot's window: nothing pushed or driven
enumerator, declared at include/shulib/competition/toggle_visit.hpp:530.
NotEnoughTimethe time left does not cover need(maxPushes): nothing pushed or driven
enumerator, declared at include/shulib/competition/toggle_visit.hpp:531.
NoChangeafter push 1 it shows the colour it had before (sticky, or a frozen camera)
enumerator, declared at include/shulib/competition/toggle_visit.hpp:532.
StillNotOursafter the last allowed push it is still not ours
enumerator, declared at include/shulib/competition/toggle_visit.hpp:533.
UnknownAfterno sure colour after the push (the reason): it stops
enumerator, declared at include/shulib/competition/toggle_visit.hpp:534.
NoTimeForSecondPushpush 1 turned it to the third colour; need(1) does not fit
enumerator, declared at include/shulib/competition/toggle_visit.hpp:535.
FlipperStuckthe retract did not reach back: the robot stays (it does not drag the Toggle)
enumerator, declared at include/shulib/competition/toggle_visit.hpp:536.
Cutthe run's deadline or a disable cut the step
enumerator, declared at include/shulib/competition/toggle_visit.hpp:537.
OursAfterShortStrokeours after a stroke that stopped short — maybe stuck part-way: NOT counted
enumerator, declared at include/shulib/competition/toggle_visit.hpp:538.
RetractedForTimethe retract-now rule fired: back at once, out, and done
enumerator, declared at include/shulib/competition/toggle_visit.hpp:539.
DriveFailedthe drive in or out did not arrive within driveBound
enumerator, declared at include/shulib/competition/toggle_visit.hpp:541.
SeenNotOurslookAtToggle only: a sure colour at the spot, not ours (the look call never pushes)
enumerator, declared at include/shulib/competition/toggle_visit.hpp:542.
FrozenBeforePushthe camera seen frozen on the drive in: nothing pushed, the robot drove out
enumerator, declared at include/shulib/competition/toggle_visit.hpp:543.
SpotsTooClosethe EVERYDAY form only: lookFrom - pushFrom is twice the Toggle block's frozenMoveIn or less (the route's request against the robot file's block) — nothing read or moved (the explicit form throws a precondition instead)
enumerator, declared at include/shulib/competition/toggle_visit.hpp:545.
[[nodiscard]] constexpr const char* toggleVisitWord(ToggleVisitVerdict v) noexceptThe verdict as words for a log line, a bench page or the route preview.
free function, declared at include/shulib/competition/toggle_visit.hpp:551.
[[nodiscard]] constexpr vision::ToggleColour toggleColourOf(vision::override2026::QuadrantColour q) noexceptA Quadrant's colour as the camera's colour (RED, BLUE; Unknown for Unset).
free function, declared at include/shulib/competition/toggle_visit.hpp:580.
[[nodiscard]] constexpr vision::ToggleColour oursFor(vision::override2026::ToggleId id) noexcept"Ours" for id in a skills run: its Quadrant's colour as the camera names it (Unknown for Unset).
free function, declared at include/shulib/competition/toggle_visit.hpp:590.
struct ToggleVisitReportOne visit, as a VALUE (rule 7's line says the same in words).
struct, declared at include/shulib/competition/toggle_visit.hpp:595.
ToggleVisitVerdict verdict = ToggleVisitVerdict::UnsetHow it ended.
field, declared at include/shulib/competition/toggle_visit.hpp:597.
vision::override2026::ToggleId toggle{}Which Toggle.
field, declared at include/shulib/competition/toggle_visit.hpp:599.
vision::ToggleColour ours = vision::ToggleColour::UnknownThe target: its Quadrant's colour.
field, declared at include/shulib/competition/toggle_visit.hpp:601.
vision::ToggleColour before = vision::ToggleColour::UnknownThe colour at the look before (Unknown when not sure).
field, declared at include/shulib/competition/toggle_visit.hpp:603.
vision::ToggleColour after = vision::ToggleColour::UnknownThe colour at the last look after (Unknown when not sure or none was made).
field, declared at include/shulib/competition/toggle_visit.hpp:605.
vision::ToggleWhy whyBefore = vision::ToggleWhy::NoReadThe tracker's reason at the end of the look before.
field, declared at include/shulib/competition/toggle_visit.hpp:607.
vision::ToggleWhy whyAfter = vision::ToggleWhy::NoReadThe tracker's reason at the end of the last look after.
field, declared at include/shulib/competition/toggle_visit.hpp:609.
bool afterTooEarly = falseTrue when the last look after saw a sure colour it could not count: no picture from after the retract, or the lens not yet moved past frozenMoveIn since it.
field, declared at include/shulib/competition/toggle_visit.hpp:612.
std::uint8_t pushes = 0Pushes made (a passive stroke counts as one).
field, declared at include/shulib/competition/toggle_visit.hpp:614.
bool fullStroke[2]{false, false}Whether each push's stroke was FULL (the push SUCCEEDED after a drive in that arrived; a passive drive that reached the push spot).
field, declared at include/shulib/competition/toggle_visit.hpp:617.
vision::Interval range{}The band's range interval at the look before, inches (valid when a band passed).
field, declared at include/shulib/competition/toggle_visit.hpp:619.
vision::Interval bearing{}The band's bearing interval at the look before, radians (valid when a band passed).
field, declared at include/shulib/competition/toggle_visit.hpp:621.
bool positionChecked = falseTrue when the tracker's POSITION gate ran on the look before's sure view (the tracker's config turns it on, and the camera handles stated a pose bound it accepts).
field, declared at include/shulib/competition/toggle_visit.hpp:624.
double lensFromWallIn = 0.0With a FIELD start: the estimate's lens distance from the Toggle's wall at the look, inches.
field, declared at include/shulib/competition/toggle_visit.hpp:626.
bool wallChecked = falseTrue when the wall and the field distance were checked (a FIELD start).
field, declared at include/shulib/competition/toggle_visit.hpp:628.
double secondsLeftAtStart = 0.0The guard's remaining() when the step began, seconds.
field, declared at include/shulib/competition/toggle_visit.hpp:630.
double secondsLeftAtCheck = 0.0The guard's remaining() at the last time check, seconds (0 when none was made).
field, declared at include/shulib/competition/toggle_visit.hpp:632.
double secondsNeeded = 0.0What that check needed, seconds (0 when none was made).
field, declared at include/shulib/competition/toggle_visit.hpp:634.
double seconds = 0.0The step's own time, seconds.
field, declared at include/shulib/competition/toggle_visit.hpp:636.
mechanism::StepReport push[2]{}Each push's StepReport (a default one for a passive stroke or a push never made).
field, declared at include/shulib/competition/toggle_visit.hpp:638.
mechanism::StepReport back[2]{}Each retract's StepReport (likewise).
field, declared at include/shulib/competition/toggle_visit.hpp:640.
control::ExitReason driveIn = control::ExitReason::RunningThe drive in's and out's exit for the last stroke (Running when none was made).
field, declared at include/shulib/competition/toggle_visit.hpp:642.
control::ExitReason driveOut = control::ExitReason::RunningLikewise, the drive out.
field, declared at include/shulib/competition/toggle_visit.hpp:644.
const char* detail = ""A short reason beside some verdicts (FLIPPER NOT READY's, NO CAMERA's, NOT AT THE SPOT's) — a library literal, the flipper's absence sentence, or (the everyday form, AF1S-A2) the Toggle-camera slot's own sentence, which lives as long as its Robot; "" when none.
field, declared at include/shulib/competition/toggle_visit.hpp:648.
[[nodiscard]] constexpr bool ok() const noexceptTrue for the two successes: ALREADY OURS and FLIPPED.
function, declared at include/shulib/competition/toggle_visit.hpp:651.
[[nodiscard]] constexpr manipulation::MechanismOutcome outcome() const noexceptWhat a route's then() takes: SUCCEEDED for ok(); CANCELLED for CUT (the route stops whatever its on-failure choice); STALLED for FLIPPER STUCK, or a visit that ended short of ours (NO CHANGE, STILL NOT OURS, UNKNOWN AFTER) after a push that STALLED; TIMED_OUT for NOT ENOUGH TIME, NO TIME FOR PUSH 2 and RETRACTED FOR TIME; UNCONFIRMED for every other doubt, OURS AFTER A SHORT STROKE included.
function, declared at include/shulib/competition/toggle_visit.hpp:659.
struct ExplicitToggleCameraThe camera handles the explicit form reads — the robot's ONE camera feed and the mount the library believes, the TEAM's tracker numbers, and the pose bound the caller states. The step builds its OWN tracker from tracker and model for each visit, so the hold that counts always began inside it.
struct, declared at include/shulib/competition/toggle_visit.hpp:682.
vision::CameraFeed* feed = nullptrThe camera's feed — ticked inside the step's waits (nullptr: no camera).
field, declared at include/shulib/competition/toggle_visit.hpp:684.
const vision::CameraModel* model = nullptrThe mount the library believes, built from a placement cameraModelProblem() accepted (nullptr: no camera).
field, declared at include/shulib/competition/toggle_visit.hpp:687.
vision::ToggleTrackerConfig tracker{}The team's tracker numbers (toggleTrackerConfigProblem() must accept them).
field, declared at include/shulib/competition/toggle_visit.hpp:689.
units::Length poseTolerance{}The pose bound the caller states, inches: how far the estimate may be off. 0 = NONE stated — the tracker's position gate is then skipped (its view says unchecked), never run on a pose taken as exact.
field, declared at include/shulib/competition/toggle_visit.hpp:693.
double headingToleranceDeg = 0.0The heading bound the caller states, degrees (used only with poseTolerance).
field, declared at include/shulib/competition/toggle_visit.hpp:695.
const char* absence = nullptrWhy feed / model are nullptr, for NO CAMERA's line — the everyday form's slot sentence (AF1S-A2, APPENDED); nullptr = the library's own words ("no camera feed on this robot"). BORROWED: it must outlive the visit's report (a slot's sentence lives as long as its Robot).
field, declared at include/shulib/competition/toggle_visit.hpp:699.
struct TogglePoseBoundThe pose bound a ROUTE states for one visit through the everyday form (AF1S-A2) — how far the estimate may be off at the look, for the tracker's POSITION gate (the robot file's Toggle block turns the gate on; it runs only with a bound stated, tighter than the block's maxPoseToleranceIn). The default states NONE: the gate is skipped, never run on a pose taken as exact. State one only where the route trusts its pose — under a FIELD start, right after a wall reset (the AF1S brief's D6 (c)); under any other start the step drops it (the estimate is not in the field's frame) and its line says so. The gate turns MOST lookalikes away — not one within its tolerance of where a Toggle's face is (A4 register HA-199; guide chapter 14).
struct, declared at include/shulib/competition/toggle_visit.hpp:710.
units::Length poseTolerance{}How far the estimate's position may be off, inches. 0 = NONE stated (the gate is skipped).
field, declared at include/shulib/competition/toggle_visit.hpp:712.
double headingToleranceDeg = 0.0How far its heading may be off, degrees (used only with poseTolerance).
field, declared at include/shulib/competition/toggle_visit.hpp:714.
[[nodiscard]] inline const char* bandAtLookSpotProblem(const vision::ToggleView& v, const ToggleVisitRequest& r, double bearingWindowDeg) noexceptThe band at the look spot? nullptr when its WHOLE range interval lies inside [lookFrom - offBy, lookFrom + offBy] (both ends included) and its WHOLE bearing interval inside +-bearingWindowDeg; otherwise what is wrong. Containment, never overlap (file banner, rule 2). Pure.
free function, declared at include/shulib/competition/toggle_visit.hpp:720.
[[nodiscard]] inline double towardWallRadians(vision::override2026::ToggleId id) noexceptThe direction TOWARD id's wall, F1 radians (minus kTogglePlaces' inward normal): right 0, blue +pi/2, left pi, red -pi/2. PRECONDITION-free: an Unset id answers 0.
free function, declared at include/shulib/competition/toggle_visit.hpp:737.
[[nodiscard]] inline ToggleVisitReport checkAndFlipToggle(ExplicitToggleCamera& camera, chassis::Chassis& chassis, sequence::RunGuard& guard, mechanism::MechanismService* service, const AutonEntry& entry, const ToggleVisitRequest& request, hal::ITelemetrySink& sink)THE STEP, explicit form (file banner): look at request.toggle from the look spot the route parked the robot on; nothing more if it already shows its Quadrant's colour; otherwise drive in, push, retract, drive out, look again — at most maxPushes pushes, the second only on the third colour. Blocking, through guard's deadline-aware waits only; at most the look before plus worstCaseSeconds(request). Returns the report, a VALUE; outcome() is what a then() returns. ONE [TGL] line to sink. service may be nullptr for a PASSIVE flipper. PRECONDITIONS (a programming error, thrown): guard is running; toggleVisitRequestProblem(request) is nullptr; and, with a usable camera, lookFrom - pushFrom is more than twice the tracker's frozenMoveIn.
free function, declared at include/shulib/competition/toggle_visit.hpp:1597.
[[nodiscard]] inline ToggleVisitReport lookAtToggle(ExplicitToggleCamera& camera, chassis::Chassis& chassis, sequence::RunGuard& guard, mechanism::MechanismService* service, const AutonEntry& entry, const ToggleVisitRequest& request, hal::ITelemetrySink& sink)Rules 1–3 ONLY — it never moves anything: is it allowed, what colour is the Toggle, is the robot at the look spot. ALREADY OURS, SEEN NOT OURS (a sure colour at the spot, not ours), or the refusal that stopped it — the building block for a team that writes the flip itself (the brief's D1 (c); the checked step is the recommended path). ONE [TGL] line. The preconditions of checkAndFlipToggle.
free function, declared at include/shulib/competition/toggle_visit.hpp:1610.
[[nodiscard]] inline ToggleVisitReport checkAndFlipToggle(AutonContext& ctx, const ToggleVisitRequest& request, const TogglePoseBound& bound = {})THE STEP, EVERYDAY form (file banner, "Two forms, ONE body"; AF1S-A2): the explicit form's visit, with the camera the robot's own Toggle-camera slot (through ctx.chassis.deps().ctx), the flipper found in ctx.mechanismService, and ctx.guard, ctx.entry and ctx.telemetry. No slot, or one that is not ready, is NO CAMERA naming why (after NOT SKILLS — rule 1's order). bound states the estimate's uncertainty for the tracker's position gate (default: none — the gate is skipped); under a start that is not FIELD it is dropped, and the line says wall and position not checked (relative start). An excursion lookFrom - pushFrom of twice the slot's frozenMoveIn or less is SPOTS TOO CLOSE (a refusal: nothing read or moved). Returns the report; outcome() is what a then() returns. PRECONDITIONS: ctx.guard is running (an AutonContext lives for one guarded run) and the request is sane.
free function, declared at include/shulib/competition/toggle_visit.hpp:1667.
[[nodiscard]] inline ToggleVisitReport lookAtToggle(AutonContext& ctx, const ToggleVisitRequest& request, const TogglePoseBound& bound = {})Rules 1–3 ONLY, EVERYDAY form (AF1S-A2): lookAtToggle over the robot's own Toggle-camera slot, as checkAndFlipToggle(ctx, ...) reads it — the bound dropped under a start that is not FIELD, SPOTS TOO CLOSE the same. It never moves anything. ONE [TGL] line to ctx.telemetry.
free function, declared at include/shulib/competition/toggle_visit.hpp:1679.
[[nodiscard]] constexpr const char* toggleVisitBlockProblem(const ToggleVisitRequest& request, const vision::ToggleCameraConfig& block) noexceptThe ROUTE's request against the ROBOT FILE's Toggle block, AT BUILD (file banner; AF1S-A2's review): nullptr when the everyday step can take this pair, else the first problem — the request's own (toggleVisitRequestProblem), then an excursion lookFrom - pushFrom of twice the block's frozenMoveIn or less (the step's SPOTS TOO CLOSE). The PAIR only: a block that is not declared, or whose tracker numbers are refused, is the block's own problem (vision::toggleCameraProblem) and passes here. Pure, constexpr — a route that can see its robot file's block writes static_assert(competition::toggleVisitBlockProblem(kRedWallVisit, kToggleBlock) == nullptr);.
free function, declared at include/shulib/competition/toggle_visit.hpp:1695.
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 — 183 lines, click to expand
competition::checkAndFlipToggle — the Toggle flip for a SKILLS run, as ONE route step (chunk AF1S-A1,
2026-11-11; the AF1S brief's D1–D11 and its re-check R1–R12, the team lead's answers of 2026-11-10).
At a LOOK SPOT the route parked the robot on, square in front of a named Toggle, it looks at the
Toggle with the front AI Vision camera, does NOTHING if the Toggle already shows its Quadrant's
colour, and otherwise drives straight in, pushes with the flipper, retracts, drives straight back
out and looks again — a second push only when the first turned the Toggle to the THIRD colour,
never a third. Every doubt does nothing more and is reported; the route's own choice after a failed
step (its onFail, or the default stop) decides what comes next.
── Two forms, ONE body ─────────────────────────────────────────────────────────────────────────
The EVERYDAY form (chunk AF1S-A2, 2026-11-15), over an auton's context — what every team route writes:
r.onFail(skipTo("blue wall")).then([&] {
return competition::checkAndFlipToggle(ctx, kRedWallVisit).outcome();
}, "red wall Toggle");
It reads the robot's Toggle camera through `ctx.chassis.deps().ctx->toggleCamera()` — the context's
second OPTIONAL slot, filled by robot::Robot from the robot file's camera and Toggle blocks
(vision/toggle_camera.hpp), carried by the motion scheduler's shadow context — exactly as the everyday
wall reset reads the wall sensors; the mechanism service, the guard, the entry and the sink are the
context's own. No slot (no Toggle block declared) or a slot that is NOT READY (the camera absent, its
mount unmeasured, a tracker number refused — its own sentence) is NO CAMERA, that sentence in the line,
at rule 1's place (after NOT SKILLS). An optional third argument states a POSE BOUND for the visit —
`{.poseTolerance = 2_in, .headingToleranceDeg = 3}` under a FIELD start, right after a wall reset (the
brief's D6 (c)) — so the tracker's position gate, when the robot file turns it on, can run; without one it
is skipped. Two things the everyday form does that the explicit one does not (AF1S-A2's review, 2026-11-16), both
because the library KNOWS how this run's estimate was set (runAuton applied the entry's start) and the
two numbers it compares come from two files:
* a bound stated under a start that is not FIELD is NOT handed to the tracker — the estimate is then
in the robot's own frame, not the field's, so the position gate would compare it with the season's
Toggle places and drop the real Toggle as "no band"; the line says `wall and position not checked
(relative start)`. (The explicit form's caller knows its own estimate's frame and states the bound.)
* an excursion lookFrom - pushFrom of twice the Toggle block's `frozenMoveIn` or less — the ROUTE's
request against the ROBOT FILE's block, typed at different stations — is a REFUSAL, SPOTS TOO CLOSE,
before anything is read or moved, so the route's onFail applies; in the explicit form, where one
caller holds both numbers, it stays a programming error (a precondition). toggleVisitBlockProblem()
checks the pair AT BUILD, for a route that can see its robot file's block.
The EXPLICIT form (AF1S-A1), over handles — the host tests and a hand-wired Tier-3 program:
r.then([&] {
return competition::checkAndFlipToggle(cam, ctx.chassis, ctx.guard, ctx.mechanismService,
ctx.entry, kRedWallVisit, ctx.telemetry).outcome();
}, "red wall Toggle");
Both run the one visit below (detail::ToggleVisit): every rule is the same in both, by construction — the
two differences above are a detail::VisitForm the everyday calls hand it.
── "Ours" in a skills run ──────────────────────────────────────────────────────────────────────
Each Toggle's QUADRANT colour (vision/override_elements.hpp's table, A4 register HA-243 — a reading
of the manual's drawings, v2.0 <RSC3>a-iii-1: "Toggles only confer Ownership of Pins when the Toggle
matches the color of its Quadrant"; v2.1's change log keeps it in substance). The route names WHICH
Toggle; "ours" is never typed, so it cannot be typed wrong. A MATCH auton is refused (NOT SKILLS):
its "ours" is the alliance's, which comes after the 21st (ALLY1).
── What "FLIPPED" means — and what it cannot (A4 register HA-232) ──────────────────────────────
It means "the Toggle SHOWS our colour after a FULL stroke" — never "it is set". The game counts a
Toggle as set only when it is fully seated and no robot touches it (v2.0 <SC4>); a Toggle stuck
part-way through its roll shows the face it is rolling TO, and the camera reads that colour "sure"
(VIS1-A2's banner; the AF1S brief's probe P5(c): 58 of 108 stuck positions). So a success line
always ENDS "seating not checked", and a stroke that stopped short — a push that STALLED, TIMED OUT
or was CANCELLED, or a passive drive that did not reach the push spot — and then reads ours is NOT a
success: OURS AFTER SHORT STROKE. That the flipper pushes on the camera's word ALONE is the team
lead's ruling (2026-11-03, "just the ai vision sensor", confirmed for this step on 2026-11-10 — the
brief's D11): no sensor sees colour at the push point.
── The rules, in order (each one a test) ───────────────────────────────────────────────────────
1. ALLOWED — reading NOTHING, commanding nothing: a SKILLS auton (else NOT SKILLS); a usable camera
(the feed, a measured mount, a tracker config the tracker accepts — else NO CAMERA); an excursion
lookFrom - pushFrom of MORE than twice the tracker's `frozenMoveIn` (else, in the EVERYDAY form,
SPOTS TOO CLOSE; in the explicit form a precondition at this same place — below); the flipper
found on this robot, built, homed, idle and AT `back` within its "reached" tolerance — a
pneumatic's `flipBound` and `backBound` each at least its move time plus its confirm window,
the most its slot waits for a verdict, so rule 4 never counts less than the step will wait
(else FLIPPER NOT READY — the step NEVER moves it there itself: the route does); with a FIELD start,
the estimate's heading within +-45 degrees of the direction TOWARD the named Toggle's wall —
minus kTogglePlaces' inward normal: right wall 0, blue wall +90, left wall 180, red wall -90
(else WRONG WALL). A RELATIVE start skips the wall check and the line says so.
2. LOOK — a FRESH tracker, fed from the look's start on every read of the feed (ticked inside the
run guard's deadline-aware wait, so the mechanism service and any motion keep ticking and a
deadline cuts it), with the estimate and the caller's pose bound widened for the image's age
(vision::boundAtImage, `maxImageAge`) — up to `lookWithin` for a SURE colour, else UNKNOWN
BEFORE with the tracker's reason. Sure, the band must be AT THE SPOT: its WHOLE range interval
inside [lookFrom - offBy, lookFrom + offBy] — CONTAINMENT, never overlap (the interval is 5–18
in wide on the host camera model: an overlap test accepted a robot 8–11 in too far) — and its
whole bearing interval inside the tracker's window; with a FIELD start, also the estimate's lens
within `offBy` of `lookFrom` from the wall's inner face, along its normal — which takes the
Toggle's face to sit AT that inner face (where it sits is UNVERIFIED, A4 register HA-201: a real
set-back shifts this window by that much; Step 0.4 measures it). Else NOT AT THE SPOT. This check is
COARSE: the camera catches only gross arrival errors; where the flipper lands is the route's
odometry (A4 register HA-244).
3. OURS ALREADY — ALREADY OURS, nothing pushed.
4. TIME — need(n) = n x (ceil(driveBound) + ceil(maxImageAge) + ceil(flipBound) + ceil(backBound) +
ceil(settle) + ceil(driveBound) + ceil(lookWithin) + 2 ticks) + margin, ceil() up to the 10-ms
tick (ceil(maxImageAge): the most the drive in HOLDS on "camera frozen?", rule 5). Push 1
only when the guard's remaining() >= need(maxPushes) (a visit that may need two pushes is not
begun unless both fit), push 2 only when >= need(1). Else NOT ENOUGH TIME / NO TIME FOR PUSH 2.
worstCaseSeconds(request) is need(maxPushes) — the look before it adds at most `lookWithin`.
5. FLIP, every push PAIRED — drive straight IN by lookFrom - pushFrom along the current heading
(NEVER a blocking Chassis verb: a motion::MoveToPose started with scheduler().async and waited
through the guard, its predicate ticking the feed and the tracker on every read, cancelled on
every exit); command `flipper`; on ANY verdict, `back` at once; wait for it; `settle`; drive
straight back OUT to the look spot. The camera SEEN FROZEN on the drive in (the lens moved past
`frozenMoveIn` and the band's box did not move, still so on a picture taken after that was first
seen — readAt - maxImageAge, HA-192: a live camera's lagging pictures catch up within
maxImageAge — so the look the push would rest on may be a stale picture): the drive in stops
there, nothing is pushed, the robot drives out (FROZEN BEFORE PUSH). Raised but not yet that old
(a maxImageAge longer than the rest of the drive in), the step HOLDS before anything reaches the
Toggle — an active flipper's drive in arrives and nothing is pushed yet; a PASSIVE bar's drive
in (the stroke itself) stops where the question is raised — and keeps reading, at most
ceil(maxImageAge) a drive in (rule 4 counts it): the evidence turning stale, or the question
still open when that runs out, is FROZEN BEFORE PUSH; the question clearing (a live camera's
lagging pictures caught up) lets the push go on (a passive bar drives on, within what is left of
driveBound). With a pose bound stated, this check (and rule 6's "camera frozen?") reads an
UNGATED twin of the tracker: the position gate drops a frozen picture's band as "no band" once
the lens has moved it off the Toggle's place. A drive in that did not arrive: nothing pushed, the robot drives out (DRIVE FAILED); a
drive OUT that did not arrive: DRIVE FAILED, no look after (it would not be from the look
spot). A retract that does not reach `back`: FLIPPER STUCK and the robot does
NOT drive out (a flipper caught on the Toggle would drag it — <GG9>). If, while the flipper is
OUT (from the push's command until `back`'s; a passive bar: from the end of the drive in until
the drive out), the time left falls to backBound + settle + driveBound + margin, `back` is
commanded AT ONCE (the push is replaced), there is no settle, the robot drives out as soon as it
is back, and the visit ends RETRACTED FOR TIME — the robot must be OFF the Toggle at 0:00
(<SC4>b). Rule 4 makes that unreachable while every stage keeps to its bound; it is for time lost
OUTSIDE them (a brain's loop that stalled). A PASSIVE flipper (a fixed bar): the drive in and out
IS the stroke; no mechanism is commanded.
6. LOOK AGAIN — moving, and only after the retract (the brief's re-check R3, R4, R8). The tracker
has been fed on EVERY read since the look before (so a camera that froze anywhere — at the look
spot, on the way in, at the push spot, on the way out — has been moved past `frozenMoveIn` and
reads "camera frozen?"); the after-colour counts only from a SURE view on a read whose IMAGE is
after the retract's end (readAt - maxImageAge >= the retract's end — the read's time is not the
picture's, HA-192) AND after the lens has moved more than `frozenMoveIn` from where it was at
the retract's end (belt and braces: the look after begins only once the drive out SETTLED at
the look spot, and the excursion is more than twice `frozenMoveIn`, so with any settle
tolerance under the excursion less `frozenMoveIn` this clause cannot refuse a read — the one
host test that reaches it settles within 11 in of a 12-in excursion) — up to `lookWithin` after
reaching the look spot. Ours after a FULL stroke:
FLIPPED. Ours after a short one: OURS AFTER SHORT STROKE. The colour it had before: NO CHANGE (a
sticky Toggle, or a camera frozen since before the push — both stop). Not sure: UNKNOWN AFTER.
Push 1 and the THIRD colour: rule 4's push-2 check, then 5 and 6 once more; push 2 not ours:
STILL NOT OURS. Never a third push.
7. ONE [TGL] line per visit through the caller's sink — Info for the two successes, Warn otherwise;
ASCII, at most 160 bytes; every success line ends "seating not checked". The service's own
[MECH] lines for each push and retract appear beside it.
── What it cannot catch (stated, not hidden) ───────────────────────────────────────────────────
A Toggle stuck part-way that reads as its destination (above); a camera frozen while the robot is
parked, IF the step were changed to look from where it pushed (rule 6 is why it cannot); a camera
frozen at the look spot whose stale picture shows the Toggle is ALREADY ours — nothing is driven,
so nothing can show it frozen (a stale not-ours picture IS caught: the drive in moves the lens, rule
5); a PASSIVE bar that reaches the Toggle before the lens has moved `frozenMoveIn` on the drive in
(before a frozen camera CAN look frozen) strokes it on the stale look, and the verdict is still
FROZEN BEFORE PUSH (host test plant: a bar touching 2 in into a 16-in drive in); a Toggle that changes after the look, while the camera is still live on the drive in (too close
to name a colour at most mounts); for a PNEUMATIC flipper, whether the cylinder truly reached the
end of its stroke or truly went back — its slot reports SUCCEEDED once the commanded level has been
held for its move time (nothing senses the rod), so for a pneumatic "a FULL stroke" and "reached
`back`" mean "the move time passed": a cylinder blocked part-way by a jammed Toggle still reads as
FLIPPED's full stroke, and one caught on the Toggle on the way back is driven out with it — OURS
AFTER A SHORT STROKE and FLIPPER STUCK cannot come from a pneumatic (A4 register HA-235); a lookalike
band the tracker's gates cannot tell from a face (A4 register HA-199 — the position gate, with a pose
the team trusts, turns MOST of those away; not one within its tolerance of where a Toggle's face is); a
robot touching the Toggle after the step ends; the pieces the robot holds (<SG6>: holding more than one
Pin or one Cup, it may not touch a Toggle — the route's to respect).
A programming error is LOUD (a precondition): the guard not running; a request that names no Toggle,
leaves a number UNSET, puts the push spot at or beyond the look spot, an `offBy` of `lookFrom` or
more, a flipper and a back of two mechanisms or the same goal twice, or `maxPushes` other than 1 or
2 — refused AT BUILD when the request is built through toggleVisit(...) as a constant; and, in the
EXPLICIT form, an excursion lookFrom - pushFrom of twice the tracker's `frozenMoveIn` or less (the
look after could not see a frozen camera) — the everyday form refuses that one, SPOTS TOO CLOSE.
── A MIRRORED auton (chunk MIRROR1-A, 2026-11-13; competition/field_mirror.hpp) ─────────────────
The route names robot one's Toggle; `entry` says the run is robot two's, mirrored. The step reads the
localizer and drives the scheduler — below the Chassis's mirror, the REAL field — so it swaps for
itself: the request's Toggle becomes its IMAGE under the entry's mirror (override2026::mirroredToggle,
found from the season's places: robot one's red wall Toggle is robot two's right wall Toggle, left
<-> blue wall), whose Quadrant colour is the same (checked at compile time in override_mirror.hpp), so
"ours" does not change. Rule 1's WRONG WALL check, the look spot, the [TGL] line — every rule — then
reads the real Toggle; every other field of the request is a size or a mechanism and stays.
PROS-free, sim-free, allocation-free; single-task. It never runs in the background and never reads
the camera outside its own waits. NOTHING HERE HAS RUN ON A ROBOT: every rule has run against the
host test plant (the drive, the arm and the host Toggle and camera models) and nothing else.