CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/Tools/Replay/Replay.h
Views: 1798
1
/*
2
This program is free software: you can redistribute it and/or modify
3
it under the terms of the GNU General Public License as published by
4
the Free Software Foundation, either version 3 of the License, or
5
(at your option) any later version.
6
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
11
12
You should have received a copy of the GNU General Public License
13
along with this program. If not, see <http://www.gnu.org/licenses/>.
14
*/
15
16
#include <AP_Vehicle/AP_Vehicle.h>
17
#include <AP_Vehicle/AP_FixedWing.h>
18
#include <SRV_Channel/SRV_Channel.h>
19
20
#include "LogReader.h"
21
22
#define AP_PARAM_VEHICLE_NAME replayvehicle
23
24
struct user_parameter {
25
struct user_parameter *next;
26
char name[17];
27
float value;
28
};
29
30
extern user_parameter *user_parameters;
31
extern bool replay_force_ekf2;
32
extern bool replay_force_ekf3;
33
34
class ReplayVehicle : public AP_Vehicle {
35
public:
36
friend class Replay;
37
38
ReplayVehicle() { unused_log_bitmask.set(-1); }
39
// HAL::Callbacks implementation.
40
void load_parameters(void) override;
41
void get_scheduler_tasks(const AP_Scheduler::Task *&tasks,
42
uint8_t &task_count,
43
uint32_t &log_bit) override {
44
tasks = nullptr;
45
task_count = 0;
46
log_bit = 0;
47
};
48
49
virtual bool set_mode(const uint8_t new_mode, const ModeReason reason) override { return true; }
50
virtual uint8_t get_mode() const override { return 0; }
51
52
AP_FixedWing aparm;
53
54
AP_Int32 unused_log_bitmask; // logging is magic for Replay; this is unused
55
struct LogStructure log_structure[256] = {
56
};
57
58
NavEKF2 ekf2;
59
NavEKF3 ekf3;
60
61
SRV_Channels servo_channels;
62
63
protected:
64
65
protected:
66
67
const AP_Int32 &get_log_bitmask() override { return unused_log_bitmask; }
68
const struct LogStructure *get_log_structures() const override {
69
return log_structure;
70
}
71
uint8_t get_num_log_structures() const override {
72
return uint8_t(ARRAY_SIZE(log_structure));
73
}
74
75
void init_ardupilot() override;
76
77
private:
78
Parameters g;
79
80
// setup the var_info table
81
AP_Param param_loader{var_info};
82
83
static const AP_Param::Info var_info[];
84
};
85
86
class Replay : public AP_HAL::HAL::Callbacks {
87
88
public:
89
Replay(ReplayVehicle &vehicle) :
90
_vehicle(vehicle) { }
91
92
void setup() override;
93
void loop() override;
94
95
// return true if a user parameter of name is set
96
bool check_user_param(const char *name);
97
98
private:
99
const char *filename;
100
ReplayVehicle &_vehicle;
101
102
LogReader reader{_vehicle.log_structure, _vehicle.ekf2, _vehicle.ekf3};
103
104
void _parse_command_line(uint8_t argc, char * const argv[]);
105
106
void set_user_parameters(void);
107
bool parse_param_line(char *line, char **vname, float &value);
108
void load_param_file(const char *filename);
109
void usage();
110
};
111
112