Home | History | Annotate | Download | only in mpl
      1 /*
      2  $License:
      3     Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved.
      4     See included License.txt for License information.
      5  $
      6  */
      7 
      8 #ifndef MLDMP_MAGDISTURB_H__
      9 #define MLDMP_MAGDISTURB_H__
     10 
     11 #include "mltypes.h"
     12 
     13 #ifdef __cplusplus
     14 extern "C" {
     15 #endif
     16 
     17    // #define WIN_8
     18     //#define RECORD_DATA_4_ANALYSIS
     19 
     20     int inv_check_magnetic_disturbance(unsigned long delta_time, const long *quat,
     21         const long *compass, const long *gravity);
     22 
     23     void inv_track_world_yaw_angle_angle(int mode, float currdip);
     24 
     25     inv_error_t inv_enable_magnetic_disturbance(void);
     26     inv_error_t inv_disable_magnetic_disturbance(void);
     27     int inv_get_magnetic_disturbance_state();
     28 
     29     inv_error_t inv_set_magnetic_disturbance(int time_ms);
     30     inv_error_t inv_init_magnetic_disturbance(void);
     31 
     32     void inv_enable_magnetic_disturbance_logging(void);
     33     void inv_disable_magnetic_disturbance_logging(void);
     34 
     35     float Mag3ofNormalizedLong(const long *x);
     36     float Mag2ofNormalizedLong(const long *x);
     37     float Mag2ofNormalizedFloat(const float *x);
     38 
     39     int inv_mag_disturb_get_detect_status_3D(void);
     40     void inv_mag_disturb_set_detect_status_3D(int status);
     41 
     42     int inv_mag_disturb_get_drop_heading_accuracy_status(void);
     43     void inv_mag_disturb_set_drop_heading_accuracy_status(int status);
     44 
     45     int inv_mag_disturb_get_detect_weak_status_3D(void);
     46     void inv_mag_disturb_set_detect_weak_status_3D(int status);
     47 
     48     int inv_mag_disturb_get_detect_world_yaw_angle_status(void);
     49     void inv_mag_disturb_set_detect_world_yaw_angle_status(int status);
     50 
     51     int inv_mag_disturb_get_detect_world_yaw_angle_confirm_status(void);
     52     void inv_mag_disturb_set_detect_world_yaw_angle_confirm_status(int status);
     53 
     54     float inv_mag_disturb_get_vector_radius_3D(void);
     55     void inv_mag_disturb_set_vector_radius_3D(float radius);
     56 
     57     void inv_mag_disturb_world_yaw_angle_init(void);
     58     void inv_mag_disturb_world_yaw_angle_process(struct inv_sensor_cal_t *obj);
     59     //enum mag_distub_state_e inv_mag_disturb_get_mar_world_yaw_angle_state(void);
     60 
     61     char inv_mag_disturb_get_mar_world_yaw_angle_detection_status(void);
     62 
     63     float inv_mag_disturb_world_yaw_angle_distortion_from_gyro_bias(struct inv_sensor_cal_t *obj);
     64     int inv_mag_disturb_get_dip_compassNgravity(struct inv_sensor_cal_t *data);
     65 
     66     float inv_mag_disturb_9x_quat_confidence_interval(struct inv_sensor_cal_t *obj);
     67     float inv_mag_disturb_geo_mag_confidence_interval(struct inv_sensor_cal_t *obj);
     68 
     69     float inv_mag_disturb_world_yaw_angle_distortion_from_accel_compass_bias(float accel_bias_error, float compass_bias_error);
     70     float inv_mag_disturb_world_yaw_angle_distortion_from_accel_compass_only(float accel_bias_error, float compass_bias_error);
     71 
     72     void inv_mag_disturb_all_confidence_interval_init(void);
     73     void inv_mag_disturb_recover_compass_accuracy_to_3(void);
     74 
     75 #ifdef RECORD_DATA_4_ANALYSIS
     76     void debug_file_init(void);
     77     void debug_file_record(struct inv_sensor_cal_t *obj);
     78     void debug_file_exit(void);
     79 #endif
     80 
     81     /************************/
     82     /* external API         */
     83     /************************/
     84     float inv_mag_disturb_get_magnitude_threshold(void);
     85     void inv_mag_disturb_set_magnitude_threshold(float radius);
     86 
     87     float inv_mag_disturb_get_magnitude_recover_normal_threshold(void);
     88     void inv_mag_disturb_set_magnitude_recover_normal_threshold(float radius);
     89 
     90     /* These API get/set the yaw angle based magnetic anomaly detection*/
     91     float inv_mag_disturb_get_yaw_angle_weak_threshold(void);
     92     void inv_mag_disturb_set_yaw_angle_weak_threshold(float angle);
     93 
     94     /* These API get/set the yaw angle based strong magnetic anomaly detection*/
     95     /* The strong magnetic anomaly detection will drop heading accuracy if gyro is not trustable */
     96     float inv_mag_disturb_get_yaw_angle_strong_threshold(void);
     97     void inv_mag_disturb_set_yaw_angle_strong_threshold(float angle);
     98 
     99     float inv_mag_disturb_get_time_threshold_detect(void);
    100     void inv_mag_disturb_set_time_threshold_detect(float time_seconds);
    101 
    102     float inv_mag_disturb_get_local_field_radius(void);
    103     void inv_mag_disturb_set_local_field_radius(float radius);
    104 
    105     float inv_mag_disturb_get_local_field_dip(void);
    106     void inv_mag_disturb_set_local_field_dip(float dip);
    107 
    108 #ifdef __cplusplus
    109 }
    110 #endif
    111 
    112 
    113 #endif // MLDMP_MAGDISTURB_H__
    114