CTRE Phoenix 6 C++ 26.0.0-beta-1
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.
 
HootAutoReplayWithJoystickReplay ()
 Registers joystick 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::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::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::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)
 Registers the integer as a Hoot-Replayed input.
 
HootAutoReplayWithFloat (std::string name, std::function< float()> getter, std::function< void(SignalMeasurement< float >)> setter)
 Registers the float as a Hoot-Replayed input.
 
HootAutoReplayWithDouble (std::string name, std::function< double()> getter, std::function< void(SignalMeasurement< double >)> setter)
 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 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)
 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)
 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)
 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<frc::Pose2d>(
"Vision/CameraPose",
[this]() -> frc::Pose2d const& { return cameraPose; },
[this](SignalMeasurement<frc::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:164

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 over the original data. As a result, they cannot return temporary values. If a getter lambda must return a temporary value, capture a unique_ptr or shared_ptr in the lambda, then modify and return the value of the unique_ptr/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 )

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

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
Returns
this object

◆ WithFloat()

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

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

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
Returns
this object

◆ WithInteger()

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

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

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
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 playback during Hoot Replay, "Turn off DS" must be checked in the simulation GUI (under "DS" at the top of the window). Additionally, the Update() of this HootAutoReplay instance must be run at the start of RobotPeriodic() before the CommandScheduler is run.

Returns
this object

◆ WithProtobuf()

template<wpi::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.

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

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

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.

The Update() of this HootAutoReplay instance must be run at the start of RobotPeriodic() before the CommandScheduler is run.

Returns
this object

◆ WithValue()

template<typename U >
requires 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.

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: