Class SignalLogger
This logs all the signals from the CAN buses into .hoot files. Each file name starts with the CANivore serial number or "rio" for the roboRIO CAN bus, followed by the timestamp. In the header of a hoot file, the CANivore name and firmware version are logged in plain text.
During an FRC match, the log file will be renamed to include the event name, match type, and match number at the start of the file name. The match type will be 'P' for practice matches, 'Q' for qualification matches, and 'E' for elimination matches.
During Hoot Replay, the signal logger always runs while replay is running. All custom signals
written during replay will be automatically placed under hoot_replay/. Additionally,
the log will contain all status signals and custom signals from the original log.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StatusCodeaddSchema(String name, HootSchemaType type, byte[] schema) Adds the schema to the log file.static StatusCodeaddSchema(String name, HootSchemaType type, String schema) Adds the schema to the log file.static StatusCodeenableAutoLogging(boolean enable) Enables or disables auto logging.static booleanhasSchema(String name, HootSchemaType type) Checks if the schema has already been added to the log files.static StatusCodeSets the destination for logging, restarting logger if the path changed.static StatusCodestart()Starts logging status signals.static StatusCodestop()Stops logging status signals.static StatusCodewriteBoolean(String name, boolean value) Writes the boolean to the log file.static StatusCodewriteBoolean(String name, boolean value, double latencySeconds) Writes the boolean to the log file.static StatusCodewriteBooleanArray(String name, boolean[] values) Writes the array of booleans to the log file.static StatusCodewriteBooleanArray(String name, boolean[] values, double latencySeconds) Writes the array of booleans to the log file.static StatusCodewriteDouble(String name, double value) Writes the double to the log file.static StatusCodewriteDouble(String name, double value, String units) Writes the double to the log file.static StatusCodewriteDouble(String name, double value, String units, double latencySeconds) Writes the double to the log file.static StatusCodewriteDoubleArray(String name, double[] values) Writes the array of doubles to the log file.static StatusCodewriteDoubleArray(String name, double[] values, String units) Writes the array of doubles to the log file.static StatusCodewriteDoubleArray(String name, double[] values, String units, double latencySeconds) Writes the array of doubles to the log file.static StatusCodewriteFloat(String name, float value) Writes the float to the log file.static StatusCodewriteFloat(String name, float value, String units) Writes the float to the log file.static StatusCodewriteFloat(String name, float value, String units, double latencySeconds) Writes the float to the log file.static StatusCodewriteFloatArray(String name, float[] values) Writes the array of floats to the log file.static StatusCodewriteFloatArray(String name, float[] values, String units) Writes the array of floats to the log file.static StatusCodewriteFloatArray(String name, float[] values, String units, double latencySeconds) Writes the array of floats to the log file.static StatusCodewriteInteger(String name, long value) Writes the integer to the log file.static StatusCodewriteInteger(String name, long value, String units) Writes the integer to the log file.static StatusCodewriteInteger(String name, long value, String units, double latencySeconds) Writes the integer to the log file.static StatusCodewriteIntegerArray(String name, long[] values) Writes the array of integers to the log file.static StatusCodewriteIntegerArray(String name, long[] values, String units) Writes the array of integers to the log file.static StatusCodewriteIntegerArray(String name, long[] values, String units, double latencySeconds) Writes the array of integers to the log file.static <T> StatusCodewriteProtobuf(String name, Protobuf<T, ?> proto, T value) Writes the protobuf to the log file.static <T> StatusCodewriteProtobuf(String name, Protobuf<T, ?> proto, T value, double latencySeconds) Writes the protobuf to the log file.static StatusCodeWrites the raw data bytes to the log file.static StatusCodeWrites the raw data bytes to the log file.static StatusCodewriteSchemaValue(String name, String schema, HootSchemaType type, byte[] data) Writes the schema-serialized bytes to the log file.static StatusCodewriteSchemaValue(String name, String schema, HootSchemaType type, byte[] data, double latencySeconds) Writes the schema-serialized bytes to the log file.static StatusCodewriteSchemaValue(String name, String schema, HootSchemaType type, ByteBuffer data) Writes the schema-serialized buffer to the log file.static StatusCodewriteSchemaValue(String name, String schema, HootSchemaType type, ByteBuffer data, double latencySeconds) Writes the schema-serialized buffer to the log file.static StatusCodewriteString(String name, String value) Writes the string to the log file.static StatusCodewriteString(String name, String value, double latencySeconds) Writes the string to the log file.static StatusCodewriteStringArray(String name, String[] values) Writes the array of strings to the log file.static StatusCodewriteStringArray(String name, String[] values, double latencySeconds) Writes the array of strings to the log file.static <T> StatusCodewriteStruct(String name, Struct<T> struct, T value) Writes the WPILib Struct to the log file.static <T> StatusCodewriteStruct(String name, Struct<T> struct, T value, double latencySeconds) Writes the WPILib Struct to the log file.static <T> StatusCodewriteStructArray(String name, Struct<T> struct, T[] values) Writes the array of WPILib Structs to the log file.static <T> StatusCodewriteStructArray(String name, Struct<T> struct, T[] values, double latencySeconds) Writes the array of WPILib Structs to the log file.static StatusCodewriteValue(String name, Measure<?> value) Writes the unit value to the log file.static StatusCodewriteValue(String name, Measure<?> value, double latencySeconds) Writes the unit value to the log file.static <U extends Unit>
StatusCodewriteValue(String name, Measure<U> value, U units) Writes the unit value to the log file in the given units.static <U extends Unit>
StatusCodewriteValue(String name, Measure<U> value, U units, double latencySeconds) Writes the unit value to the log file in the given units.
-
Constructor Details
-
SignalLogger
public SignalLogger()
-
-
Method Details
-
setPath
Sets the destination for logging, restarting logger if the path changed.If this is not called or the path is left empty, the default path will be used. The default path on the roboRIO is a logs folder on the first USB flash drive found, or /home/lvuser/logs if none is available. The default path on all other platforms is a logs folder in the current working directory.
Typical use for this routine is to use a removable USB flash drive for logging.
This is ignored during Hoot Replay, where the hoot log will always be written to a subfolder next to the log being replayed.
- Parameters:
path- Folder path for the log files; path must exist- Returns:
- Status of setting the path and restarting the log
-
start
Starts logging status signals. Starts regardless of auto logging status.If using a roboRIO 1, we recommend setting the logging path to an external drive using
setPath(java.lang.String)to avoid running out of internal storage space.This is ignored during Hoot Replay, where logging is automatically started when Hoot Replay starts running or restarts.
- Returns:
- Status of starting the logger
-
stop
Stops logging status signals. Stops regardless of auto logging status.This is ignored during Hoot Replay, where logging is automatically stopped when Hoot Replay is stopped or reaches the end of the file.
- Returns:
- Status of stopping the logger
-
enableAutoLogging
Enables or disables auto logging.Auto logging is only supported on the roboRIO. Additionally, on a roboRIO 1, auto logging will only be active if a USB flash drive is present.
When auto logging is enabled, logging is started by any of the following (whichever occurs first):
- The robot is enabled.
- It has been at least 5 seconds since program startup (allowing for calls
to
setPath(java.lang.String)), and the Driver Station is connected to the robot.
- Parameters:
enable- Whether to enable auto logging- Returns:
- Status of auto logging enable/disable
-
addSchema
Adds the schema to the log file.Users can call
writeStruct(java.lang.String, edu.wpi.first.util.struct.Struct<T>, T),writeStructArray(java.lang.String, edu.wpi.first.util.struct.Struct<T>, T[]), andwriteProtobuf(java.lang.String, edu.wpi.first.util.protobuf.Protobuf<T, ?>, T)to directly write schema values instead.The schema name should typically exactly match the name of the type (without any extra prefix or suffix).
For protobuf, first register all relevant file descriptors by file name (such as "geometry2d.proto"). Then, for each top-level type being used, add a separate empty schema with the full name of the type (such as "wpi.proto.ProtobufPose2d").
- Parameters:
name- Name of the schematype- Type of the schema, such as struct or protobufschema- Schema bytes to write- Returns:
- Status of adding the schema
-
addSchema
Adds the schema to the log file.Users can call
writeStruct(java.lang.String, edu.wpi.first.util.struct.Struct<T>, T),writeStructArray(java.lang.String, edu.wpi.first.util.struct.Struct<T>, T[]), andwriteProtobuf(java.lang.String, edu.wpi.first.util.protobuf.Protobuf<T, ?>, T)to directly write schema values instead.The schema name should typically exactly match the name of the type (without any extra prefix or suffix).
For protobuf, first register all relevant file descriptors by file name (such as "geometry2d.proto"). Then, for each top-level type being used, add a separate empty schema with the full name of the type (such as "wpi.proto.ProtobufPose2d").
- Parameters:
name- Name of the schematype- Type of the schema, such as struct or protobufschema- Schema string to write- Returns:
- Status of adding the schema
-
hasSchema
Checks if the schema has already been added to the log files.- Parameters:
name- Name of the schematype- Type of the schema, such as struct or protobuf- Returns:
- Whether the schema has been added to the log files
-
writeSchemaValue
public static StatusCode writeSchemaValue(String name, String schema, HootSchemaType type, byte[] data) Writes the schema-serialized bytes to the log file.Users can call
writeStruct(java.lang.String, edu.wpi.first.util.struct.Struct<T>, T),writeStructArray(java.lang.String, edu.wpi.first.util.struct.Struct<T>, T[]), andwriteProtobuf(java.lang.String, edu.wpi.first.util.protobuf.Protobuf<T, ?>, T)to directly write schema values instead.The name of the associated schema must exactly match the type of the data (such as "Pose2d" or "wpi.proto.ProtobufPose2d"). Additionally, the schema name must be registered with
addSchema(java.lang.String, com.ctre.phoenix6.HootSchemaType, byte[])before calling this API.- Parameters:
name- Name of the signalschema- Name of the associated schematype- Type of the associated schema, such as struct or protobufdata- Serialized data bytes- Returns:
- Status of writing the data
-
writeSchemaValue
public static StatusCode writeSchemaValue(String name, String schema, HootSchemaType type, byte[] data, double latencySeconds) Writes the schema-serialized bytes to the log file.Users can call
writeStruct(java.lang.String, edu.wpi.first.util.struct.Struct<T>, T),writeStructArray(java.lang.String, edu.wpi.first.util.struct.Struct<T>, T[]), andwriteProtobuf(java.lang.String, edu.wpi.first.util.protobuf.Protobuf<T, ?>, T)to directly write schema values instead.The name of the associated schema must exactly match the type of the data (such as "Pose2d" or "wpi.proto.ProtobufPose2d"). Additionally, the schema name must be registered with
addSchema(java.lang.String, com.ctre.phoenix6.HootSchemaType, byte[])before calling this API.- Parameters:
name- Name of the signalschema- Name of the associated schematype- Type of the associated schema, such as struct or protobufdata- Serialized data byteslatencySeconds- Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log- Returns:
- Status of writing the data
-
writeSchemaValue
public static StatusCode writeSchemaValue(String name, String schema, HootSchemaType type, ByteBuffer data) Writes the schema-serialized buffer to the log file.Users can call
writeStruct(java.lang.String, edu.wpi.first.util.struct.Struct<T>, T),writeStructArray(java.lang.String, edu.wpi.first.util.struct.Struct<T>, T[]), andwriteProtobuf(java.lang.String, edu.wpi.first.util.protobuf.Protobuf<T, ?>, T)to directly write schema values instead.The name of the associated schema must exactly match the type of the data (such as "Pose2d" or "wpi.proto.ProtobufPose2d"). Additionally, the schema name must be registered with
addSchema(java.lang.String, com.ctre.phoenix6.HootSchemaType, byte[])before calling this API.- Parameters:
name- Name of the signalschema- Name of the associated schematype- Type of the associated schema, such as struct or protobufdata- Serialized data buffer, where [0, data.position()) will be written- Returns:
- Status of writing the data
-
writeSchemaValue
public static StatusCode writeSchemaValue(String name, String schema, HootSchemaType type, ByteBuffer data, double latencySeconds) Writes the schema-serialized buffer to the log file.Users can call
writeStruct(java.lang.String, edu.wpi.first.util.struct.Struct<T>, T),writeStructArray(java.lang.String, edu.wpi.first.util.struct.Struct<T>, T[]), andwriteProtobuf(java.lang.String, edu.wpi.first.util.protobuf.Protobuf<T, ?>, T)to directly write schema values instead.The name of the associated schema must exactly match the type of the data (such as "Pose2d" or "wpi.proto.ProtobufPose2d"). Additionally, the schema name must be registered with
addSchema(java.lang.String, com.ctre.phoenix6.HootSchemaType, byte[])before calling this API.- Parameters:
name- Name of the signalschema- Name of the associated schematype- Type of the associated schema, such as struct or protobufdata- Serialized data buffer, where [0, data.position()) will be writtenlatencySeconds- Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log- Returns:
- Status of writing the data
-
writeStruct
Writes the WPILib Struct to the log file.- Parameters:
name- Name of the signalstruct- Struct serialization implementationvalue- Value to write- Returns:
- Status of writing the data
-
writeStruct
public static <T> StatusCode writeStruct(String name, Struct<T> struct, T value, double latencySeconds) Writes the WPILib Struct to the log file.- Parameters:
name- Name of the signalstruct- Struct serialization implementationvalue- Value to writelatencySeconds- Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log- Returns:
- Status of writing the data
-
writeStructArray
Writes the array of WPILib Structs to the log file.- Parameters:
name- Name of the signalstruct- Struct serialization implementationvalues- Values to write- Returns:
- Status of writing the data
-
writeStructArray
public static <T> StatusCode writeStructArray(String name, Struct<T> struct, T[] values, double latencySeconds) Writes the array of WPILib Structs to the log file.- Parameters:
name- Name of the signalstruct- Struct serialization implementationvalues- Values to writelatencySeconds- Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log- Returns:
- Status of writing the data
-
writeProtobuf
Writes the protobuf to the log file.- Parameters:
name- Name of the signalproto- Protobuf serialization implementationvalue- Value to write- Returns:
- Status of writing the data
-
writeProtobuf
public static <T> StatusCode writeProtobuf(String name, Protobuf<T, ?> proto, T value, double latencySeconds) Writes the protobuf to the log file.- Parameters:
name- Name of the signalproto- Protobuf serialization implementationvalue- Value to writelatencySeconds- Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log- Returns:
- Status of writing the data
-
writeRaw
Writes the raw data bytes to the log file.- Parameters:
name- Name of the signaldata- Raw data bytes- Returns:
- Status of writing the data
-
writeRaw
Writes the raw data bytes to the log file.- Parameters:
name- Name of the signaldata- Raw data byteslatencySeconds- Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log- Returns:
- Status of writing the data
-
writeBoolean
Writes the boolean to the log file.- Parameters:
name- Name of the signalvalue- Value to write- Returns:
- Status of writing the data
-
writeBoolean
Writes the boolean to the log file.- Parameters:
name- Name of the signalvalue- Value to writelatencySeconds- Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log- Returns:
- Status of writing the data
-
writeInteger
Writes the integer to the log file.- Parameters:
name- Name of the signalvalue- Value to write- Returns:
- Status of writing the data
-
writeInteger
Writes the integer to the log file.- Parameters:
name- Name of the signalvalue- Value to writeunits- Units of the signal- Returns:
- Status of writing the data
-
writeInteger
Writes the integer to the log file.- Parameters:
name- Name of the signalvalue- Value to writeunits- Units of the signallatencySeconds- Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log- Returns:
- Status of writing the data
-
writeFloat
Writes the float to the log file.- Parameters:
name- Name of the signalvalue- Value to write- Returns:
- Status of writing the data
-
writeFloat
Writes the float to the log file.- Parameters:
name- Name of the signalvalue- Value to writeunits- Units of the signal- Returns:
- Status of writing the data
-
writeFloat
Writes the float to the log file.- Parameters:
name- Name of the signalvalue- Value to writeunits- Units of the signallatencySeconds- Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log- Returns:
- Status of writing the data
-
writeDouble
Writes the double to the log file.- Parameters:
name- Name of the signalvalue- Value to write- Returns:
- Status of writing the data
-
writeDouble
Writes the double to the log file.- Parameters:
name- Name of the signalvalue- Value to writeunits- Units of the signal- Returns:
- Status of writing the data
-
writeDouble
public static StatusCode writeDouble(String name, double value, String units, double latencySeconds) Writes the double to the log file.- Parameters:
name- Name of the signalvalue- Value to writeunits- Units of the signallatencySeconds- Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log- Returns:
- Status of writing the data
-
writeString
Writes the string to the log file.- Parameters:
name- Name of the signalvalue- Value to write- Returns:
- Status of writing the data
-
writeString
Writes the string to the log file.- Parameters:
name- Name of the signalvalue- Value to writelatencySeconds- Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log- Returns:
- Status of writing the data
-
writeValue
Writes the unit value to the log file.- Parameters:
name- Name of the signalvalue- Value to write- Returns:
- Status of writing the data
-
writeValue
Writes the unit value to the log file.- Parameters:
name- Name of the signalvalue- Value to writelatencySeconds- Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log- Returns:
- Status of writing the data
-
writeValue
Writes the unit value to the log file in the given units.- Parameters:
name- Name of the signalvalue- Value to writeunits- Units to use for logging the measure- Returns:
- Status of writing the data
-
writeValue
public static <U extends Unit> StatusCode writeValue(String name, Measure<U> value, U units, double latencySeconds) Writes the unit value to the log file in the given units.- Parameters:
name- Name of the signalvalue- Value to writeunits- Units to use for logging the measurelatencySeconds- Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log- Returns:
- Status of writing the data
-
writeBooleanArray
Writes the array of booleans to the log file.- Parameters:
name- Name of the signalvalues- Array of values to write- Returns:
- Status of writing the data
-
writeBooleanArray
Writes the array of booleans to the log file.- Parameters:
name- Name of the signalvalues- Array of values to writelatencySeconds- Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log- Returns:
- Status of writing the data
-
writeIntegerArray
Writes the array of integers to the log file.- Parameters:
name- Name of the signalvalues- Array of values to write- Returns:
- Status of writing the data
-
writeIntegerArray
Writes the array of integers to the log file.- Parameters:
name- Name of the signalvalues- Array of values to writeunits- Units of the signals- Returns:
- Status of writing the data
-
writeIntegerArray
public static StatusCode writeIntegerArray(String name, long[] values, String units, double latencySeconds) Writes the array of integers to the log file.- Parameters:
name- Name of the signalvalues- Array of values to writeunits- Units of the signalslatencySeconds- Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log- Returns:
- Status of writing the data
-
writeFloatArray
Writes the array of floats to the log file.- Parameters:
name- Name of the signalvalues- Array of values to write- Returns:
- Status of writing the data
-
writeFloatArray
Writes the array of floats to the log file.- Parameters:
name- Name of the signalvalues- Array of values to writeunits- Units of the signals- Returns:
- Status of writing the data
-
writeFloatArray
public static StatusCode writeFloatArray(String name, float[] values, String units, double latencySeconds) Writes the array of floats to the log file.- Parameters:
name- Name of the signalvalues- Array of values to writeunits- Units of the signalslatencySeconds- Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log- Returns:
- Status of writing the data
-
writeDoubleArray
Writes the array of doubles to the log file.- Parameters:
name- Name of the signalvalues- Array of values to write- Returns:
- Status of writing the data
-
writeDoubleArray
Writes the array of doubles to the log file.- Parameters:
name- Name of the signalvalues- Array of values to writeunits- Units of the signals- Returns:
- Status of writing the data
-
writeDoubleArray
public static StatusCode writeDoubleArray(String name, double[] values, String units, double latencySeconds) Writes the array of doubles to the log file.- Parameters:
name- Name of the signalvalues- Array of values to writeunits- Units of the signalslatencySeconds- Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log- Returns:
- Status of writing the data
-
writeStringArray
Writes the array of strings to the log file.- Parameters:
name- Name of the signalvalues- Array of values to write- Returns:
- Status of writing the data
-
writeStringArray
Writes the array of strings to the log file.- Parameters:
name- Name of the signalvalues- Array of values to writelatencySeconds- Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log- Returns:
- Status of writing the data
-