Skip to content

imu.hpp

IImu — the inertial sensor behind the HAL, reporting in shulib's CANONICAL frame (the V5's clockwise/degrees convention is converted away in the hal/pros adapter via imu_conversion.hpp, so everything above this line is CCW-positive radians).

This header declares 1 type (11 members).

Extracted from include/shulib/hal/imu.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 the user guide; worked recipes live in the cookbook; this page is the complete, mechanical list of what exists.

Contents

class IImu

class IImu

The inertial sensor seam, reporting in shulib's CANONICAL frame: CCW-positive radians with +X = 0. The V5's clockwise-degrees convention is converted away once, inside the PROS adapter, so no code above this line ever converts an angle again. heading() is the load-bearing sub-degree quantity the whole accuracy claim rests on; every reading is untrustworthy until isReady() returns true. Implementations must not throw and must return finite values.

class, declared at include/shulib/hal/imu.hpp:21.

IImu::~IImu

virtual ~IImu() = default

All defaulted, and the fact worth carrying away is a lifetime one rather than a language one: an implementation is REFERENCED and never owned anywhere in this tree — RobotContext keeps a non-owning IImu*, and Localizer, PilonsOdometry and both correctors each hold an IImu& — so the adapter you construct must outlive every one of them. The destructor is virtual only so that owning one through an IImu* would still be well-defined; declaring it is what forces the copy and move members to be re-defaulted here.

function, declared at include/shulib/hal/imu.hpp:29.

IImu::IImu

IImu() = default

Covered by the comment on ~IImu — one comment documents this run of special members.

function, declared at include/shulib/hal/imu.hpp:30.

IImu::IImu (overload 2)

IImu(const IImu&) = default

Covered by the comment on ~IImu — one comment documents this run of special members.

function, declared at include/shulib/hal/imu.hpp:31.

IImu::IImu (overload 3)

IImu(IImu&&) = default

Covered by the comment on ~IImu — one comment documents this run of special members.

function, declared at include/shulib/hal/imu.hpp:32.

IImu::operator=

IImu& operator=(const IImu&) = default

Covered by the comment on ~IImu — one comment documents this run of special members.

function, declared at include/shulib/hal/imu.hpp:33.

IImu::operator= (overload 2)

IImu& operator=(IImu&&) = default

Covered by the comment on ~IImu — one comment documents this run of special members.

function, declared at include/shulib/hal/imu.hpp:34.

IImu::heading

[[nodiscard]] virtual math::Angle heading() const = 0

Canonical field heading: CCW-positive, +X = 0, wrapped to (-π, π].

function, declared at include/shulib/hal/imu.hpp:37.

IImu::yawRate

[[nodiscard]] virtual units::AngularVelocity yawRate() const = 0

Canonical yaw rate (CCW-positive).

function, declared at include/shulib/hal/imu.hpp:40.

IImu::isReady

[[nodiscard]] virtual bool isReady() const = 0

True once the IMU is calibrated and its readings are trustworthy (false during boot calibration). POSITIVE polarity by convention — every HAL health predicate reads true = usable (cf. IGps::hasFix), so if (imu.isReady()) can never read backwards.

function, declared at include/shulib/hal/imu.hpp:45.

IImu::pitch

[[nodiscard]] virtual math::Angle pitch() const = 0

Chassis pitch, as a wrapped math::Angle, for tip detection. The word this library uses for a settled convention is deliberately NOT used here: unlike heading() (CCW-positive, +X = 0, and the adapter negates to get there), pitch's SIGN is unsettled — the PROS adapter passes the sensor's as-mounted sign through unnegated (open hardware assumption HA-110), so consume the MAGNITUDE until a bench measurement fixes it. This comment also used to be written to cover roll() as well, which the generator cannot do: it attached the text to pitch() alone and left roll() undocumented until roll() got its own.

function, declared at include/shulib/hal/imu.hpp:54.

IImu::roll

[[nodiscard]] virtual math::Angle roll() const = 0

Chassis roll, as a wrapped math::Angle. Unlike heading(), the SIGN is NOT yet a settled convention: the PROS adapter passes the sensor's as-mounted sign through unnegated (open hardware assumption HA-110), so consume the MAGNITUDE until a bench measurement fixes it. That is enough for the tip detection this exists for.

function, declared at include/shulib/hal/imu.hpp:59.

Design commentary, from the header

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 — 8 lines
 IImu — the inertial sensor behind the HAL, reporting in shulib's CANONICAL frame
 (the V5's clockwise/degrees convention is converted away in the hal/pros adapter
 via imu_conversion.hpp, so everything above this line is CCW-positive radians).

 heading() is the load-bearing < 1° quantity. yawRate() feeds the fused estimate.
 isCalibrating() gates trust at boot (readings are garbage until calibration ends).
 pitch()/roll() exist for tip detection (master plan M2).

Last updated 2026-08-15 — published from the main release branch, commit fa545ff. This site tracks releases, so between them it can lag the repository — that lag is deliberate, and it is what keeps the development log off the public site. For the current state of the code, see the repository.