2015-06-29 02:59:53 -03:00
|
|
|
#include "VehicleType.h"
|
2019-01-18 02:18:52 -04:00
|
|
|
#include "DataFlashFileReader.h"
|
2015-06-29 02:59:53 -03:00
|
|
|
#include "LR_MsgHandler.h"
|
2016-05-25 07:46:18 -03:00
|
|
|
#include "Parameters.h"
|
2013-12-29 07:56:54 -04:00
|
|
|
|
2019-01-18 00:23:42 -04:00
|
|
|
class LogReader : public AP_LoggerFileReader
|
2013-12-29 07:56:54 -04:00
|
|
|
{
|
|
|
|
public:
|
2018-04-22 07:19:11 -03:00
|
|
|
LogReader(AP_AHRS &_ahrs,
|
|
|
|
AP_InertialSensor &_ins,
|
|
|
|
Compass &_compass,
|
|
|
|
AP_GPS &_gps,
|
|
|
|
AP_Airspeed &_airspeed,
|
2019-03-27 18:44:23 -03:00
|
|
|
AP_Logger &_logger,
|
2018-04-22 07:19:11 -03:00
|
|
|
struct LogStructure *log_structure,
|
|
|
|
uint8_t log_structure_count,
|
|
|
|
const char **¬types);
|
2015-05-09 19:20:32 -03:00
|
|
|
bool wait_type(const char *type);
|
2014-01-05 01:37:47 -04:00
|
|
|
|
2013-12-29 07:56:54 -04:00
|
|
|
const Vector3f &get_attitude(void) const { return attitude; }
|
2014-10-14 19:17:22 -03:00
|
|
|
const Vector3f &get_ahr2_attitude(void) const { return ahr2_attitude; }
|
2014-01-05 01:37:47 -04:00
|
|
|
const Vector3f &get_inavpos(void) const { return inavpos; }
|
2014-01-03 01:07:39 -04:00
|
|
|
const Vector3f &get_sim_attitude(void) const { return sim_attitude; }
|
2014-02-22 17:17:55 -04:00
|
|
|
const float &get_relalt(void) const { return rel_altitude; }
|
2015-06-26 02:12:17 -03:00
|
|
|
const LR_MsgHandler::CheckState &get_check_state(void) const { return check_state; }
|
2013-12-29 07:56:54 -04:00
|
|
|
|
2015-04-27 00:25:16 -03:00
|
|
|
VehicleType::vehicle_type vehicle;
|
2014-01-04 20:39:43 -04:00
|
|
|
|
2014-03-01 00:15:46 -04:00
|
|
|
bool set_parameter(const char *name, float value);
|
|
|
|
|
2014-03-01 17:00:13 -04:00
|
|
|
void set_accel_mask(uint8_t mask) { accel_mask = mask; }
|
|
|
|
void set_gyro_mask(uint8_t mask) { gyro_mask = mask; }
|
2015-06-16 01:26:07 -03:00
|
|
|
void set_use_imt(bool _use_imt) { use_imt = _use_imt; }
|
2015-07-08 21:20:45 -03:00
|
|
|
void set_save_chek_messages(bool _save_chek_messages) { save_chek_messages = _save_chek_messages; }
|
2014-03-01 17:00:13 -04:00
|
|
|
|
2015-04-20 02:07:13 -03:00
|
|
|
uint64_t last_timestamp_us(void) const { return last_timestamp_usec; }
|
2015-06-12 09:52:52 -03:00
|
|
|
virtual bool handle_log_format_msg(const struct log_Format &f);
|
|
|
|
virtual bool handle_msg(const struct log_Format &f, uint8_t *msg);
|
2015-04-20 02:07:13 -03:00
|
|
|
|
2015-07-07 02:13:51 -03:00
|
|
|
static bool in_list(const char *type, const char *list[]);
|
|
|
|
|
2015-07-04 09:43:54 -03:00
|
|
|
protected:
|
|
|
|
|
2013-12-29 07:56:54 -04:00
|
|
|
private:
|
2014-04-21 05:11:20 -03:00
|
|
|
AP_AHRS &ahrs;
|
2013-12-29 07:56:54 -04:00
|
|
|
AP_InertialSensor &ins;
|
2015-01-11 18:30:08 -04:00
|
|
|
Compass &compass;
|
2014-03-31 04:46:01 -03:00
|
|
|
AP_GPS &gps;
|
2014-02-17 18:11:46 -04:00
|
|
|
AP_Airspeed &airspeed;
|
2019-03-27 18:44:23 -03:00
|
|
|
AP_Logger &logger;
|
2018-04-22 07:19:11 -03:00
|
|
|
struct LogStructure *_log_structure;
|
|
|
|
uint8_t _log_structure_count;
|
2013-12-29 07:56:54 -04:00
|
|
|
|
2014-03-01 17:00:13 -04:00
|
|
|
uint8_t accel_mask;
|
|
|
|
uint8_t gyro_mask;
|
2015-06-16 01:26:07 -03:00
|
|
|
bool use_imt = true;
|
2014-03-01 17:00:13 -04:00
|
|
|
|
2013-12-29 18:32:20 -04:00
|
|
|
uint32_t ground_alt_cm;
|
|
|
|
|
2015-07-04 02:14:14 -03:00
|
|
|
class LR_MsgHandler *msgparser[LOGREADER_MAX_FORMATS] {};
|
2015-04-22 20:24:45 -03:00
|
|
|
|
2013-12-29 07:56:54 -04:00
|
|
|
Vector3f attitude;
|
2014-10-14 19:17:22 -03:00
|
|
|
Vector3f ahr2_attitude;
|
2014-01-03 01:07:39 -04:00
|
|
|
Vector3f sim_attitude;
|
2014-01-05 01:37:47 -04:00
|
|
|
Vector3f inavpos;
|
2014-02-22 17:17:55 -04:00
|
|
|
float rel_altitude;
|
2015-04-20 02:07:13 -03:00
|
|
|
uint64_t last_timestamp_usec;
|
2013-12-29 07:56:54 -04:00
|
|
|
|
2015-07-02 20:32:05 -03:00
|
|
|
// mapping from original msgid to output msgid
|
|
|
|
uint8_t mapped_msgid[256] {};
|
|
|
|
|
|
|
|
// next available msgid for mapping
|
|
|
|
uint8_t next_msgid = 1;
|
|
|
|
|
2015-06-26 02:12:17 -03:00
|
|
|
LR_MsgHandler::CheckState check_state;
|
|
|
|
|
2015-04-27 00:25:16 -03:00
|
|
|
bool installed_vehicle_specific_parsers;
|
2015-07-07 02:13:51 -03:00
|
|
|
const char **¬types;
|
2015-05-19 07:22:36 -03:00
|
|
|
|
2015-07-08 21:20:45 -03:00
|
|
|
bool save_chek_messages;
|
|
|
|
|
2015-07-07 02:13:51 -03:00
|
|
|
void maybe_install_vehicle_specific_parsers();
|
2015-07-02 20:32:05 -03:00
|
|
|
|
2018-04-22 07:19:11 -03:00
|
|
|
void initialise_fmt_map();
|
2015-07-02 20:32:05 -03:00
|
|
|
uint8_t map_fmt_type(const char *name, uint8_t intype);
|
2015-07-08 21:20:45 -03:00
|
|
|
|
|
|
|
bool save_message_type(const char *name);
|
2013-12-29 07:56:54 -04:00
|
|
|
};
|
2016-05-16 04:21:52 -03:00
|
|
|
|
|
|
|
// some vars are difficult to get through the layers
|
|
|
|
struct globals {
|
|
|
|
bool no_params;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct globals globals;
|