Class Utils

java.lang.Object
com.ctre.phoenix6.Utils

public class Utils extends Object
  • Constructor Details

  • Method Details

    • getCurrentTimeSeconds

      public static double getCurrentTimeSeconds()
      Get the current timestamp in seconds.

      This is the time source used for status signals.

      This time source is typically continuous and monotonic. However, it may be overridden in simulation to use a non-monotonic, non-continuous source.

      Returns:
      Current time in seconds
    • getSystemTimeSeconds

      public static double getSystemTimeSeconds()
      Get the system timestamp in seconds.

      This is NOT the time source used for status signals. Use GetCurrentTImeSeconds instead when working with status signal timing.

      This time source is guaranteed to be continuous and monotonic, making it useful for measuring time deltas in a robot program.

      Returns:
      System time in seconds
    • isSimulation

      public static boolean isSimulation()
      Get whether the program is running in simulation.
      Returns:
      true if in simulation
    • isReplay

      public static boolean isReplay()
      Get whether the program is running in replay mode.
      Returns:
      true if in replay mode
    • fpgaToCurrentTime

      public static double fpgaToCurrentTime(double fpgaTimeSeconds)
      Converts an FPGA timestamp to the timebase reported by getCurrentTimeSeconds().
      Parameters:
      fpgaTimeSeconds - The FPGA timestamp in seconds
      Returns:
      The equivalent getCurrentTimeSeconds() timestamp in seconds