CTRE Phoenix 6 C++ 26.0.0-beta-1
Loading...
Searching...
No Matches
ctre::phoenix6::SignalLogger Class Reference

Static class for controlling the Phoenix 6 signal logger. More...

#include <ctre/phoenix6/SignalLogger.hpp>

Static Public Member Functions

static ctre::phoenix::StatusCode SetPath (const char *path)
 Sets the destination for logging, restarting logger if the path changed.
 
static ctre::phoenix::StatusCode Start ()
 Starts logging status signals.
 
static ctre::phoenix::StatusCode Stop ()
 Stops logging status signals.
 
static ctre::phoenix::StatusCode EnableAutoLogging (bool enable)
 Enables or disables auto logging.
 
static ctre::phoenix::StatusCode AddSchema (std::string_view name, HootSchemaType type, std::span< uint8_t const > schema)
 Adds the schema to the log file.
 
static ctre::phoenix::StatusCode AddSchema (std::string_view name, HootSchemaType type, std::string_view schema)
 Adds the schema to the log file.
 
static bool HasSchema (std::string_view name, HootSchemaType type)
 Checks if the schema has already been added to the log files.
 
static ctre::phoenix::StatusCode WriteSchemaValue (std::string_view name, std::string_view schema, HootSchemaType type, std::span< uint8_t const > data, units::time::second_t latencySeconds=0_s)
 Writes the schema-serialized bytes to the log file.
 
template<typename T , typename... I>
requires wpi::StructSerializable<T, I...>
static ctre::phoenix::StatusCode WriteStruct (std::string_view name, T const &value, I const &... info, units::time::second_t latencySeconds=0_s)
 Writes the WPILib Struct to the log file.
 
template<typename T , typename... I>
requires wpi::StructSerializable<T, I...>
static ctre::phoenix::StatusCode WriteStructArray (std::string_view name, std::span< T const > values, I const &... info, units::time::second_t latencySeconds=0_s)
 Writes the array of WPILib Structs to the log file.
 
template<wpi::ProtobufSerializable T>
static ctre::phoenix::StatusCode WriteProtobuf (std::string_view name, T const &value, units::time::second_t latencySeconds=0_s)
 Writes the protobuf to the log file.
 
static ctre::phoenix::StatusCode WriteRaw (std::string_view name, std::span< uint8_t const > data, units::time::second_t latencySeconds=0_s)
 Writes the raw data bytes to the log file.
 
static ctre::phoenix::StatusCode WriteBoolean (std::string_view name, bool value, units::time::second_t latencySeconds=0_s)
 Writes the boolean to the log file.
 
static ctre::phoenix::StatusCode WriteInteger (std::string_view name, int64_t value, std::string_view units="", units::time::second_t latencySeconds=0_s)
 Writes the integer to the log file.
 
static ctre::phoenix::StatusCode WriteFloat (std::string_view name, float value, std::string_view units="", units::time::second_t latencySeconds=0_s)
 Writes the float to the log file.
 
static ctre::phoenix::StatusCode WriteDouble (std::string_view name, double value, std::string_view units="", units::time::second_t latencySeconds=0_s)
 Writes the double to the log file.
 
static ctre::phoenix::StatusCode WriteString (std::string_view name, std::string_view value, units::time::second_t latencySeconds=0_s)
 Writes the string to the log file.
 
template<typename U >
requires units::traits::is_unit_t_v<U>
static ctre::phoenix::StatusCode WriteValue (std::string_view name, U value, units::time::second_t latencySeconds=0_s)
 Writes the unit value to the log file.
 
static ctre::phoenix::StatusCode WriteBooleanArray (std::string_view name, std::span< bool const > values, units::time::second_t latencySeconds=0_s)
 Writes the array of booleans to the log file.
 
static ctre::phoenix::StatusCode WriteBooleanArray (std::string_view name, std::span< uint8_t const > values, units::time::second_t latencySeconds=0_s)
 Writes the array of booleans to the log file.
 
static ctre::phoenix::StatusCode WriteIntegerArray (std::string_view name, std::span< int64_t const > values, std::string_view units="", units::time::second_t latencySeconds=0_s)
 Writes the array of integers to the log file.
 
static ctre::phoenix::StatusCode WriteFloatArray (std::string_view name, std::span< float const > values, std::string_view units="", units::time::second_t latencySeconds=0_s)
 Writes the array of floats to the log file.
 
static ctre::phoenix::StatusCode WriteDoubleArray (std::string_view name, std::span< double const > values, std::string_view units="", units::time::second_t latencySeconds=0_s)
 Writes the array of doubles to the log file.
 
static ctre::phoenix::StatusCode WriteStringArray (std::string_view name, std::span< std::string_view const > values, units::time::second_t latencySeconds=0_s)
 Writes the array of strings to the log file.
 
static ctre::phoenix::StatusCode WriteStringArray (std::string_view name, std::span< std::string const > values, units::time::second_t latencySeconds=0_s)
 Writes the array of strings to the log file.
 

Detailed Description

Static class for controlling the Phoenix 6 signal logger.

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.

Member Function Documentation

◆ AddSchema() [1/2]

static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::AddSchema ( std::string_view name,
HootSchemaType type,
std::span< uint8_t const > schema )
static

Adds the schema to the log file.

In an FRC robot program, users can call WriteStruct and WriteProtobuf 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
nameName of the schema
typeType of the schema, such as struct or protobuf
schemaSchema bytes to write
Returns
Status of adding the schema

◆ AddSchema() [2/2]

static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::AddSchema ( std::string_view name,
HootSchemaType type,
std::string_view schema )
inlinestatic

Adds the schema to the log file.

In an FRC robot program, users can call WriteStruct and WriteProtobuf 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
nameName of the schema
typeType of the schema, such as struct or protobuf
schemaSchema string to write
Returns
Status of adding the schema

◆ EnableAutoLogging()

static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::EnableAutoLogging ( bool enable)
static

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), and the Driver Station is connected to the robot.

After auto logging has started the log once, logging will not be automatically stopped or restarted by auto logging.

Parameters
enableWhether to enable auto logging
Returns
Status of auto logging enable/disable

◆ HasSchema()

static bool ctre::phoenix6::SignalLogger::HasSchema ( std::string_view name,
HootSchemaType type )
static

Checks if the schema has already been added to the log files.

Parameters
nameName of the schema
typeType of the schema, such as struct or protobuf
Returns
Whether the schema has been added to the log files

◆ SetPath()

static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::SetPath ( const char * path)
static

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
pathFolder path for the log files; path must exist
Returns
Status of setting the path and restarting the log

◆ Start()

static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::Start ( )
static

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 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()

static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::Stop ( )
static

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

◆ WriteBoolean()

static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::WriteBoolean ( std::string_view name,
bool value,
units::time::second_t latencySeconds = 0_s )
inlinestatic

Writes the boolean to the log file.

Parameters
nameName of the signal
valueValue to write
latencySecondsLatency 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() [1/2]

static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::WriteBooleanArray ( std::string_view name,
std::span< bool const > values,
units::time::second_t latencySeconds = 0_s )
inlinestatic

Writes the array of booleans to the log file.

Parameters
nameName of the signal
valuesSpan of values to write
latencySecondsLatency 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() [2/2]

static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::WriteBooleanArray ( std::string_view name,
std::span< uint8_t const > values,
units::time::second_t latencySeconds = 0_s )
inlinestatic

Writes the array of booleans to the log file.

Parameters
nameName of the signal
valuesSpan of values to write, passed as a span of bytes
latencySecondsLatency 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()

static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::WriteDouble ( std::string_view name,
double value,
std::string_view units = "",
units::time::second_t latencySeconds = 0_s )
inlinestatic

Writes the double to the log file.

Parameters
nameName of the signal
valueValue to write
unitsUnits of the signal
latencySecondsLatency 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()

static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::WriteDoubleArray ( std::string_view name,
std::span< double const > values,
std::string_view units = "",
units::time::second_t latencySeconds = 0_s )
inlinestatic

Writes the array of doubles to the log file.

Parameters
nameName of the signal
valuesSpan of values to write
unitsUnits of the signals
latencySecondsLatency 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()

static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::WriteFloat ( std::string_view name,
float value,
std::string_view units = "",
units::time::second_t latencySeconds = 0_s )
inlinestatic

Writes the float to the log file.

Parameters
nameName of the signal
valueValue to write
unitsUnits of the signal
latencySecondsLatency 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()

static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::WriteFloatArray ( std::string_view name,
std::span< float const > values,
std::string_view units = "",
units::time::second_t latencySeconds = 0_s )
inlinestatic

Writes the array of floats to the log file.

Parameters
nameName of the signal
valuesSpan of values to write
unitsUnits of the signals
latencySecondsLatency 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()

static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::WriteInteger ( std::string_view name,
int64_t value,
std::string_view units = "",
units::time::second_t latencySeconds = 0_s )
inlinestatic

Writes the integer to the log file.

Parameters
nameName of the signal
valueValue to write
unitsUnits of the signal
latencySecondsLatency 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()

static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::WriteIntegerArray ( std::string_view name,
std::span< int64_t const > values,
std::string_view units = "",
units::time::second_t latencySeconds = 0_s )
inlinestatic

Writes the array of integers to the log file.

Parameters
nameName of the signal
valuesSpan of values to write
unitsUnits of the signals
latencySecondsLatency 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()

template<wpi::ProtobufSerializable T>
static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::WriteProtobuf ( std::string_view name,
T const & value,
units::time::second_t latencySeconds = 0_s )
inlinestatic

Writes the protobuf to the log file.

Parameters
nameName of the signal
valueValue to write
latencySecondsLatency 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()

static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::WriteRaw ( std::string_view name,
std::span< uint8_t const > data,
units::time::second_t latencySeconds = 0_s )
inlinestatic

Writes the raw data bytes to the log file.

Parameters
nameName of the signal
dataSpan of raw data bytes
latencySecondsLatency 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()

static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::WriteSchemaValue ( std::string_view name,
std::string_view schema,
HootSchemaType type,
std::span< uint8_t const > data,
units::time::second_t latencySeconds = 0_s )
inlinestatic

Writes the schema-serialized bytes to the log file.

In an FRC robot program, users can call WriteStruct, WriteStructArray, and WriteProtobuf 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 before calling this API.

Parameters
nameName of the signal
schemaName of the associated schema
typeType of the associated schema, such as struct or protobuf
dataSpan of serialized data bytes
latencySecondsLatency 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()

static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::WriteString ( std::string_view name,
std::string_view value,
units::time::second_t latencySeconds = 0_s )
inlinestatic

Writes the string to the log file.

Parameters
nameName of the signal
valueValue to write
latencySecondsLatency 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() [1/2]

static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::WriteStringArray ( std::string_view name,
std::span< std::string const > values,
units::time::second_t latencySeconds = 0_s )
inlinestatic

Writes the array of strings to the log file.

Parameters
nameName of the signal
valuesSpan of values to write
latencySecondsLatency 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() [2/2]

static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::WriteStringArray ( std::string_view name,
std::span< std::string_view const > values,
units::time::second_t latencySeconds = 0_s )
inlinestatic

Writes the array of strings to the log file.

Parameters
nameName of the signal
valuesSpan of values to write
latencySecondsLatency 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()

template<typename T , typename... I>
requires wpi::StructSerializable<T, I...>
static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::WriteStruct ( std::string_view name,
T const & value,
I const &... info,
units::time::second_t latencySeconds = 0_s )
inlinestatic

Writes the WPILib Struct to the log file.

Parameters
nameName of the signal
valueValue to write
infoOptional struct type info
latencySecondsLatency 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()

template<typename T , typename... I>
requires wpi::StructSerializable<T, I...>
static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::WriteStructArray ( std::string_view name,
std::span< T const > values,
I const &... info,
units::time::second_t latencySeconds = 0_s )
inlinestatic

Writes the array of WPILib Structs to the log file.

Parameters
nameName of the signal
valuesValues to write
infoOptional struct type info
latencySecondsLatency 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()

template<typename U >
requires units::traits::is_unit_t_v<U>
static ctre::phoenix::StatusCode ctre::phoenix6::SignalLogger::WriteValue ( std::string_view name,
U value,
units::time::second_t latencySeconds = 0_s )
inlinestatic

Writes the unit value to the log file.

Parameters
nameName of the signal
valueValue to write
latencySecondsLatency 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

The documentation for this class was generated from the following file: