Class FtcPidCoeffCache

java.lang.Object
ftclib.robotcore.FtcPidCoeffCache

public class FtcPidCoeffCache extends Object
This class implements a PID Coefficient cache that write through to file storage on disk. The file format is simply an ASCII text file with four PID coefficient numbers (double numbers Kp, Ki, Kd and Kf) separated by commas. This class can be used for PID tuning where the tuning code can write the user input coefficients to a file so that they can be read back as tune PID menu default values in the next tuning sessions. Doing so will avoid the time consuming cycle of tune/modify value in code/recompile.
  • Field Details

  • Constructor Details

    • FtcPidCoeffCache

      public FtcPidCoeffCache(String cacheFolderPath)
      Constructor: Creates an instance of the object.
      Parameters:
      cacheFolderPath - specifies the cache file folder path.
  • Method Details

    • getCachedPidCoeff

      public TrcPidController.PidCoefficients getCachedPidCoeff(TrcPidController pidCtrl)
      This method returns the cached PID coefficients for the given PID controller. If the given PID controller has no cached PID coefficients, it will look for a cache file associated with the PID controller. The PID coefficients read will be put into the cache and returned. If no cache file found, the current PID coefficients for the PID controller is put into the cache and returned.
      Parameters:
      pidCtrl - specifies the PID controller for which to look for its cached PID coefficients.
      Returns:
      cached PID coefficients.
    • writeCachedPidCoeff

      public void writeCachedPidCoeff(TrcPidController pidCtrl, TrcPidController.PidCoefficients pidCoeff)
      This method writes the PID coefficients to the cache and also write through to the backing file storage.
      Parameters:
      pidCtrl - specifies the PID controller associated with the PID coefficients.
      pidCoeff - specifies the PID coefficients to write through into the cache.