Class BulkReads

java.lang.Object
com.crossbotics.ftchelper.hardware.BulkReads

public final class BulkReads extends Object
Makes sensor and encoder reads much faster with "bulk reads".

Without this, each encoder read is a separate message to the hub (about 2 ms each). With bulk reads, the first read in a loop gets everything from the hub in one message. This often doubles the loop speed.

Words used here: a "hub" is the Control Hub or Expansion Hub, the box the motors and sensors plug into (the SDK calls it a LynxModule). An "encoder" counts how far a motor has turned. The "cache" is the hub's saved copy of the last bulk read: reads use the saved copy until it is cleared, so they are fast but only as new as the last bulk read.


 // Easiest: one line in INIT. A new bulk read happens when you read any value a second time.
 BulkReads.auto(hardwareMap);

 // Fastest: you clear the cache yourself at the top of each loop.
 List<LynxModule> hubs = BulkReads.manual(hardwareMap);
 while (opModeIsActive()) {
     BulkReads.clear(hubs);
     ...
 }
 
Tutorial 06 (docs/tutorials/06-fast-clear-loop.md) shows this in a full program. Docs: docs/modules/hardware.md
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<com.qualcomm.hardware.lynx.LynxModule>
    auto(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap)
    Turns on AUTO bulk reads on every hub.
    static void
    clear(List<com.qualcomm.hardware.lynx.LynxModule> hubs)
    Clears the cached readings so the next read gets new values.
    static List<com.qualcomm.hardware.lynx.LynxModule>
    manual(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap)
    Turns on MANUAL bulk reads on every hub.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait