CTRE Phoenix 6 C++ 25.0.0-beta-4
Loading...
Searching...
No Matches
ctre::phoenix6::HootReplay Class Reference

Static class for controlling Phoenix 6 hoot log replay. More...

#include <ctre/phoenix6/HootReplay.hpp>

Classes

struct  SignalData
 Stores information about a user signal from replay. More...
 

Static Public Member Functions

static ctre::phoenix::StatusCode LoadFile (char const *filepath)
 Loads the given file and starts signal log replay.
 
static void CloseFile ()
 Ends the hoot log replay.
 
static bool IsFileLoaded ()
 Gets whether a valid hoot log file is currently loaded.
 
static ctre::phoenix::StatusCode Play ()
 Starts or resumes the hoot log replay.
 
static ctre::phoenix::StatusCode Pause ()
 Pauses the hoot log replay.
 
static ctre::phoenix::StatusCode Stop ()
 Stops the hoot log replay.
 
static ctre::phoenix::StatusCode Restart ()
 Restarts the hoot log replay from the start of the log.
 
static bool IsPlaying ()
 Gets whether hoot log replay is actively playing.
 
static bool WaitForPlaying (units::second_t timeout)
 Waits until hoot log replay is actively playing.
 
static void SetSpeed (double speed)
 Sets the speed of the hoot log replay.
 
static ctre::phoenix::StatusCode StepTiming (units::time::second_t stepTimeSeconds)
 Advances the hoot log replay time by the given value.
 
static SignalData< std::vector< uint8_t > > GetRaw (std::string_view name)
 Gets a raw-bytes user signal.
 
static SignalData< bool > GetBoolean (std::string_view name)
 Gets a boolean user signal.
 
static SignalData< int64_t > GetInteger (std::string_view name)
 Gets an integer user signal.
 
static SignalData< float > GetFloat (std::string_view name)
 Gets a float user signal.
 
static SignalData< double > GetDouble (std::string_view name)
 Gets a double user signal.
 
template<typename U , typename = std::enable_if_t<units::traits::is_unit_t_v<U>>>
static SignalData< U > GetValue (std::string_view name)
 Gets a unit value user signal.
 
static SignalData< std::string > GetString (std::string_view name)
 Gets a string user signal.
 
static SignalData< std::vector< uint8_t > > GetBooleanArray (std::string_view name)
 Get a boolean array user signal.
 
static SignalData< std::vector< int64_t > > GetIntegerArray (std::string_view name)
 Get an integer array user signal.
 
static SignalData< std::vector< float > > GetFloatArray (std::string_view name)
 Get a float array user signal.
 
static SignalData< std::vector< double > > GetDoubleArray (std::string_view name)
 Get a double array user signal.
 

Detailed Description

Static class for controlling Phoenix 6 hoot log replay.

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 LoadFile(char const *) before any devices are constructed to load a hoot file and start replay. Alternatively, the CANBus(std::string_view, char const *) 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 StepTiming(units::second_t) while paused. The current file can be closed using CloseFile(), after which a new file may be loaded.

Member Function Documentation

◆ CloseFile()

static void ctre::phoenix6::HootReplay::CloseFile ( )
static

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.

◆ GetBoolean()

static SignalData< bool > ctre::phoenix6::HootReplay::GetBoolean ( std::string_view name)
inlinestatic

Gets a boolean user signal.

Parameters
nameName of the signal
Returns
Structure with all information about the signal

◆ GetBooleanArray()

static SignalData< std::vector< uint8_t > > ctre::phoenix6::HootReplay::GetBooleanArray ( std::string_view name)
inlinestatic

Get a boolean array user signal.

Parameters
nameName of the signal
Returns
Structure with all information about the signal

◆ GetDouble()

static SignalData< double > ctre::phoenix6::HootReplay::GetDouble ( std::string_view name)
inlinestatic

Gets a double user signal.

Parameters
nameName of the signal
Returns
Structure with all information about the signal

◆ GetDoubleArray()

static SignalData< std::vector< double > > ctre::phoenix6::HootReplay::GetDoubleArray ( std::string_view name)
inlinestatic

Get a double array user signal.

Parameters
nameName of the signal
Returns
Structure with all information about the signal

◆ GetFloat()

static SignalData< float > ctre::phoenix6::HootReplay::GetFloat ( std::string_view name)
inlinestatic

Gets a float user signal.

Parameters
nameName of the signal
Returns
Structure with all information about the signal

◆ GetFloatArray()

static SignalData< std::vector< float > > ctre::phoenix6::HootReplay::GetFloatArray ( std::string_view name)
inlinestatic

Get a float array user signal.

Parameters
nameName of the signal
Returns
Structure with all information about the signal

◆ GetInteger()

static SignalData< int64_t > ctre::phoenix6::HootReplay::GetInteger ( std::string_view name)
inlinestatic

Gets an integer user signal.

Parameters
nameName of the signal
Returns
Structure with all information about the signal

◆ GetIntegerArray()

static SignalData< std::vector< int64_t > > ctre::phoenix6::HootReplay::GetIntegerArray ( std::string_view name)
inlinestatic

Get an integer array user signal.

Parameters
nameName of the signal
Returns
Structure with all information about the signal

◆ GetRaw()

static SignalData< std::vector< uint8_t > > ctre::phoenix6::HootReplay::GetRaw ( std::string_view name)
inlinestatic

Gets a raw-bytes user signal.

Parameters
nameName of the signal
Returns
Structure with all information about the signal

◆ GetString()

static SignalData< std::string > ctre::phoenix6::HootReplay::GetString ( std::string_view name)
inlinestatic

Gets a string user signal.

Parameters
nameName of the signal
Returns
Structure with all information about the signal

◆ GetValue()

template<typename U , typename = std::enable_if_t<units::traits::is_unit_t_v<U>>>
static SignalData< U > ctre::phoenix6::HootReplay::GetValue ( std::string_view name)
inlinestatic

Gets a unit value user signal.

Parameters
nameName of the signal
Returns
Structure with all information about the signal

◆ IsFileLoaded()

static bool ctre::phoenix6::HootReplay::IsFileLoaded ( )
static

Gets whether a valid hoot log file is currently loaded.

Returns
true if a valid hoot log file is loaded

◆ IsPlaying()

static bool ctre::phoenix6::HootReplay::IsPlaying ( )
inlinestatic

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

◆ LoadFile()

static ctre::phoenix::StatusCode ctre::phoenix6::HootReplay::LoadFile ( char const * filepath)
static

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(std::string_view, char const *) 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
filepathPath and name of the hoot file to load
Returns
Status of opening and reading the file for replay
Exceptions
std::invalid_argument- The file is invalid, unlicensed, or targets a different version of Phoenix 6

◆ Pause()

static ctre::phoenix::StatusCode ctre::phoenix6::HootReplay::Pause ( )
static

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

◆ Play()

static ctre::phoenix::StatusCode ctre::phoenix6::HootReplay::Play ( )
static

Starts or resumes the hoot log replay.

Returns
Status of starting or resuming replay

◆ Restart()

static ctre::phoenix::StatusCode ctre::phoenix6::HootReplay::Restart ( )
inlinestatic

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

◆ SetSpeed()

static void ctre::phoenix6::HootReplay::SetSpeed ( double speed)
static

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
speedSpeed of the hoot log replay

◆ StepTiming()

static ctre::phoenix::StatusCode ctre::phoenix6::HootReplay::StepTiming ( units::time::second_t stepTimeSeconds)
inlinestatic

Advances the hoot log replay time by the given value.

Replay must be paused or stopped before advancing its time.

Parameters
stepTimeSecondsThe amount of time to advance
Returns
Status of advancing the replay time

◆ Stop()

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

Stops the hoot log replay.

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

Returns
Status of stopping replay

◆ WaitForPlaying()

static bool ctre::phoenix6::HootReplay::WaitForPlaying ( units::second_t timeout)
inlinestatic

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 IsPlaying.

Parameters
timeoutMax time to wait for replay to start playing
Returns
true if replay is playing back signals

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