phoenix6.signal_logger¶
Module Contents¶
Attributes¶
- phoenix6.signal_logger.USE_WPILIB = 'True'¶
- phoenix6.signal_logger.T¶
- class phoenix6.signal_logger.SignalLogger¶
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.
- static set_path(path: str) phoenix6.status_code.StatusCode¶
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 (str) – Folder path for the log files; path must exist
- Returns:
Status of setting the path and restarting the log
- Return type:
- static start() phoenix6.status_code.StatusCode¶
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 self.set_path 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
- Return type:
- static stop() phoenix6.status_code.StatusCode¶
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
- Return type:
- static enable_auto_logging(enable: bool) phoenix6.status_code.StatusCode¶
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 self.set_path), 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:
enable (bool) – Whether to enable auto logging
- Returns:
Status of auto logging enable/disable
- Return type:
- static add_schema(name: str, schema_type: phoenix6.hoot_schema_type.HootSchemaType, schema: bytes | str) phoenix6.status_code.StatusCode¶
Adds the schema to the log file.
In an FRC robot program, users can call self.write_struct and self.write_struct_array to directly write WPILib Struct 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 (str) – Name of the schema
schema_type (HootSchemaType) – Type of the schema, such as struct or protobuf
schema – Schema bytes or string to write
- Returns:
Status of adding the schema
- Return type:
- static has_schema(name: str, schema_type: phoenix6.hoot_schema_type.HootSchemaType) bool¶
Checks if the schema has already been added to the log files.
- Parameters:
name (str) – Name of the schema
schema_type (HootSchemaType) – Type of the schema, such as struct or protobuf
- Returns:
Whether the schema has been added to the log files
- Return type:
bool
- static write_schema_value(name: str, schema: str, schema_type: phoenix6.hoot_schema_type.HootSchemaType, data: bytes, latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode¶
Writes the schema-serialized bytes to the log file.
In an FRC robot program, users can call self.write_struct and self.write_struct_array to directly write WPILib Struct 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 self.add_schema before calling this API.
- Parameters:
name (str) – Name of the signal
schema (str) – Name of the associated schema
schema_type (HootSchemaType) – Type of the associated schema, such as struct or protobuf
data (bytes) – Serialized data bytes
latency_seconds (second) – 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
- Return type:
- classmethod write_struct(name: str, struct: type[T], value: T, latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode¶
Writes the WPILib Struct to the log file.
- Parameters:
name (str) – Name of the signal
struct (type[T]) – Type of struct to serialize
value (T) – Value to write
latency_seconds (second) – 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
- Return type:
- classmethod write_struct_array(name: str, struct: type[T], values: list[T], latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode¶
Writes the array of WPILib Structs to the log file.
- Parameters:
name (str) – Name of the signal
struct (type[T]) – Type of struct to serialize
values (list[T]) – Values to write
latency_seconds (second) – 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
- Return type:
- static write_raw(name: str, data: bytes, latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode¶
Writes the raw data bytes to the log file.
- Parameters:
name (str) – Name of the signal
data (bytes) – Raw data bytes
latency_seconds (second) – 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
- Return type:
- static write_boolean(name: str, value: bool, latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode¶
Writes the boolean to the log file.
- Parameters:
name (str) – Name of the signal
value – Value to write
latency_seconds (second) – 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
- Return type:
- static write_integer(name: str, value: int, units: str = '', latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode¶
Writes the integer to the log file.
- Parameters:
name (str) – Name of the signal
value – Value to write
units (str) – Units of the signal
latency_seconds (second) – 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
- Return type:
- static write_float(name: str, value: float, units: str = '', latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode¶
Writes the float to the log file.
- Parameters:
name (str) – Name of the signal
value – Value to write
units (str) – Units of the signal
latency_seconds (second) – 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
- Return type:
- static write_double(name: str, value: float, units: str = '', latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode¶
Writes the double to the log file.
- Parameters:
name (str) – Name of the signal
value – Value to write
units (str) – Units of the signal
latency_seconds (second) – 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
- Return type:
- static write_string(name: str, value: str, latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode¶
Writes the string to the log file.
- Parameters:
name (str) – Name of the signal
value – Value to write
latency_seconds (second) – 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
- Return type:
- static write_boolean_array(name: str, value: list[bool], latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode¶
Writes the array of booleans to the log file.
- Parameters:
name (str) – Name of the signal
value (list[bool]) – Array of values to write
latency_seconds (second) – 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
- Return type:
- static write_integer_array(name: str, value: list[int], units: str = '', latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode¶
Writes the array of integers to the log file.
- Parameters:
name (str) – Name of the signal
value (list[int]) – Array of values to write
units (str) – Units of the signal
latency_seconds (second) – 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
- Return type:
- static write_float_array(name: str, value: list[float], units: str = '', latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode¶
Writes the array of floats to the log file.
- Parameters:
name (str) – Name of the signal
value (list[float]) – Array of values to write
units (str) – Units of the signal
latency_seconds (second) – 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
- Return type:
- static write_double_array(name: str, value: list[float], units: str = '', latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode¶
Writes the array of doubles to the log file.
- Parameters:
name (str) – Name of the signal
value (list[float]) – Array of values to write
units (str) – Units of the signal
latency_seconds (second) – 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
- Return type:
- static write_string_array(name: str, value: list[str], latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode¶
Writes the array of strings to the log file.
- Parameters:
name (str) – Name of the signal
value (list[str]) – Array of values to write
latency_seconds (second) – 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
- Return type: