Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/Tools/Replay/Replay.h
Views: 1798
/*1This program is free software: you can redistribute it and/or modify2it under the terms of the GNU General Public License as published by3the Free Software Foundation, either version 3 of the License, or4(at your option) any later version.56This program is distributed in the hope that it will be useful,7but WITHOUT ANY WARRANTY; without even the implied warranty of8MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9GNU General Public License for more details.1011You should have received a copy of the GNU General Public License12along with this program. If not, see <http://www.gnu.org/licenses/>.13*/1415#include <AP_Vehicle/AP_Vehicle.h>16#include <AP_Vehicle/AP_FixedWing.h>17#include <SRV_Channel/SRV_Channel.h>1819#include "LogReader.h"2021#define AP_PARAM_VEHICLE_NAME replayvehicle2223struct user_parameter {24struct user_parameter *next;25char name[17];26float value;27};2829extern user_parameter *user_parameters;30extern bool replay_force_ekf2;31extern bool replay_force_ekf3;3233class ReplayVehicle : public AP_Vehicle {34public:35friend class Replay;3637ReplayVehicle() { unused_log_bitmask.set(-1); }38// HAL::Callbacks implementation.39void load_parameters(void) override;40void get_scheduler_tasks(const AP_Scheduler::Task *&tasks,41uint8_t &task_count,42uint32_t &log_bit) override {43tasks = nullptr;44task_count = 0;45log_bit = 0;46};4748virtual bool set_mode(const uint8_t new_mode, const ModeReason reason) override { return true; }49virtual uint8_t get_mode() const override { return 0; }5051AP_FixedWing aparm;5253AP_Int32 unused_log_bitmask; // logging is magic for Replay; this is unused54struct LogStructure log_structure[256] = {55};5657NavEKF2 ekf2;58NavEKF3 ekf3;5960SRV_Channels servo_channels;6162protected:6364protected:6566const AP_Int32 &get_log_bitmask() override { return unused_log_bitmask; }67const struct LogStructure *get_log_structures() const override {68return log_structure;69}70uint8_t get_num_log_structures() const override {71return uint8_t(ARRAY_SIZE(log_structure));72}7374void init_ardupilot() override;7576private:77Parameters g;7879// setup the var_info table80AP_Param param_loader{var_info};8182static const AP_Param::Info var_info[];83};8485class Replay : public AP_HAL::HAL::Callbacks {8687public:88Replay(ReplayVehicle &vehicle) :89_vehicle(vehicle) { }9091void setup() override;92void loop() override;9394// return true if a user parameter of name is set95bool check_user_param(const char *name);9697private:98const char *filename;99ReplayVehicle &_vehicle;100101LogReader reader{_vehicle.log_structure, _vehicle.ekf2, _vehicle.ekf3};102103void _parse_command_line(uint8_t argc, char * const argv[]);104105void set_user_parameters(void);106bool parse_param_line(char *line, char **vname, float &value);107void load_param_file(const char *filename);108void usage();109};110111112