Skip to content

rotation_conversion.hpp

Rotation-sensor canonical conversions — the ONE place the V5 rotation sensor's centidegrees become shulib's canonical radians (§7: "convert exactly once, at the edge").

This header declares 2 free functions.

Extracted from include/shulib/hal/rotation_conversion.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

rotationCentidegToCanonical

[[nodiscard]] inline units::AngleDim rotationCentidegToCanonical(double centidegrees)

Cumulative centidegrees (get_position(), HA-11/HA-16) → canonical cumulative radians. Deliberately NOT math::Angle: odometry integrates total tracking-wheel travel, so this must never wrap (rotation.hpp:8-9). π/18000 because 1 centidegree = (1/100)° = (1/100)·(π/180) rad. Drop the scale and every tracking-wheel delta is 5730× — one inch of travel reads as 477 feet, and odometry is garbage from the first tick.

free function, declared at include/shulib/hal/rotation_conversion.hpp:35.

rotationCentidegPerSecToCanonical

[[nodiscard]] inline units::AngularVelocity rotationCentidegPerSecToCanonical( double centidegPerSec)

Centidegrees-per-second (get_velocity(), HA-105) → canonical rad/s. Same scale as position — one factor, one place.

free function, declared at include/shulib/hal/rotation_conversion.hpp:44.

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 — 18 lines
 Rotation-sensor canonical conversions — the ONE place the V5 rotation sensor's
 centidegrees become shulib's canonical radians (§7: "convert exactly once, at
 the edge"). Pure, PROS-free, host- and mutation-testable in isolation; the
 hal/pros IRotation adapter is thin glue that CALLS these.

 V5 rotation sensor convention (vendored pros/rotation.hpp:195-242): both
 get_position() and get_velocity() are int32 CENTIDEGREES (position cumulative,
 never wrapping — HA-11; 36000 ticks/rev — HA-16; velocity in centideg/s —
 HA-105). The sensor's reversed flag is applied by PROS itself when the sensor
 is constructed on a NEGATIVE port (rotation.hpp:46-47) — that is the "exactly
 once" of rotation.hpp:4-6, and the adapter must NOT negate again on top.

 Sentinel note (T7): PROS_ERR (= INT32_MAX) is IN-BAND for an int32
 centidegree reading — 2147483647 centideg is ~59652 revolutions, unreachable
 in a match (HA-11's arithmetic) but perfectly finite. ONLY the adapter can
 screen it, BEFORE calling these. The conversions take double so the
 PROS_ERR_F backstop still works if a future float path appears.

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.