Motor Caching
Motor Caching is a performance optimization feature in CoreControl. It reduces the number of unnecessary hardware write operations, which can significantly improve loop times, especially when using many motors or servos.
Overview
Section titled “Overview”In the FTC SDK, every time you set a motor’s power or a servo’s position, a command is sent to the hardware controller (Control Hub or Expansion Hub). This communication takes time. If you set the same power value repeatedly in a loop (e.g., motor.power = 1.0 every loop), you are wasting valuable time sending redundant commands.
CoreControl provides extension properties (cachingPower, cachingPosition) that check the current value before writing a new one. If the new value is effectively the same as the current one (within a small tolerance), the write operation is skipped.
Simply replace .power with .cachingPower and .position with .cachingPosition in your code.
// Instead of this:motor.power = 1.0servo.position = 0.5
// Use this:motor.cachingPower = 1.0servo.cachingPosition = 0.5// Instead of this:motor.setPower(1.0);servo.setPosition(0.5);
// Use this:Caching.setCachingPower(motor, 1.0);Caching.setCachingPosition(servo, 0.5);API Reference
Section titled “API Reference”DcMotor / DcMotorEx
Section titled “DcMotor / DcMotorEx”Extension Property: cachingPower
- Type:
Double - Behavior: Writes to
poweronly if the new value differs from the current value by more than0.009. Always writes if the new value is exactly0.0.
Extension Property: cachingPosition
- Type:
Double - Behavior: Writes to
positiononly if the new value differs from the current value by more than0.0009.
CRServo
Section titled “CRServo”Extension Property: cachingPower
- Type:
Double - Behavior: Writes to
poweronly if the new value differs from the current value by more than0.009. Always writes if the new value is exactly0.0.