64 std::vector<std::function<void(wpi::units::second_t)>> updates;
83 for (
auto const &update : updates) {
88#if (__has_include(<wpi/system/RobotController.hpp>) && __has_include(<wpi/system/Timer.hpp>)) || defined(_CTRE_DOCS_)
99#if (__has_include(<wpi/driverstation/internal/DriverStationBackend.hpp>) && __has_include(<wpi/simulation/DriverStationSim.hpp>)) || defined(_CTRE_DOCS_)
159 std::string name, std::string schemaName,
161 std::function<std::span<uint8_t const>()> getter,
177 std::string name, std::string schemaName,
179 std::function<std::span<uint8_t const>()> getter,
183#if __has_include(<wpi/util/struct/Struct.hpp>) || defined(_CTRE_DOCS_)
195 template <
typename T,
typename... I>
196 requires wpi::util::StructSerializable<T, I...>
198 std::string name, I &&... info,
199 std::function<T
const &()> getter,
203 updates.emplace_back([name=std::move(name), ... info=std::forward<I>(info), setter=std::move(setter)](
auto) {
205 if (val.status.IsOK() && val.value) {
208 std::move(*val.value),
210 std::move(val.units),
213 setter(std::move(v));
217 updates.emplace_back([name=std::move(name), ... info=std::forward<I>(info), getter=std::move(getter)](
auto timestamp) {
235 template <
typename T,
typename... I>
236 requires wpi::util::StructSerializable<T, I...>
238 std::string name, I &&... info,
239 std::function<std::span<T const>()> getter,
243 updates.emplace_back([name=std::move(name), ... info=std::forward<I>(info), setter=std::move(setter)](
auto) {
245 if (val.status.IsOK() && val.value) {
248 std::move(*val.value),
250 std::move(val.units),
253 setter(std::move(v));
257 updates.emplace_back([name=std::move(name), ... info=std::forward<I>(info), getter=std::move(getter)](
auto timestamp) {
265#if __has_include(<wpi/util/protobuf/Protobuf.hpp>) || defined(_CTRE_DOCS_)
275 template <wpi::util::ProtobufSerializable T>
278 std::function<T
const &()> getter,
282 updates.emplace_back([name=std::move(name), setter=std::move(setter)](
auto) {
284 if (val.status.IsOK() && val.value) {
287 std::move(*val.value),
289 std::move(val.units),
292 setter(std::move(v));
296 updates.emplace_back([name=std::move(name), getter=std::move(getter)](
auto timestamp) {
314 std::function<std::span<uint8_t const>()> getter,
328 std::function<
bool()> getter,
343 std::function<int64_t()> getter,
345 std::string units =
""
359 std::function<
float()> getter,
361 std::string units =
""
375 std::function<
double()> getter,
377 std::string units =
""
390 std::function<std::string_view()> getter,
403 template <
typename U>
404 requires wpi::units::traits::is_unit_t_v<U>
407 std::function<U()> getter,
411 updates.emplace_back([name=std::move(name), setter=std::move(setter)](
auto) {
413 if (val.status.IsOK()) {
414 setter(std::move(val));
418 updates.emplace_back([name=std::move(name), getter=std::move(getter)](
auto timestamp) {
435 std::function<std::span<bool const>()> getter,
449 std::function<std::span<uint8_t const>()> getter,
464 std::function<std::span<int64_t const>()> getter,
466 std::string units =
""
480 std::function<std::span<float const>()> getter,
482 std::string units =
""
496 std::function<std::span<double const>()> getter,
498 std::string units =
""
511 std::function<std::span<std::string_view const>()> getter,
525 std::function<std::span<std::string const>()> getter,
Class for handling automatic logging and replay of custom signal inputs.
Definition HootAutoReplay.hpp:63
HootAutoReplay & WithMatchInfoReplay()
Registers match info logging and playback with this instance.
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.
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.
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.
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.
HootAutoReplay & WithTimestampReplay()
Registers Timer::GetTimestamp() logging and playback with this instance.
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.
HootAutoReplay & WithValue(std::string name, std::function< U()> getter, std::function< void(SignalMeasurement< U >)> setter)
Registers the unit value as a Hoot-Replayed input.
Definition HootAutoReplay.hpp:405
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.
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.
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.
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.
HootAutoReplay & WithJoystickReplay()
Registers joystick logging and playback with this instance.
HootAutoReplay & WithBoolean(std::string name, std::function< bool()> getter, std::function< void(SignalMeasurement< bool >)> setter)
Registers the boolean as a Hoot-Replayed input.
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
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.
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.
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.
void Update() const
Updates the state of the robot program by doing one of the following:
Definition HootAutoReplay.hpp:80
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.
HootAutoReplay & WithDriverStationReplay()
Registers Driver Station logging and playback with this instance, excluding joysticks and match info.
HootAutoReplay & WithStructArray(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.
Definition HootAutoReplay.hpp:237
HootAutoReplay & WithProtobuf(std::string name, std::function< T const &()> getter, std::function< void(SignalMeasurement< T >)> setter)
Registers the protobuf as a Hoot-Replayed input.
Definition HootAutoReplay.hpp:276
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.
static SignalMeasurement< std::optional< T > > GetStruct(std::string_view name, I const &... info)
Gets a WPILib Struct user signal.
Definition HootReplay.hpp:227
static SignalMeasurement< std::optional< std::vector< T > > > GetStructArray(std::string_view name, I const &... info)
Gets a WPILib Struct array user signal.
Definition HootReplay.hpp:262
static SignalMeasurement< U > GetValue(std::string_view name)
Gets a unit value user signal.
Definition HootReplay.hpp:382
static SignalMeasurement< std::optional< T > > GetProtobuf(std::string_view name)
Gets a Protobuf user signal.
Definition HootReplay.hpp:307
static ctre::phoenix::StatusCode WriteStructArray(std::string_view name, std::span< T const > values, I const &... info, wpi::units::second_t timestamp=utils::GetCurrentTime())
Writes the array of WPILib Structs to the log file.
Definition SignalLogger.hpp:236
static ctre::phoenix::StatusCode WriteStruct(std::string_view name, T const &value, I const &... info, wpi::units::second_t timestamp=utils::GetCurrentTime())
Writes the WPILib Struct to the log file.
Definition SignalLogger.hpp:189
static ctre::phoenix::StatusCode WriteProtobuf(std::string_view name, T const &value, wpi::units::second_t timestamp=utils::GetCurrentTime())
Writes the protobuf to the log file.
Definition SignalLogger.hpp:281
static ctre::phoenix::StatusCode WriteValue(std::string_view name, U value, wpi::units::second_t timestamp=utils::GetCurrentTime())
Writes the unit value to the log file.
Definition SignalLogger.hpp:397
CTREXPORT bool IsReplay()
Get whether the program is running in replay mode.
wpi::units::second_t GetCurrentTime()
Get the current timestamp.
Definition Utils.hpp:27
Definition ExternalFeedbackConfigs.hpp:16
HootSchemaType
Supported schema types for a hoot user signal.
Definition HootSchemaType.hpp:15
Definition motor_constants.h:14
Information from a single measurement of a status signal.
Definition SignalMeasurement.hpp:25