2016-05-25 07:46:18 -03:00
|
|
|
/*
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <AP_Vehicle/AP_Vehicle.h>
|
2022-09-29 21:26:48 -03:00
|
|
|
#include <AP_Vehicle/AP_FixedWing.h>
|
2020-11-05 19:25:17 -04:00
|
|
|
|
|
|
|
#include "LogReader.h"
|
2016-05-25 07:46:18 -03:00
|
|
|
|
2023-01-10 08:29:40 -04:00
|
|
|
#define AP_PARAM_VEHICLE_NAME replayvehicle
|
|
|
|
|
2020-11-07 05:42:21 -04:00
|
|
|
struct user_parameter {
|
|
|
|
struct user_parameter *next;
|
|
|
|
char name[17];
|
|
|
|
float value;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern user_parameter *user_parameters;
|
2020-11-15 23:34:44 -04:00
|
|
|
extern bool replay_force_ekf2;
|
|
|
|
extern bool replay_force_ekf3;
|
2020-11-07 05:42:21 -04:00
|
|
|
|
2019-11-16 18:47:16 -04:00
|
|
|
class ReplayVehicle : public AP_Vehicle {
|
2016-05-25 07:46:18 -03:00
|
|
|
public:
|
2019-12-29 18:36:34 -04:00
|
|
|
friend class Replay;
|
|
|
|
|
2022-07-20 06:42:08 -03:00
|
|
|
ReplayVehicle() { unused.set(-1); }
|
2019-11-16 18:47:16 -04:00
|
|
|
// HAL::Callbacks implementation.
|
2020-01-16 08:52:26 -04:00
|
|
|
void load_parameters(void) override;
|
|
|
|
void get_scheduler_tasks(const AP_Scheduler::Task *&tasks,
|
|
|
|
uint8_t &task_count,
|
2020-03-09 00:28:23 -03:00
|
|
|
uint32_t &log_bit) override {
|
|
|
|
tasks = nullptr;
|
|
|
|
task_count = 0;
|
|
|
|
log_bit = 0;
|
|
|
|
};
|
2016-05-25 07:46:18 -03:00
|
|
|
|
2019-11-16 18:47:16 -04:00
|
|
|
virtual bool set_mode(const uint8_t new_mode, const ModeReason reason) override { return true; }
|
2020-01-09 21:23:13 -04:00
|
|
|
virtual uint8_t get_mode() const override { return 0; }
|
2019-11-16 18:47:16 -04:00
|
|
|
|
2022-09-29 21:26:48 -03:00
|
|
|
AP_FixedWing aparm;
|
2021-10-04 07:17:04 -03:00
|
|
|
|
2017-06-27 05:25:07 -03:00
|
|
|
AP_Int32 unused; // logging is magic for Replay; this is unused
|
2018-04-22 07:19:11 -03:00
|
|
|
struct LogStructure log_structure[256] = {
|
|
|
|
};
|
2019-03-27 18:44:23 -03:00
|
|
|
AP_Logger logger{unused};
|
2016-05-25 07:46:18 -03:00
|
|
|
|
2020-11-05 19:25:17 -04:00
|
|
|
NavEKF2 ekf2;
|
|
|
|
NavEKF3 ekf3;
|
|
|
|
|
2020-01-16 08:52:26 -04:00
|
|
|
protected:
|
|
|
|
|
|
|
|
void init_ardupilot() override;
|
|
|
|
|
2016-05-25 07:46:18 -03:00
|
|
|
private:
|
|
|
|
Parameters g;
|
|
|
|
|
|
|
|
// setup the var_info table
|
|
|
|
AP_Param param_loader{var_info};
|
|
|
|
|
|
|
|
static const AP_Param::Info var_info[];
|
|
|
|
};
|
|
|
|
|
|
|
|
class Replay : public AP_HAL::HAL::Callbacks {
|
2020-11-05 19:25:17 -04:00
|
|
|
|
2016-05-25 07:46:18 -03:00
|
|
|
public:
|
|
|
|
Replay(ReplayVehicle &vehicle) :
|
|
|
|
_vehicle(vehicle) { }
|
|
|
|
|
|
|
|
void setup() override;
|
|
|
|
void loop() override;
|
|
|
|
|
2020-11-07 05:42:21 -04:00
|
|
|
// return true if a user parameter of name is set
|
|
|
|
bool check_user_param(const char *name);
|
|
|
|
|
2016-05-25 07:46:18 -03:00
|
|
|
private:
|
|
|
|
const char *filename;
|
|
|
|
ReplayVehicle &_vehicle;
|
|
|
|
|
2020-11-05 19:25:17 -04:00
|
|
|
LogReader reader{_vehicle.log_structure, _vehicle.ekf2, _vehicle.ekf3};
|
2016-05-25 07:46:18 -03:00
|
|
|
|
|
|
|
void _parse_command_line(uint8_t argc, char * const argv[]);
|
|
|
|
|
2020-11-07 05:42:21 -04:00
|
|
|
void set_user_parameters(void);
|
|
|
|
bool parse_param_line(char *line, char **vname, float &value);
|
|
|
|
void load_param_file(const char *filename);
|
|
|
|
void usage();
|
2016-05-25 20:40:21 -03:00
|
|
|
};
|