Class HootAutoReplay

java.lang.Object
com.ctre.phoenix6.HootAutoReplay

public class HootAutoReplay extends Object
Class for handling automatic logging and replay of custom signal inputs. Each subsystem typically creates a new instance of this class.

Note that all StatusSignals are automatically logged and replayed, so they do not need to be registered with this class. Additionally, the SignalLogger must be separately started at the start of the robot program.

"Inputs" are signals measured directly from devices that should be replayed unmodified. By comparison, a processed signal, such as a signal indicating that a mechanism has reached the target, is considered an "output". This class should only be used with inputs.

Inputs are registered with a getter that returns a value to log and a setter that updates the value in your robot program. For example, a Vision class with a Pose2d cameraPose input would register the input using:

 private final HootAutoReplay autoReplay = new HootAutoReplay()
   .withStruct(
     "Vision/CameraPose", Pose2d.struct,
     () -> cameraPose, val -> cameraPose = val.value
   );
 

After registering all relevant inputs, call update() periodically to perform the following:

  • In normal/simulated robot operation, registered inputs will be fetched from your robot code using the provided getter, and then logged using the SignalLogger.
  • During Hoot Replay, registered inputs will be fetched from HootReplay and then updated in your robot code using the provided setter.
  • Constructor Details

  • Method Details

    • update

      public final void update()
      Updates the state of the robot program by doing one of the following:
      • In normal/simulated robot operation, registered signals will be fetched from your robot code using the provided getter, and then logged using the SignalLogger.
      • During Hoot Replay, registered signals will be fetched from HootReplay and then updated in your robot code using the provided setter.
      This should be called periodically, typically in the subsystem.
    • withTimestampReplay

      Registers Timer.getTimestamp() time logging and playback with this instance. This should only be applied to one instance in the robot program.

      The update() of this HootAutoReplay instance must be run at the start of robotPeriodic() before the CommandScheduler is run.

      Returns:
      this object
    • withJoystickReplay

      Registers joystick logging and playback with this instance. This should only be applied to one instance in the robot program.

      To get joysticks to playback during Hoot Replay, "Turn off DS" must be checked in the simulation GUI (under "DS" at the top of the window). Additionally, the update() of this HootAutoReplay instance must be run at the start of robotPeriodic() before the CommandScheduler is run.

      Returns:
      this object
    • withSchemaValue

      public final HootAutoReplay withSchemaValue(String name, String schemaName, HootSchemaType type, byte[] schema, Supplier<byte[]> getter, Consumer<StatusSignal.SignalMeasurement<byte[]>> setter)
      Registers the schema-serialized bytes as a Hoot-Replayed input.
      Parameters:
      name - Name of the signal in the log
      schemaName - Name of the schema
      type - Type of the schema, such as struct or protobuf
      schema - Schema bytes to write
      getter - Function that returns the current value of the input
      setter - Function that sets the input to a new value
      Returns:
      this object
    • withSchemaValue

      public final HootAutoReplay withSchemaValue(String name, String schemaName, HootSchemaType type, String schema, Supplier<byte[]> getter, Consumer<StatusSignal.SignalMeasurement<byte[]>> setter)
      Registers the schema-serialized bytes as a Hoot-Replayed input.
      Parameters:
      name - Name of the signal in the log
      schemaName - Name of the schema
      type - Type of the schema, such as struct or protobuf
      schema - Schema string to write
      getter - Function that returns the current value of the input
      setter - Function that sets the input to a new value
      Returns:
      this object
    • withStruct

      public final <T> HootAutoReplay withStruct(String name, Struct<T> struct, Supplier<T> getter, Consumer<StatusSignal.SignalMeasurement<T>> setter)
      Registers the WPILib Struct as a Hoot-Replayed input.
      Parameters:
      name - Name of the signal in the log
      struct - Struct serialization implementation
      getter - Function that returns the current value of the input
      setter - Function that sets the input to a new value
      Returns:
      this object
    • withStructArray

      public final <T> HootAutoReplay withStructArray(String name, Struct<T> struct, Supplier<T[]> getter, Consumer<StatusSignal.SignalMeasurement<T[]>> setter)
      Registers the array of WPILib Structs as a Hoot-Replayed input.
      Parameters:
      name - Name of the signal in the log
      struct - Struct serialization implementation
      getter - Function that returns the current value of the input
      setter - Function that sets the input to a new value
      Returns:
      this object
    • withProtobuf

      public final <T> HootAutoReplay withProtobuf(String name, Protobuf<T,?> proto, Supplier<T> getter, Consumer<StatusSignal.SignalMeasurement<T>> setter)
      Registers the protobuf as a Hoot-Replayed input.
      Parameters:
      name - Name of the signal in the log
      proto - Protobuf serialization implementation
      getter - Function that returns the current value of the input
      setter - Function that sets the input to a new value
      Returns:
      this object
    • withRaw

      public final HootAutoReplay withRaw(String name, Supplier<byte[]> getter, Consumer<StatusSignal.SignalMeasurement<byte[]>> setter)
      Registers the raw data bytes as a Hoot-Replayed input.
      Parameters:
      name - Name of the signal in the log
      getter - Function that returns the current value of the input
      setter - Function that sets the input to a new value
      Returns:
      this object
    • withBoolean

      Registers the boolean as a Hoot-Replayed input.
      Parameters:
      name - Name of the signal in the log
      getter - Function that returns the current value of the input
      setter - Function that sets the input to a new value
      Returns:
      this object
    • withInteger

      Registers the integer as a Hoot-Replayed input.
      Parameters:
      name - Name of the signal in the log
      getter - Function that returns the current value of the input
      setter - Function that sets the input to a new value
      Returns:
      this object
    • withFloat

      Registers the float as a Hoot-Replayed input.
      Parameters:
      name - Name of the signal in the log
      getter - Function that returns the current value of the input
      setter - Function that sets the input to a new value
      Returns:
      this object
    • withDouble

      Registers the double as a Hoot-Replayed input.
      Parameters:
      name - Name of the signal in the log
      getter - Function that returns the current value of the input
      setter - Function that sets the input to a new value
      Returns:
      this object
    • withString

      Registers the string as a Hoot-Replayed input.
      Parameters:
      name - Name of the signal in the log
      getter - Function that returns the current value of the input
      setter - Function that sets the input to a new value
      Returns:
      this object
    • withValue

      public final <U extends Unit, MEAS extends Measure<U>> HootAutoReplay withValue(String name, U units, Supplier<MEAS> getter, Consumer<StatusSignal.SignalMeasurement<MEAS>> setter)
      Registers the unit value as a Hoot-Replayed input.
      Parameters:
      name - Name of the signal in the log
      units - Units to use for logging the measure
      getter - Function that returns the current value of the input
      setter - Function that sets the input to a new value
      Returns:
      this object
    • withBooleanArray

      public final HootAutoReplay withBooleanArray(String name, Supplier<boolean[]> getter, Consumer<StatusSignal.SignalMeasurement<boolean[]>> setter)
      Registers the array of booleans as a Hoot-Replayed input.
      Parameters:
      name - Name of the signal in the log
      getter - Function that returns the current value of the input
      setter - Function that sets the input to a new value
      Returns:
      this object
    • withIntegerArray

      public final HootAutoReplay withIntegerArray(String name, Supplier<long[]> getter, Consumer<StatusSignal.SignalMeasurement<long[]>> setter)
      Registers the array of integers as a Hoot-Replayed input.
      Parameters:
      name - Name of the signal in the log
      getter - Function that returns the current value of the input
      setter - Function that sets the input to a new value
      Returns:
      this object
    • withFloatArray

      public final HootAutoReplay withFloatArray(String name, Supplier<float[]> getter, Consumer<StatusSignal.SignalMeasurement<float[]>> setter)
      Registers the array of floats as a Hoot-Replayed input.
      Parameters:
      name - Name of the signal in the log
      getter - Function that returns the current value of the input
      setter - Function that sets the input to a new value
      Returns:
      this object
    • withDoubleArray

      public final HootAutoReplay withDoubleArray(String name, Supplier<double[]> getter, Consumer<StatusSignal.SignalMeasurement<double[]>> setter)
      Registers the array of doubles as a Hoot-Replayed input.
      Parameters:
      name - Name of the signal in the log
      getter - Function that returns the current value of the input
      setter - Function that sets the input to a new value
      Returns:
      this object
    • withStringArray

      Registers the array of strings as a Hoot-Replayed input.
      Parameters:
      name - Name of the signal in the log
      getter - Function that returns the current value of the input
      setter - Function that sets the input to a new value
      Returns:
      this object