PDR/1.Software/PDR 1.01/include/pdr_sensor.h

315 lines
7.2 KiB
C
Raw Normal View History

2022-09-15 16:35:25 +08:00
/******************** (C) COPYRIGHT 2021 Geek************************************
* File Name : pdr_sensor.h
* Department : Sensor Algorithm Team
* Current Version : V2.0
* Author : logzhan
* Date of Issued : 2021.02.01
* Comments : PDR<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
********************************************************************************/
#ifndef _SENSOR_H_
#define _SENSOR_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
/* Macro Definition ----------------------------------------------------------*/
#define IMU_SENSOR_AXIS 3
#ifdef _WIN32
#define PDR_LOGD printf
#define PDR_LOGE printf
#else
#include <android/log.h>
#define LOG_TAG "Loc_PDR"
#define PDR_LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
#define PDR_LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
#endif
#define ADD_POINT_NUM 10
#define GGA_STR "GGA"
#define RMC_STR "RMC"
#define GSA_STR "GSA"
#define GSV_STR "GSV"
#define GNGGA_STR "$GNGGA"
#define GPGGA_STR "$GPGGA"
#define GNRMC_STR "$GNRMC"
#define GPRMC_STR "$GPRMC"
#define GNGSA_STR "$GNGSA"
#define GPGSA_STR "$GPGSA"
#define GAGSA_STR "$GAGSA"
#define GLGSA_STR "$GLGSA"
#define GPGSV_STR "$GPGSV"
#define GAGSV_STR "$GAGSV"
#define GLGSV_STR "$GLGSV"
#define NORTH "N"
#define SOUTH "S"
#define EAST "E"
#define WEST "W"
#define ITEM_INVALID (-1)
#define INVAILD_GPS_YAW (-1) // <20><>ЧGPS<50><53><EFBFBD><EFBFBD><EFBFBD>Ƕ<EFBFBD><C7B6><EFBFBD>
/* Struct Definition ---------------------------------------------------------*/
typedef enum {
SENSOR_MIN,
SENSOR_ACC = 1,
SENSOR_MAG = 2,
SENSOR_GYRO = 4,
SENSOR_LIGHT = 5,
SENSOR_PROXIMITY = 8,
SENSOR_GAME_ROTATION_VECTOR = 15,
SENSOR_LOCATION_STATELLITE = 70,
SENSOR_LOCATION_NETWORK = 71,
SENSOR_LOCATION_FUSION = 72,
SENSOR_LOCATION_NMEA = 73,
SENSOR_LOCATION_NMEA_GNGGA = 74,
SENSOR_LOCATION_NMEA_GPGGA = 75,
SENSOR_LOCATION_NMEA_GNRMC = 76,
SENSOR_LOCATION_NMEA_GPRMC = 77,
SENSOR_LOCATION_NMEA_GNGSA = 78,
SENSOR_LOCATION_NMEA_GPGSA = 79,
SENSOR_LOCATION_NMEA_GPGSV = 80,
SENSOR_LOCATION_NMEA_GLGSV = 81,
SENSOR_LOCATION_NMEA_GAGSV = 82,
SENSOR_LOCATION_NMEA_GLGSA = 83,
SENSOR_LOCATION_NMEA_GAGSA = 84,
SENSOR_MAX,
} sensor;
typedef enum {
POSITIONING_N = 0,
POSITIONING_Y = 1,
}lct_status;
typedef enum {
POSITIONING_MODE_A = 0,
POSITIONING_MODE_M = 1,
}lct_mode;
typedef enum PDR_Mode {
RAW_GPS = 1,
STOP = 2,
WALK_PDR = 3,
WALK_GPS = 4,
CAR = 5
} PDR_Mode;
typedef enum DIR_Mode {
GPS_DATASHEET = 0,
IMU_PCA = 1,
DELTA_LOCATION = 2
} DIR_Mode;
/*for GSA*/
typedef enum {
PSTN_GSA_N = 1,
PSTN_GSA_Y_2D = 2,
PSTN_GSA_Y_3D = 3,
}lct_type;
typedef enum {
LATITUDE_N = 0,
LATITUDE_S = 1,
LONGITUDINAL_E = 2,
LONGITUDINAL_W = 3,
}LL_NSEW;
typedef enum {
MAG_E = 0,
MAG_W = 1,
}mag_heading;
typedef enum {
MODE_A = 0,
MODE_D = 1,
MODE_E = 2,
MODE_N = 3,
}gnrmc_mode;
typedef enum {
invalid = 0,
fix = 1,
dgps_fix = 2,
invalid_pps = 3,
rtk_fix = 4,
rtk_float = 5,
estimating = 6,
}gngga_quality;
typedef struct sensor_agm {
unsigned char update;
int type;
double time; //ms
float s[IMU_SENSOR_AXIS];
}sensor_agm;
typedef struct imu {
sensor_agm acc;
sensor_agm gyr;
sensor_agm mag;
}imu;
typedef struct lct_nmea_rmc {
unsigned char update;
char rmc_check_sum[9];
sensor type;
lct_status status;
LL_NSEW rmc_latitude_ns;
LL_NSEW longitudinal_ew;
mag_heading mag_h;
gnrmc_mode mode;
float speed;
float cog;
float utc_ddmmyy;
float magnetic;
double rmc_utc;
double latitude;
double longitudinal;
double time; //ms
}lct_nmea_rmc;
typedef struct lct_nmea_gga {
unsigned char update;
char gga_check_sum[9];
sensor type;
LL_NSEW gga_latitude_ns;
LL_NSEW longitudinal_ew;
gngga_quality status;
int satellites_nb;
int unit_a;
int unit_h;
int dgps;
float hdop;
float altitude;
float height;
double gga_utc;
double latitude;
double longitudinal;
double time; //ms
}lct_nmea_gga;
typedef struct lct_nmea_gsa {
unsigned char update;
char check_sum[9];
sensor type;
lct_mode mode;
lct_type p_type;
int prnflg;
int prn[12];
float pdop;
float hdop;
float vdop;
double time; //ms
}
lct_nmea_gsa;
typedef struct satellite_status {
int prn;
int elevation; // elevation >10
int azimuth;
int snr; //snr >25 good
}satellite_status;
typedef struct lct_nmea_gsv {
unsigned char update;
sensor type;
int sentences;
int sentence_number;
int satellites;
int satellite_number;
satellite_status satellites_data[20];
double time; //ms
}lct_nmea_gsv;
typedef struct loc_accuracy{
unsigned char update;
int status; //-1,:Status Unknown; 0: Out of Service; 1: Temporarily Unavailable; 2: Available
float err; // m
double time;
}loc_accuracy;
typedef struct lct_nmea {
unsigned char update;
double minTime;
double maxTime;
lct_nmea_gga gga;
lct_nmea_rmc rmc[2]; // 0 - GNRMC, 1 - GPRMC
lct_nmea_gsa gsa[3]; // 0 - GPGSA, 1 - GLGSA, 2 - GAGSA
lct_nmea_gsv gsv[3]; // 0 - GPGSV, 1 - GLGSV, 2 - GAGSV
loc_accuracy accuracy;
}lct_nmea;
typedef struct lct_fs {
LL_NSEW latitude_ns;
LL_NSEW longitudinal_ew;
double latitude;
double longitudinal;
double gpsLat;
double gpsLon;
double gpsHeading;
double pdrHeading;
double hdop;
double gpsSpeed;
double accuracy;
double time;
double yaw;
double lambda;
double last_lat;
double last_lon;
unsigned long step;
uint8_t motionType;
}lct_fs;
typedef struct gnss {
LL_NSEW lat_ns;
LL_NSEW lon_ew;
int minElevation;
int satellites_num; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int quality;
float yaw; // GNSS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
float vel; // GNSS <20>ٶ<EFBFBD>
float HDOP; // GNSS ˮƽ<CBAE><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
float error; // <20><>ǰGPS<50><53>Accuracy
float lastError; // <20><>һ<EFBFBD><D2BB>GPS<50><53>Accuracy
int overVelCount; // <20>ٶȹ<D9B6><C8B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3>, <20><>¼<EFBFBD>ٶȹ<D9B6><C8B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>ֻ<EFBFBD><D6BB>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڳ<EFBFBD><DAB3><EFBFBD>ģʽ
double timestamps;
double lat;
double lon;
double xNed;
double yNed;
2022-09-17 01:12:48 +08:00
}GNSS_t;
2022-09-15 16:35:25 +08:00
typedef struct IMU {
double time;
float gyr[3];
float acc[3];
float mag[3];
} IMU;
typedef struct AHRS {
uint8_t status;
uint8_t stable; // <20><>ǰAHRS<52><EFBFBD><E3B7A8><EFBFBD><EFBFBD><EFBFBD>ȶ<EFBFBD><C8B6><EFBFBD>
float error;
float qnb[4];
float gravity[3];
float x_axis[3];
float y_axis[3];
float z_axis[3];
float kp; // mahony kp<6B><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>
float yaw;
float pitch;
float roll;
float insHeading;
2022-09-17 01:12:48 +08:00
} AHRS_t;
2022-09-15 16:35:25 +08:00
#ifdef __cplusplus
}
#endif
#endif