phoenix6.hoot_replay

Module Contents

Attributes

T

phoenix6.hoot_replay.T
class phoenix6.hoot_replay.HootReplay

Static class for controlling Phoenix 6 hoot log replay.

This replays the given hoot log in simulation. Hoot logs can be created by a robot program using SignalLogger. Only one hoot log, corresponding to one CAN bus, may be replayed at a time.

This replays all signals in the given hoot log in simulation. Hoot logs can be created by a robot program using SignalLogger. Only one hoot log, corresponding to one CAN bus, may be replayed at a time.

During replay, all transmits from the robot program are ignored. This includes features such as control requests, configs, and setting signal update frequency. Additionally, Tuner X is not functional during log replay.

To use Hoot Replay, call load_file(str) before any devices are constructed to load a hoot file and start replay. Alternatively, the CANBus(str, str) constructor can be used when constructing devices.

After devices are constructed, Hoot Replay can be controlled using play(), pause(), stop(), and restart(). Additionally, Hoot Replay supports step_timing(second) while paused. The current file can be closed using close_file(), after which a new file may be loaded.

class SignalData

Bases: Generic[T]

Stores information about a user signal from replay.

name: str = ''

The name of the signal

units: str = ''

The units of the signal

timestamp: phoenix6.units.second = 0

The timestamp of the signal, in seconds

status: phoenix6.status_code.StatusCode

Status code response of getting the signal

value: T

The value of the signal

static load_file(filepath: str) phoenix6.status_code.StatusCode

Loads the given file and starts signal log replay. Only one hoot log, corresponding to one CAN bus, may be replayed at a time.

This must be called before constructing any devices or checking CAN bus status. The CANBus(canbus, hoot_filepath) constructor can be used when constructing devices to guarantee that this API is called first.

When using relative paths, the file path is typically relative to the top-level folder of the robot project.

This API is blocking on the file read.

Parameters:

filepath (str) – Path and name of the hoot file to load

Returns:

Status of opening and reading the file for replay

Return type:

StatusCode

Raises:

ValueError – The file is invalid, unlicensed, or targets a different version of Phoenix 6

static close_file()

Ends the hoot log replay. This stops the replay if it is running, closes the hoot log, and clears all signals read from the file.

static is_file_loaded() bool

Gets whether a valid hoot log file is currently loaded.

Returns:

True if a valid hoot log file is loaded

Return type:

bool

static play() phoenix6.status_code.StatusCode

Starts or resumes the hoot log replay.

Returns:

Status of starting or resuming replay

Return type:

StatusCode

static pause() phoenix6.status_code.StatusCode

Pauses the hoot log replay. This maintains the current position in the log replay so it can be resumed later.

Returns:

Status of pausing replay

Return type:

StatusCode

static stop() phoenix6.status_code.StatusCode

Stops the hoot log replay. This resets the current position in the log replay to the start.

Returns:

Status of stopping replay

Return type:

StatusCode

classmethod restart() phoenix6.status_code.StatusCode

Restarts the hoot log replay from the start of the log. This is equivalent to calling stop() followed by play().

Returns:

Status of restarting replay

Return type:

StatusCode

classmethod is_playing() bool

Gets whether hoot log replay is actively playing.

This API will return true in programs that do not support replay, making it safe to call without first checking if the program supports replay.

Returns:

True if replay is playing back signals

Return type:

bool

static wait_for_playing(timeout: phoenix6.units.second) bool

Waits until hoot log replay is actively playing.

This API will immediately return true in programs that do not support replay, making it safe to call without first checking if the program supports replay.

Since this can block the calling thread, this should not be called with a non-zero timeout on the main thread.

This can also be used with a timeout of 0 to perform a non-blocking check, which is equivalent to is_playing().

Parameters:

timeout (second) – Max time to wait for replay to start playing

Returns:

True if replay is playing back signals

Return type:

bool

static set_speed(speed: float)

Sets the speed of the hoot log replay. A speed of 1.0 corresponds to replaying the file in real time, and larger values increase the speed.

  • Minimum Value: 0.01

  • Maximum Value: 100.0

  • Default Value: 1.0

Parameters:

speed (float) – Speed of the hoot log replay

static step_timing(step_time_seconds: phoenix6.units.second) phoenix6.status_code.StatusCode

Advances the hoot log replay time by the given value. Replay must be paused or stopped before advancing its time.

Parameters:

step_time_seconds (second) – The amount of time to advance

Returns:

Status of advancing the replay time

Return type:

StatusCode

classmethod get_raw(name: str) SignalData[bytearray]

Gets a raw-bytes user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalData[bytearray]

classmethod get_boolean(name: str) SignalData[bool]

Gets a boolean user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalData[bool]

classmethod get_integer(name: str) SignalData[int]

Gets an integer user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalData[int]

classmethod get_float(name: str) SignalData[float]

Gets a float user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalData[float]

classmethod get_double(name: str) SignalData[float]

Gets a double user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalData[float]

classmethod get_string(name: str) SignalData[str]

Gets a string user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalData[str]

classmethod get_boolean_array(name: str) SignalData[list[bool]]

Gets a boolean array user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalData[list[bool]]

classmethod get_integer_array(name: str) SignalData[list[int]]

Gets an integer array user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalData[list[int]]

classmethod get_float_array(name: str) SignalData[list[float]]

Gets a float array user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalData[list[float]]

classmethod get_double_array(name: str) SignalData[list[float]]

Gets a double array user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalData[list[float]]