CTRE Phoenix 6 C++ 26.70.0-alpha-2
Loading...
Searching...
No Matches
ctre::phoenix6::HootAutoReplay Class Reference

Class for handling automatic logging and replay of custom signal inputs. More...

#include <ctre/phoenix6/HootAutoReplay.hpp>

Public Member Functions

void Update () const
 Updates the state of the robot program by doing one of the following:
HootAutoReplayWithTimestampReplay ()
 Registers Timer::GetTimestamp() logging and playback with this instance.
HootAutoReplayWithDriverStationReplay ()
 Registers Driver Station logging and playback with this instance, excluding joysticks and match info.
HootAutoReplayWithJoystickReplay ()
 Registers joystick logging and playback with this instance.
HootAutoReplayWithMatchInfoReplay ()
 Registers match info logging and playback with this instance.
HootAutoReplayWithSchemaValue (std::string name, std::string schemaName, HootSchemaType type, std::span< uint8_t const > schema, std::function< std::span< uint8_t const >()> getter, std::function< void(SignalMeasurement< std::vector< uint8_t > >)> setter)
 Registers the schema-serialized bytes as a Hoot-Replayed input.
HootAutoReplayWithSchemaValue (std::string name, std::string schemaName, HootSchemaType type, std::string_view schema, std::function< std::span< uint8_t const >()> getter, std::function< void(SignalMeasurement< std::vector< uint8_t > >)> setter)
 Registers the schema-serialized bytes as a Hoot-Replayed input.
template<typename T, typename... I>
requires wpi::util::StructSerializable<T, I...>
HootAutoReplayWithStruct (std::string name, I &&... info, std::function< T const &()> getter, std::function< void(SignalMeasurement< T >)> setter)
 Registers the WPILib Struct as a Hoot-Replayed input.
template<typename T, typename... I>
requires wpi::util::StructSerializable<T, I...>
HootAutoReplayWithStructArray (std::string name, I &&... info, std::function< std::span< T const >()> getter, std::function< void(SignalMeasurement< std::vector< T > >)> setter)
 Registers the array of WPILib Structs as a Hoot-Replayed input.
template<wpi::util::ProtobufSerializable T>
HootAutoReplayWithProtobuf (std::string name, std::function< T const &()> getter, std::function< void(SignalMeasurement< T >)> setter)
 Registers the protobuf as a Hoot-Replayed input.
HootAutoReplayWithRaw (std::string name, std::function< std::span< uint8_t const >()> getter, std::function< void(SignalMeasurement< std::vector< uint8_t > >)> setter)
 Registers the raw data bytes as a Hoot-Replayed input.
HootAutoReplayWithBoolean (std::string name, std::function< bool()> getter, std::function< void(SignalMeasurement< bool >)> setter)
 Registers the boolean as a Hoot-Replayed input.
HootAutoReplayWithInteger (std::string name, std::function< int64_t()> getter, std::function< void(SignalMeasurement< int64_t >)> setter, std::string units="")
 Registers the integer as a Hoot-Replayed input.
HootAutoReplayWithFloat (std::string name, std::function< float()> getter, std::function< void(SignalMeasurement< float >)> setter, std::string units="")
 Registers the float as a Hoot-Replayed input.
HootAutoReplayWithDouble (std::string name, std::function< double()> getter, std::function< void(SignalMeasurement< double >)> setter, std::string units="")
 Registers the double as a Hoot-Replayed input.
HootAutoReplayWithString (std::string name, std::function< std::string_view()> getter, std::function< void(SignalMeasurement< std::string >)> setter)
 Registers the string as a Hoot-Replayed input.
template<typename U>
requires wpi::units::traits::is_unit_t_v<U>
HootAutoReplayWithValue (std::string name, std::function< U()> getter, std::function< void(SignalMeasurement< U >)> setter)
 Registers the unit value as a Hoot-Replayed input.
HootAutoReplayWithBooleanArray (std::string name, std::function< std::span< bool const >()> getter, std::function< void(SignalMeasurement< std::vector< uint8_t > >)> setter)
 Registers the array of booleans as a Hoot-Replayed input.
HootAutoReplayWithBooleanArray (std::string name, std::function< std::span< uint8_t const >()> getter, std::function< void(SignalMeasurement< std::vector< uint8_t > >)> setter)
 Registers the array of booleans as a Hoot-Replayed input.
HootAutoReplayWithIntegerArray (std::string name, std::function< std::span< int64_t const >()> getter, std::function< void(SignalMeasurement< std::vector< int64_t > >)> setter, std::string units="")
 Registers the array of integers as a Hoot-Replayed input.
HootAutoReplayWithFloatArray (std::string name, std::function< std::span< float const >()> getter, std::function< void(SignalMeasurement< std::vector< float > >)> setter, std::string units="")
 Registers the array of floats as a Hoot-Replayed input.
HootAutoReplayWithDoubleArray (std::string name, std::function< std::span< double const >()> getter, std::function< void(SignalMeasurement< std::vector< double > >)> setter, std::string units="")
 Registers the array of doubles as a Hoot-Replayed input.
HootAutoReplayWithStringArray (std::string name, std::function< std::span< std::string_view const >()> getter, std::function< void(SignalMeasurement< std::vector< std::string > >)> setter)
 Registers the array of strings as a Hoot-Replayed input.
HootAutoReplayWithStringArray (std::string name, std::function< std::span< std::string const >()> getter, std::function< void(SignalMeasurement< std::vector< std::string > >)> setter)
 Registers the array of strings as a Hoot-Replayed input.

Detailed Description

Class for handling automatic logging and replay of custom signal inputs.

Each subsystem typically creates a new instance of this class.

Note that all StatusSignals are automatically logged and replayed, so they do not need to be registered with this class. Additionally, the SignalLogger must be separately started at the start of the robot program.

"Inputs" are signals measured directly from devices that should be replayed unmodified. By comparison, a processed signal, such as a signal indicating that a mechanism has reached the target, is considered an "output". This class should only be used with inputs.

Inputs are registered with a getter that returns a value to log and a setter that updates the value in your robot program. For example, a Vision class with a Pose2d cameraPose input would register the input using:

.WithStruct<wpi::math::Pose2d>(
"Vision/CameraPose",
[this]() -> wpi::math::Pose2d const& { return cameraPose; },
[this](SignalMeasurement<wpi::math::Pose2d> val) {
cameraPose = val.value;
}
);
Class for handling automatic logging and replay of custom signal inputs.
Definition HootAutoReplay.hpp:63
HootAutoReplay & WithStruct(std::string name, I &&... info, std::function< T const &()> getter, std::function< void(SignalMeasurement< T >)> setter)
Registers the WPILib Struct as a Hoot-Replayed input.
Definition HootAutoReplay.hpp:197

After registering all relevant inputs, call Update() periodically to perform the following:

  • In normal/simulated robot operation, registered inputs will be fetched from your robot code using the provided getter and then logged using the SignalLogger.
  • During Hoot Replay, registered inputs will be fetched from HootReplay and then updated in your robot code using the provided setter.

Note that for non-primitive types, the getter function must return a reference to or std::span/std::string_view over the original data. As a result, it cannot return a temporary value. If a getter lambda must return a temporary value, capture a shared_ptr in the lambda, then modify and return the value stored in the shared_ptr.

Member Function Documentation

◆ Update()

void ctre::phoenix6::HootAutoReplay::Update ( ) const
inline

Updates the state of the robot program by doing one of the following:

  • In normal/simulated robot operation, registered signals will be fetched from your robot code using the provided getter and then logged using the SignalLogger.
  • During Hoot Replay, registered signals will be fetched from HootReplay and then updated in your robot code using the provided setter.

This should be called periodically, typically in the subsystem.

◆ WithBoolean()

HootAutoReplay & ctre::phoenix6::HootAutoReplay::WithBoolean ( std::string name,
std::function< bool()> getter,
std::function< void(SignalMeasurement< bool >)> setter )

Registers the boolean as a Hoot-Replayed input.

Parameters
nameName of the signal in the log
getterFunction that returns the current value of the input
setterFunction that sets the input to a new value
Returns
this object

◆ WithBooleanArray() [1/2]

HootAutoReplay & ctre::phoenix6::HootAutoReplay::WithBooleanArray ( std::string name,
std::function< std::span< bool const >()> getter,
std::function< void(SignalMeasurement< std::vector< uint8_t > >)> setter )

Registers the array of booleans as a Hoot-Replayed input.

Parameters
nameName of the signal in the log
getterFunction that returns the current value of the input
setterFunction that sets the input to a new value
Returns
this object

◆ WithBooleanArray() [2/2]

HootAutoReplay & ctre::phoenix6::HootAutoReplay::WithBooleanArray ( std::string name,
std::function< std::span< uint8_t const >()> getter,
std::function< void(SignalMeasurement< std::vector< uint8_t > >)> setter )

Registers the array of booleans as a Hoot-Replayed input.

Parameters
nameName of the signal in the log
getterFunction that returns the current value of the input
setterFunction that sets the input to a new value
Returns
this object

◆ WithDouble()

HootAutoReplay & ctre::phoenix6::HootAutoReplay::WithDouble ( std::string name,
std::function< double()> getter,
std::function< void(SignalMeasurement< double >)> setter,
std::string units = "" )

Registers the double as a Hoot-Replayed input.

Parameters
nameName of the signal in the log
getterFunction that returns the current value of the input
setterFunction that sets the input to a new value
unitsUnits of the signal in the log
Returns
this object

◆ WithDoubleArray()

HootAutoReplay & ctre::phoenix6::HootAutoReplay::WithDoubleArray ( std::string name,
std::function< std::span< double const >()> getter,
std::function< void(SignalMeasurement< std::vector< double > >)> setter,
std::string units = "" )

Registers the array of doubles as a Hoot-Replayed input.

Parameters
nameName of the signal in the log
getterFunction that returns the current value of the input
setterFunction that sets the input to a new value
unitsUnits of the signal in the log
Returns
this object

◆ WithDriverStationReplay()

HootAutoReplay & ctre::phoenix6::HootAutoReplay::WithDriverStationReplay ( )

Registers Driver Station logging and playback with this instance, excluding joysticks and match info.

This should only be applied to one instance in the robot program.

The Update() of this HootAutoReplay instance should be scheduled in the Robot constructor using AddPeriodic() with an offset of -1 ms:

AddPeriodic([this] { autoReplay.Update(); }, DEFAULT_PERIOD, -1_ms);
Returns
this object

◆ WithFloat()

HootAutoReplay & ctre::phoenix6::HootAutoReplay::WithFloat ( std::string name,
std::function< float()> getter,
std::function< void(SignalMeasurement< float >)> setter,
std::string units = "" )

Registers the float as a Hoot-Replayed input.

Parameters
nameName of the signal in the log
getterFunction that returns the current value of the input
setterFunction that sets the input to a new value
unitsUnits of the signal in the log
Returns
this object

◆ WithFloatArray()

HootAutoReplay & ctre::phoenix6::HootAutoReplay::WithFloatArray ( std::string name,
std::function< std::span< float const >()> getter,
std::function< void(SignalMeasurement< std::vector< float > >)> setter,
std::string units = "" )

Registers the array of floats as a Hoot-Replayed input.

Parameters
nameName of the signal in the log
getterFunction that returns the current value of the input
setterFunction that sets the input to a new value
unitsUnits of the signal in the log
Returns
this object

◆ WithInteger()

HootAutoReplay & ctre::phoenix6::HootAutoReplay::WithInteger ( std::string name,
std::function< int64_t()> getter,
std::function< void(SignalMeasurement< int64_t >)> setter,
std::string units = "" )

Registers the integer as a Hoot-Replayed input.

Parameters
nameName of the signal in the log
getterFunction that returns the current value of the input
setterFunction that sets the input to a new value
unitsUnits of the signal in the log
Returns
this object

◆ WithIntegerArray()

HootAutoReplay & ctre::phoenix6::HootAutoReplay::WithIntegerArray ( std::string name,
std::function< std::span< int64_t const >()> getter,
std::function< void(SignalMeasurement< std::vector< int64_t > >)> setter,
std::string units = "" )

Registers the array of integers as a Hoot-Replayed input.

Parameters
nameName of the signal in the log
getterFunction that returns the current value of the input
setterFunction that sets the input to a new value
unitsUnits of the signal in the log
Returns
this object

◆ WithJoystickReplay()

HootAutoReplay & ctre::phoenix6::HootAutoReplay::WithJoystickReplay ( )

Registers joystick logging and playback with this instance.

This should only be applied to one instance in the robot program.

To get joysticks to play back during Hoot Replay, "Turn off DS" must be checked in the simulation GUI (under "DS" at the top of the window).

The Update() of this HootAutoReplay instance should be scheduled in the Robot constructor using AddPeriodic() with an offset of -1 ms:

AddPeriodic([this] { autoReplay.Update(); }, DEFAULT_PERIOD, -1_ms);
Returns
this object

◆ WithMatchInfoReplay()

HootAutoReplay & ctre::phoenix6::HootAutoReplay::WithMatchInfoReplay ( )

Registers match info logging and playback with this instance.

This should only be applied to one instance in the robot program.

The Update() of this HootAutoReplay instance should be scheduled in the Robot constructor using AddPeriodic() with an offset of -1 ms:

AddPeriodic([this] { autoReplay.Update(); }, DEFAULT_PERIOD, -1_ms);
Returns
this object

◆ WithProtobuf()

template<wpi::util::ProtobufSerializable T>
HootAutoReplay & ctre::phoenix6::HootAutoReplay::WithProtobuf ( std::string name,
std::function< T const &()> getter,
std::function< void(SignalMeasurement< T >)> setter )
inline

Registers the protobuf as a Hoot-Replayed input.

Template Parameters
TProtobuf type
Parameters
nameName of the signal in the log
getterFunction that returns the current value of the input
setterFunction that sets the input to a new value
Returns
this object

◆ WithRaw()

HootAutoReplay & ctre::phoenix6::HootAutoReplay::WithRaw ( std::string name,
std::function< std::span< uint8_t const >()> getter,
std::function< void(SignalMeasurement< std::vector< uint8_t > >)> setter )

Registers the raw data bytes as a Hoot-Replayed input.

Parameters
nameName of the signal in the log
getterFunction that returns the current value of the input
setterFunction that sets the input to a new value
Returns
this object

◆ WithSchemaValue() [1/2]

HootAutoReplay & ctre::phoenix6::HootAutoReplay::WithSchemaValue ( std::string name,
std::string schemaName,
HootSchemaType type,
std::span< uint8_t const > schema,
std::function< std::span< uint8_t const >()> getter,
std::function< void(SignalMeasurement< std::vector< uint8_t > >)> setter )

Registers the schema-serialized bytes as a Hoot-Replayed input.

Parameters
nameName of the signal in the log
schemaNameName of the schema
typeType of the schema, such as struct or protobuf
schemaSchema bytes to write
getterFunction that returns the current value of the input
setterFunction that sets the input to a new value
Returns
this object

◆ WithSchemaValue() [2/2]

HootAutoReplay & ctre::phoenix6::HootAutoReplay::WithSchemaValue ( std::string name,
std::string schemaName,
HootSchemaType type,
std::string_view schema,
std::function< std::span< uint8_t const >()> getter,
std::function< void(SignalMeasurement< std::vector< uint8_t > >)> setter )

Registers the schema-serialized bytes as a Hoot-Replayed input.

Parameters
nameName of the signal in the log
schemaNameName of the schema
typeType of the schema, such as struct or protobuf
schemaSchema string to write
getterFunction that returns the current value of the input
setterFunction that sets the input to a new value
Returns
this object

◆ WithString()

HootAutoReplay & ctre::phoenix6::HootAutoReplay::WithString ( std::string name,
std::function< std::string_view()> getter,
std::function< void(SignalMeasurement< std::string >)> setter )

Registers the string as a Hoot-Replayed input.

Parameters
nameName of the signal in the log
getterFunction that returns the current value of the input
setterFunction that sets the input to a new value
Returns
this object

◆ WithStringArray() [1/2]

HootAutoReplay & ctre::phoenix6::HootAutoReplay::WithStringArray ( std::string name,
std::function< std::span< std::string const >()> getter,
std::function< void(SignalMeasurement< std::vector< std::string > >)> setter )

Registers the array of strings as a Hoot-Replayed input.

Parameters
nameName of the signal in the log
getterFunction that returns the current value of the input
setterFunction that sets the input to a new value
Returns
this object

◆ WithStringArray() [2/2]

HootAutoReplay & ctre::phoenix6::HootAutoReplay::WithStringArray ( std::string name,
std::function< std::span< std::string_view const >()> getter,
std::function< void(SignalMeasurement< std::vector< std::string > >)> setter )

Registers the array of strings as a Hoot-Replayed input.

Parameters
nameName of the signal in the log
getterFunction that returns the current value of the input
setterFunction that sets the input to a new value
Returns
this object

◆ WithStruct()

template<typename T, typename... I>
requires wpi::util::StructSerializable<T, I...>
HootAutoReplay & ctre::phoenix6::HootAutoReplay::WithStruct ( std::string name,
I &&... info,
std::function< T const &()> getter,
std::function< void(SignalMeasurement< T >)> setter )
inline

Registers the WPILib Struct as a Hoot-Replayed input.

Template Parameters
TStruct type
IStruct info types
Parameters
nameName of the signal in the log
infoOptional struct type info
getterFunction that returns the current value of the input
setterFunction that sets the input to a new value
Returns
this object

◆ WithStructArray()

template<typename T, typename... I>
requires wpi::util::StructSerializable<T, I...>
HootAutoReplay & ctre::phoenix6::HootAutoReplay::WithStructArray ( std::string name,
I &&... info,
std::function< std::span< T const >()> getter,
std::function< void(SignalMeasurement< std::vector< T > >)> setter )
inline

Registers the array of WPILib Structs as a Hoot-Replayed input.

Template Parameters
TStruct type
IStruct info types
Parameters
nameName of the signal in the log
infoOptional struct type info
getterFunction that returns the current value of the input
setterFunction that sets the input to a new value
Returns
this object

◆ WithTimestampReplay()

HootAutoReplay & ctre::phoenix6::HootAutoReplay::WithTimestampReplay ( )

Registers Timer::GetTimestamp() logging and playback with this instance.

This should only be applied to one instance in the robot program.

Returns
this object

◆ WithValue()

template<typename U>
requires wpi::units::traits::is_unit_t_v<U>
HootAutoReplay & ctre::phoenix6::HootAutoReplay::WithValue ( std::string name,
std::function< U()> getter,
std::function< void(SignalMeasurement< U >)> setter )
inline

Registers the unit value as a Hoot-Replayed input.

Template Parameters
UUnit type
Parameters
nameName of the signal in the log
getterFunction that returns the current value of the input
setterFunction that sets the input to a new value
Returns
this object

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