2015-04-27 00:25:16 -03:00
|
|
|
#include <VehicleType.h>
|
2013-12-29 07:56:54 -04:00
|
|
|
|
2015-04-27 00:25:16 -03:00
|
|
|
// we don't use these. but Replay.pde currently does
|
2013-12-29 07:56:54 -04:00
|
|
|
enum log_messages {
|
2014-01-04 20:39:43 -04:00
|
|
|
// plane specific messages
|
2014-04-20 08:45:31 -03:00
|
|
|
LOG_PLANE_ATTITUDE_MSG = 9,
|
|
|
|
LOG_PLANE_COMPASS_MSG = 11,
|
2014-10-14 19:17:22 -03:00
|
|
|
LOG_PLANE_COMPASS2_MSG = 15,
|
2014-04-20 08:45:31 -03:00
|
|
|
LOG_PLANE_AIRSPEED_MSG = 17,
|
2014-01-04 20:39:43 -04:00
|
|
|
|
|
|
|
// copter specific messages
|
|
|
|
LOG_COPTER_ATTITUDE_MSG = 1,
|
|
|
|
LOG_COPTER_COMPASS_MSG = 15,
|
2014-02-25 05:56:53 -04:00
|
|
|
LOG_COPTER_NAV_TUNING_MSG = 5,
|
2014-03-06 02:50:50 -04:00
|
|
|
|
|
|
|
// rover specific messages
|
|
|
|
LOG_ROVER_ATTITUDE_MSG = 8,
|
|
|
|
LOG_ROVER_COMPASS_MSG = 10,
|
2013-12-29 07:56:54 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-04-27 00:25:16 -03:00
|
|
|
class LogReader
|
2013-12-29 07:56:54 -04:00
|
|
|
{
|
|
|
|
public:
|
2015-01-11 18:30:08 -04:00
|
|
|
LogReader(AP_AHRS &_ahrs, AP_InertialSensor &_ins, AP_Baro &_baro, Compass &_compass, AP_GPS &_gps, AP_Airspeed &_airspeed, DataFlash_Class &_dataflash);
|
2013-12-29 07:56:54 -04:00
|
|
|
bool open_log(const char *logfile);
|
|
|
|
bool update(uint8_t &type);
|
|
|
|
bool wait_type(uint8_t 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; }
|
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-04-20 02:07:13 -03:00
|
|
|
uint64_t last_timestamp_us(void) const { return last_timestamp_usec; }
|
|
|
|
|
2013-12-29 07:56:54 -04:00
|
|
|
private:
|
|
|
|
int fd;
|
2014-04-21 05:11:20 -03:00
|
|
|
AP_AHRS &ahrs;
|
2013-12-29 07:56:54 -04:00
|
|
|
AP_InertialSensor &ins;
|
2015-01-05 07:28:06 -04:00
|
|
|
AP_Baro &baro;
|
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;
|
2014-12-07 20:25:22 -04:00
|
|
|
DataFlash_Class &dataflash;
|
2013-12-29 07:56:54 -04:00
|
|
|
|
2015-04-27 00:25:16 -03:00
|
|
|
void update_from_msg_compass(uint8_t gps_offset, class MsgHandler *p, uint8_t *msg);
|
|
|
|
void wait_timestamp_from_msg(class MsgHandler *p, uint8_t *data);
|
2015-04-22 20:24:45 -03:00
|
|
|
|
2014-03-01 17:00:13 -04:00
|
|
|
uint8_t accel_mask;
|
|
|
|
uint8_t gyro_mask;
|
|
|
|
|
2013-12-29 18:32:20 -04:00
|
|
|
uint32_t ground_alt_cm;
|
|
|
|
|
2015-04-22 20:24:45 -03:00
|
|
|
#define LOGREADER_MAX_FORMATS 255 // must be >= highest MESSAGE
|
2014-04-20 08:45:31 -03:00
|
|
|
struct log_Format formats[LOGREADER_MAX_FORMATS];
|
2015-04-27 00:25:16 -03:00
|
|
|
class MsgHandler *msgparser[LOGREADER_MAX_FORMATS];
|
2015-04-22 20:24:45 -03:00
|
|
|
|
|
|
|
template <typename R>
|
2015-04-27 00:25:16 -03:00
|
|
|
void require_field(class MsgHandler *p, uint8_t *msg, const char *label, R &ret);
|
|
|
|
void require_field(class MsgHandler *p, uint8_t *data, const char *label, char *buffer, uint8_t bufferlen);
|
2015-04-22 20:24:45 -03:00
|
|
|
|
|
|
|
// convenience wrappers around require_field
|
2015-04-27 00:25:16 -03:00
|
|
|
uint16_t require_field_uint16_t(class MsgHandler *p, uint8_t *data, const char *label);
|
|
|
|
int16_t require_field_int16_t(class MsgHandler *p, uint8_t *data, const char *label);
|
|
|
|
uint8_t require_field_uint8_t(class MsgHandler *p, uint8_t *data, const char *label);
|
|
|
|
int32_t require_field_int32_t(class MsgHandler *p, uint8_t *data, const char *label);
|
|
|
|
float require_field_float(class MsgHandler *p, uint8_t *data, const char *label);
|
|
|
|
uint8_t require_field_uint8_t(uint8_t *msg, const char *label);
|
|
|
|
|
|
|
|
void location_from_msg(class MsgHandler *p, uint8_t *data,
|
2015-04-22 20:24:45 -03:00
|
|
|
Location &loc,
|
|
|
|
const char *label_lat,
|
|
|
|
const char *label_long,
|
|
|
|
const char *label_alt);
|
2015-04-27 00:25:16 -03:00
|
|
|
void ground_vel_from_msg(class MsgHandler *p, uint8_t *data,
|
2015-04-22 20:24:45 -03:00
|
|
|
Vector3f &vel,
|
|
|
|
const char *label_speed,
|
|
|
|
const char *label_course,
|
|
|
|
const char *label_vz);
|
2015-04-27 00:25:16 -03:00
|
|
|
void attitude_from_msg(class MsgHandler *p, uint8_t *data,
|
2015-04-22 20:24:45 -03:00
|
|
|
Vector3f &att,
|
|
|
|
const char *label_roll,
|
|
|
|
const char *label_pitch,
|
|
|
|
const char *label_yaw);
|
|
|
|
// end convenience wrappers
|
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
|
|
|
|
|
|
|
void wait_timestamp(uint32_t timestamp);
|
2014-01-04 20:39:43 -04:00
|
|
|
|
2015-04-22 20:24:45 -03:00
|
|
|
void update_rover(uint8_t type, uint8_t *data, uint16_t length);
|
2015-04-27 00:25:16 -03:00
|
|
|
|
|
|
|
bool installed_vehicle_specific_parsers;
|
|
|
|
void maybe_install_vehicle_specific_parsers();
|
2013-12-29 07:56:54 -04:00
|
|
|
};
|