From 1f1618342d790eda4982480588d11004e6869c5b Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Thu, 15 Feb 2024 11:39:38 +1100 Subject: [PATCH] Replay: instantiate an RC_Channels_Replay AP_Vehicle wants to init this object, and since Replay has one... --- Tools/Replay/Replay.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Tools/Replay/Replay.cpp b/Tools/Replay/Replay.cpp index d3dc5339798403..363dd3e1f2bf1b 100644 --- a/Tools/Replay/Replay.cpp +++ b/Tools/Replay/Replay.cpp @@ -96,6 +96,34 @@ const struct AP_Param::GroupInfo GCS_MAVLINK_Parameters::var_info[] = { }; GCS_Dummy _gcs; +// need to instantiate RC_Channels; AP_Vehicle wants to call methods +// on the rc() singleton. Specifying AP_RC_CHANNEL_ENABLED as 0 turns +// out to be hard. + +class RC_Channel_Replay : public RC_Channel +{ +}; +class RC_Channels_Replay : public RC_Channels +{ +public: + int8_t flight_mode_channel_number() const override { return 0; } + RC_Channel_Replay *channel(const uint8_t chan) override { + if (chan >= NUM_RC_CHANNELS) { + return nullptr; + } + return &obj_channels[chan]; + } + RC_Channel_Replay obj_channels[NUM_RC_CHANNELS]; +}; +// defining these two macros and including the +// RC_Channels_VarInfo header defines the parameter information common +// to all vehicle types +#define RC_CHANNELS_SUBCLASS RC_Channels_Replay +#define RC_CHANNEL_SUBCLASS RC_Channel_Replay + +#include +RC_Channels_Replay _rc_channels; + #if AP_ADVANCEDFAILSAFE_ENABLED AP_AdvancedFailsafe *AP::advancedfailsafe() { return nullptr; } bool AP_AdvancedFailsafe::gcs_terminate(bool should_terminate, const char *reason) { return false; }