mechanism/devices.hpp — the DEVICES one mechanism was built over, and what the build found for each of its ROLES.
This header declares 3 types (21 members) and 1 constant.
Extracted from include/shulib/mechanism/devices.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.
inline constexpr std::size_t kDevicesMaxMotors = 4How many motors one mechanism's Devices has room for: config::kMaxMotorsPerMechanism, stated here because this header includes nothing above hal/ (robot/mechanism_parts.hpp and mechanism/service.hpp each static_assert that the two agree).
constant, declared at include/shulib/mechanism/devices.hpp:41.
struct DevicesThe devices one mechanism was built over (header).
struct, declared at include/shulib/mechanism/devices.hpp:44.
hal::MotorMechanism* motors = nullptrA motor kind's actuator (power, position, speed); nullptr for a pneumatic or when ABSENT.
field, declared at include/shulib/mechanism/devices.hpp:46.
hal::PneumaticMechanism* pneumatic = nullptrA pneumatic kind's actuator; nullptr for a motor kind or when ABSENT.
field, declared at include/shulib/mechanism/devices.hpp:48.
hal::IRotation* angleSensor = nullptrIts angle sensor (a Rotation role).
field, declared at include/shulib/mechanism/devices.hpp:50.
hal::IDigitalIn* homeSwitch = nullptrIts home switch (a limit switch on a 3-wire line).
field, declared at include/shulib/mechanism/devices.hpp:52.
hal::IDistance* pieceDistance = nullptrIts piece sensor when it is a distance sensor (at most one of the three piece pointers).
field, declared at include/shulib/mechanism/devices.hpp:54.
hal::IOptical* pieceOptical = nullptrIts piece sensor when it is an optical sensor.
field, declared at include/shulib/mechanism/devices.hpp:56.
hal::IDigitalIn* pieceSwitch = nullptrIts piece sensor when it is a limit switch.
field, declared at include/shulib/mechanism/devices.hpp:58.
const hal::IReadFaults* pieceFaults = nullptrThe piece sensor's READ-FAULT count (the provider's readFaults(port) / lineReadFaults(line)): a sample taken while it moved was a HELD value, never evidence. nullptr = no piece sensor, or one that never screens a read.
field, declared at include/shulib/mechanism/devices.hpp:62.
const hal::IReadFaults* homeSwitchFaults = nullptrThe home switch's read-fault count (lineReadFaults(line)).
field, declared at include/shulib/mechanism/devices.hpp:64.
const char* absence = ""Why the mechanism was NOT built — the provider's sentence naming the port; "" when it was.
field, declared at include/shulib/mechanism/devices.hpp:66.
hal::IMotorCurrentLimit* currentLimits[kDevicesMaxMotors]{}Each motor's own current limit, in the motors' order (MECH-S-A; the provider's currentLimit(port)); nullptr past the mechanism's motors, for a pneumatic or ABSENT one, and where the provider's motor cannot limit its current.
field, declared at include/shulib/mechanism/devices.hpp:70.
enum class RoleState : std::uint8_tWhat the build found for ONE ROLE — the facts its boot line words (mechanism::roleLine, in mechanism/wiring.hpp).
enum class, declared at include/shulib/mechanism/devices.hpp:75.
Presenta smart device of the expected kind answered on its port
enumerator, declared at include/shulib/mechanism/devices.hpp:76.
Refusedthe provider refused it (its sentence names the port and what was found)
enumerator, declared at include/shulib/mechanism/devices.hpp:77.
NotCheckablea 3-wire role: made, but the brain cannot see a 3-wire device (HA-158)
enumerator, declared at include/shulib/mechanism/devices.hpp:78.
NotAskednot requested: the mechanism was already ABSENT
enumerator, declared at include/shulib/mechanism/devices.hpp:79.
struct RoleFactOne role of one mechanism, as the build left it — what a boot line needs.
struct, declared at include/shulib/mechanism/devices.hpp:83.
const char* role = ""The role in the boot line's words: "motor 1".."motor 4", "line 1", "line 2", "angle sensor", "home switch", "piece sensor".
field, declared at include/shulib/mechanism/devices.hpp:86.
std::uint8_t port = 0Its smart port, physical (1..21); 0 for a 3-wire role.
field, declared at include/shulib/mechanism/devices.hpp:88.
std::uint8_t line = 0Its 3-wire line, 1..8 = A..H; 0 for a smart role.
field, declared at include/shulib/mechanism/devices.hpp:90.
RoleState state = RoleState::NotAskedWhat the build found.
field, declared at include/shulib/mechanism/devices.hpp:92.
bool degradeOnly = falseA refusal that leaves the mechanism RUNNING WITHOUT this role (a piece sensor), rather than ABSENT.
field, declared at include/shulib/mechanism/devices.hpp:95.
const char* refusal = ""The provider's refusal sentence when state is Refused (stable for the parts' lifetime); "" otherwise.
field, declared at include/shulib/mechanism/devices.hpp:98.
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 — 22 lines
mechanism/devices.hpp — the DEVICES one mechanism was built over, and what the build found for
each of its ROLES (the mechanism core, chunk MECH-A1, 2026-10-08).
robot::MechanismParts (robot/mechanism_parts.hpp) builds every role a mechanism declares — its
motors or lines, its angle sensor, its home switch, its piece sensor — and hands the result to
the mechanism service (MECH-A2) as one `Devices` per mechanism, and to the boot lines as one
`RoleFact` per role. HAL POINTERS ONLY, and no other mechanism/ header included, so robot/ may
produce these without depending on the vocabulary above it (mechanism/kinds.hpp, wiring.hpp).
nullptr in a `Devices` = that role is not on this mechanism, or the mechanism is ABSENT, or (a
piece sensor) it was refused and the mechanism runs WITHOUT one. The read-fault pointers are the
provider's IDeviceProvider::readFaults / lineReadFaults for that sensor (hal/read_faults.hpp):
the service reads a sample taken while one moved as HELD, never as evidence (MECH-A2's rule).
Since MECH-S-A (2026-11-05) a motor mechanism's `Devices` also carries each motor's own CURRENT
LIMIT (the provider's IDeviceProvider::currentLimit(port) — hal/motor_current_limit.hpp), in the
motors' order: the service writes a stated cap through it at boot and reads every motor's limit
back (mechanism/service.hpp). nullptr = no such motor, or a provider whose motor cannot limit its
current (the service says so when a cap is stated).
PROS-free, allocation-free.