IMU, Encoders, and Bulk Caching
Reliable motion feedback without slow loops.
Reliable motion feedback without slow loops.
In this lesson, you will:
Encoders and the IMU are how the robot remembers movement. Bulk caching is how the code reads many hub values without making every loop pay for each read separately.
A fast loop should have a rhythm: clear cache, read sensors, compute decisions, write hardware, update telemetry. Breaking that rhythm creates stale data or inconsistent timing.
Set hub caching to manual, clear it once near the start of each loop, then read heading and encoder values. Validate by pushing the robot and rotating it by hand before powered tests.
BulkCacheLoop.javaJava
for (LynxModule hub : hubs) hub.clearBulkCache();
double heading = imu.getRobotYawPitchRollAngles().getYaw(AngleUnit.RADIANS);
int ticks = frontLeft.getCurrentPosition();
telemetry.addData("heading rad", heading);
telemetry.addData("front left ticks", ticks);Wrong heading units, reversed encoder signs, and stale cached values all produce confident-looking but wrong data. Print raw values and move the robot slowly to verify signs.
Build a feedback dashboard that shows heading, drive encoder ticks, loop rate, and whether cache was cleared this loop.
Check your understanding before moving on.
0 of 2 answered