OpenShoe
1.0
|
Modules | |
Auxilliary functions | |
Auxilliary functions for calculation various matrix and scalar operations. | |
Miscellaneous | |
Miscellaneous routines. | |
ZUPT aided INS functions | |
the main functions for running the ZUPT aided INS. | |
Initialization routines | |
Routines for initializing the system. Only coarse initial alignment is implemented. | |
Calibration routines | |
Calibration routines. Only accelerometer calibration is implemented since basic gyro calibration (bias) is trivial and is available on the IMU. | |
Defines | |
#define | MAX_ORIENTATIONS 12 |
Maximum numbers of orientations that can be used in the accelerometer calibration. | |
#define | MIN_ORIENTATIONS 3 |
Minimum numbers of orientations that can be used in the accelerometer calibration. | |
#define | MATRIX_INVERSION_ERROR 1 |
Value returned in the error message if an error occurred in the matrix inversion. | |
#define | ACC_STATIONARITY_ERROR 2 |
Value returned in the error message if the IMU was not stationary during the accelerometer calibration. | |
#define | ACC_CALIBRATION_ILLCONDITIONED 3 |
Value returned in the error message if the orientations used in the accelerometer calibration were poorly chosen. | |
#define | NUMBER_OF_ORIENTATIONS_TO_LARGE 4 |
Value returned in the error message if the number of orientations specified for the accelerometer calibration is to large. It has been changed to 12. | |
#define | NUMBER_OF_ORIENTATIONS_TO_SMALL 5 |
Value returned in the error message if the number of orientations specified for the accelerometer calibration is to few. It has been changed to 3. | |
#define | absf(a) (a>0 ? a:-a) |
Absolute value of a floating point variable. | |
Functions | |
void | calibrate_accelerometers (void) |
Function for calibrating the accelerometer biases. | |
void | estimate_accelerometer_biases (void) |
Function that estimates the accelerometer biases given a matrix of the mean of the measured acceleration at different orientations. | |
void | correct_navigation_states (void) |
Function for correcting the navigation states given a zero-velocity detection. | |
void | gain_matrix (void) |
Function for calculating the Kalman filter gain matrix. | |
void | initialize_navigation_algorithm (void) |
Function for initializing the navigation algorithm. | |
void | measurement_update (void) |
Function for doing a measurement update of the Kalman filter covariance. | |
void | strapdown_mechanisation_equations (void) |
Function for doing a time update of the mechanized navigation equations. | |
void | time_up_data (void) |
Function for doing a time update of the Kalman filter state covariance. | |
void | update_imu_data_buffers (void) |
Function that updates the IMU data buffers with the latest values read from the IMU, and writes the IMU data to that should be process at the current iteration to the processing variables. | |
void | ZUPT_detector (void) |
Function for detecting when the system has zero-velocity. | |
void | zupt_update (void) |
Wrapper function that checks if a zero-velocity update should be done, and then calls all navigation algorithm functions that should be executed during a zero-velocity update. | |
Accelerometer calibration parameters. | |
Parameters controlling accelerometer calibration, and vectors and matrices used store the biases. | |
vec3 | accelerometer_biases |
Accelerometer biases (x,y,z-axis) [ ]. | |
precision | acceleration_variance_threshold = 0.002 |
Threshold used to check that accelerometers were stationary during the calibration [ ]. | |
uint32_t | nr_of_calibration_samples = 800 |
Number of samples used at each orientation in the calibration procedure. | |
uint8_t | nr_of_calibration_orientations = 6 |
Number of orientations used in the accelerometer calibration procedure. OBS! Most be at least 3 and less than 13. | |
Bool | new_orientation_flag = false |
Flag that is set to true when the IMU should be place in a new orientation. Should be set to false when the calibration procedure is started, and when the IMU has been placed in a new orientation by the user. | |
Bool | acc_calibration_finished_flag = false |
Flag that is set to true when the calibration is finished. Must be set to false before the calibration is started. | |
General control parameters. | |
Parameters controlling general settings of the navigation algorithm | |
precision | latitude = 13 |
Rough latitude of the system [ ]. (Used to calculate the magnitude of the gravity vector) | |
precision | altitude = 920 |
Rough altitude of the system [ ]. (Used to calculate the magnitude of the gravity vector) | |
precision | g = 9.782940329221166 |
Magnitude of the local gravity acceleration [ ]. | |
precision | dt = 0.001220703125000 |
Sampling period [ ]. | |
uint8_t | error_signal |
Error signaling vector. If zero no error has occurred. | |
IMU data buffer variables. | |
vec3 | accelerations_in |
Accelerations read from the IMU [ ]. These are written into the IMU data buffer. | |
vec3 | angular_rates_in |
Angular rates read from the IMU [ ]. These are written into the IMU data buffer. | |
vec3 | accelerations_out |
Accelerations outputted from the IMU data buffer [ ]. | |
vec3 | angular_rates_out |
Angular rates outputted from the IMU data buffer [ ]. | |
Initialization control parameters | |
Parameters controlling the initialization of the navigation algorithm, i.e., the initial states of the inertial navigation system equations and the initial Kalman filter covariance matrix. | |
Bool | initialize_flag = true |
A flag that should be set to true when initialization is started and that becomes false when the initialization is finished. | |
uint8_t | nr_of_inital_alignment_samples = 16 |
Number of samples used in the initial alignment. | |
precision | initial_heading = 0 |
Initial heading [ ]. | |
vec3 | initial_pos = {0, 0, 0} |
Initial position (North, East, Down) [ ]. | |
vec3 | sigma_initial_position = {0.00001,0.00001,0.00001} |
Standard deviations in the initial position uncertainties [ ]. | |
vec3 | sigma_initial_velocity = {0.01,0.01,0.01} |
Standard deviations in the initial velocity uncertainties [ ]. | |
vec3 | sigma_initial_attitude = {0.00174,0.00174,0.00174} |
Standard deviations in the initial attitude uncertainties [ ]. | |
Kalman filter control parameters | |
Parameters controlling the behavior of the Kalman filter. The parameters can be changed while the filter is running to adapt the filter to the current motion dynamics.
| |
precision | sigma_acceleration = 0.7 |
Accelerometer process noise standard deviation [ ]. | |
precision | sigma_gyroscope = 0.005235987755983 |
Gyroscope process noise standard deviation [ ]. | |
vec3 | sigma_velocity = {0.1,0.1,0.1} |
Pseudo zero-velocity measurement noise standard deviations (north, east, down) [ ]. | |
Navigation and filter state variables. | |
Vectors that holds the current navigation state estimate and the covariance and gain of the Kalman filter. | |
vec3 | position |
Position estimate (North,East,Down) [ ]. | |
vec3 | velocity |
Velocity estimate (North,East,Down) [ ]. | |
quat_vec | quaternions |
Attitude (quaternions) estimate. | |
mat3 | Rb2t |
Rotation matrix used as an "aiding" variable in the filter algorithm. Holds the same information as the quaternions. | |
mat9sym | cov_vector |
Vector representation of the Kalman filter covariance matrix. | |
mat9by3 | kalman_gain |
Vector representation of the Kalman filter gain matrix. | |
Zero-velocity detector control parameters | |
Parameters controlling the behavior of the zero-velocity detector. All the detector control parameters, except the detector_Window_size may be changed will the navigation algorithm is running in order to adapt the behavior of the detector to the current motion dynamics. | |
precision | sigma_acc_det = 0.035 |
Accelerometer noise standard deviation figure [ ], which is used to control how much the detector should trusts the accelerometer data. | |
precision | sigma_gyro_det = 0.006 |
Gyroscope noise standard deviation figure [ ], which is used to control how much the detector should trusts the gyroscope data. | |
volatile uint8_t | detector_Window_size = 3 |
The data window size used in the detector (OBS! Must be an odd number.). | |
precision | detector_threshold = 50000 |
Threshold used in the detector. | |
bool | zupt = false |
Flag that is set to true if a zero-velocity update should be done. | |
precision | Test_statistics = 0 |
Variable holding the test statistics for the generalized likelihood ratio test, i.e., the zero-velocity detector. |
This group contain the filtering algorithms written for OpenShoe. That is, the ZUPT aided INS and calibration algorithms
#define absf | ( | a | ) | (a>0 ? a:-a) |
Absolute value of a floating point variable.
#define ACC_CALIBRATION_ILLCONDITIONED 3 |
Value returned in the error message if the orientations used in the accelerometer calibration were poorly chosen.
#define ACC_STATIONARITY_ERROR 2 |
Value returned in the error message if the IMU was not stationary during the accelerometer calibration.
#define MATRIX_INVERSION_ERROR 1 |
Value returned in the error message if an error occurred in the matrix inversion.
#define MAX_ORIENTATIONS 12 |
Maximum numbers of orientations that can be used in the accelerometer calibration.
#define MIN_ORIENTATIONS 3 |
Minimum numbers of orientations that can be used in the accelerometer calibration.
#define NUMBER_OF_ORIENTATIONS_TO_LARGE 4 |
Value returned in the error message if the number of orientations specified for the accelerometer calibration is to large. It has been changed to 12.
#define NUMBER_OF_ORIENTATIONS_TO_SMALL 5 |
Value returned in the error message if the number of orientations specified for the accelerometer calibration is to few. It has been changed to 3.
void calibrate_accelerometers | ( | void | ) |
Function for calibrating the accelerometer biases.
This function is used to calibrate the biases of the accelerometers in the IMU and requires the users to place the IMU into at least three different orientations. The calibration method is based upon the calibration algorithm described in the paper Calibration of the Accelerometer Triad of an Inertial Measurement Unit, Maximum Likelihood Estimation and Cramer-Rao Bound, but does only calibrate the accelerometer bias.
Before the calibration is started the flags new_orientation_flag and acc_calibration_successful_flag should be set to false. Then the function should called every time new IMU-data have been read from the IMU and as long as the new flags new_orientation_flag and acc_calibration_successful_flag are false. When the flag new_orientation_flag becomes true a message should be sent to the user, which then should place the IMU in a new orientation and reset the flag. When the flag acc_calibration_successful_flag becomes true the calibration is finished and the accelerometer calibration parameters have been written into the memory of the IMU.
[out] | error_vec | A variable that is set non zero value of an error/warning has occurred during the |
[in,out] | acc_calibration_successful_flag | A flag that should be false when calibration is started and that becomes true when the calibration is finished. |
[in,out] | new_orientation_flag | A flag that should be false when calibration is started and that becomes true when IMU should be placed in a new orientation. When the IMU has been placed in a new orientation it should be set to false. execution of the function. |
[in] | accelerations_in | The from the IMU latest read acceleration data. |
void correct_navigation_states | ( | void | ) |
Function for correcting the navigation states given a zero-velocity detection.
When called this function takes the velocity estimate of the navigation system and treat it as an observation of the current velocity error of the system. The errors in all navigation states (position, velocity, and attitude) are then estimated by multiplying the "velocity error" with the Kalman gain. The estimated errors in the navigation states are then used to correct the navigation states.
[in,out] | position | The position estimate of the navigation system. |
[in,out] | velocity | The velocity estimate of the navigation system. |
[out] | quaternions | The orientation estimate of the navigation system. |
[in] | Rb2t | The vector representation of the body to navigation coordinate system rotation matrix estimate. |
[in] | kalman_gain | The vector representation of the Kalman filter gain matrix. |
void estimate_accelerometer_biases | ( | void | ) |
Function that estimates the accelerometer biases given a matrix of the mean of the measured acceleration at different orientations.
[out] | max_v | Largest value of the input vector. |
[out] | index | Index of the vector element holding the largest value. |
[in] | arg_vec | The input vector. |
void gain_matrix | ( | void | ) |
Function for calculating the Kalman filter gain matrix.
When called the function calculates the Kalman filter gain and store it in the vector kalman_gain. To calculate the gain the function uses the Kalman filter covariance and the pseudo velocity measurement noise standard deviation.
[out] | kalman_gain | The vector representation of the Kalman filter gain matrix. |
[in] | cov_vector | The vector representation of the Kalman filter covariance matrix. |
[in] | sigma_velocity | The standard deviation of the pseudo velocity measurement error (Note: This parameters enters the function through a sub-function.). |
void initialize_navigation_algorithm | ( | void | ) |
Function for initializing the navigation algorithm.
This function initializes the navigation algorithm and should during the initialization of the navigation system be called every time new IMU-data have been read from the IMU. Before the initialization is started the flag initialize_flag should be set to true, and the counter initialize_sample_ctr to zero. The initialization is finished when the flag initialize_flag becomes false.
The initialization function first runs an initial alignment of the navigation system, where the roll and pitch are estimated from the average of the accelerometer readings. Then, the function sets the initial navigation states (position, velocity, and quaternions) and the initial Kalman filter covariance.
[out] | position | The position estimate of the navigation system. |
[out] | velocity | The velocity estimate of the navigation system. |
[out] | quaternions | The orientation estimate of the navigation system. |
[out] | cov_vector | The vector representation of the Kalman filter covariance matrix. |
[in,out] | initialize_flag | A flag that should be set to true when initialization is started and that becomes false when the initialization is finished. |
[in] | nr_of_inital_alignment_samples | The number of samples used in the initial alignment. |
[in] | initial_heading | The initial heading of the navigation system. |
[in] | initial_pos | The initial position of the navigation system. |
[in] | sigma_initial_position | The standard deviations of the uncertainties in the initial position. |
[in] | sigma_initial_velocity | The standard deviations of the uncertainties in the initial velocity. |
[in] | sigma_initial_attitude | The standard deviations of the uncertainties in the initial attitude. |
void measurement_update | ( | void | ) |
Function for doing a measurement update of the Kalman filter covariance.
When called the function does a measurement update of the Kalman filter state covariance matrix stored in the vector cov_vector.
[in,out] | cov_vector | The vector representation of the Kalman filter covariance matrix. |
[in] | kalman_gain | The vector representation of the Kalman filter gain matrix. |
void strapdown_mechanisation_equations | ( | void | ) |
Function for doing a time update of the mechanized navigation equations.
When called the function does a time update of the mechanized inertial navigation system equations. That is, first the quaternions stored in quaternions is updated using the angular rate measurements in angular_rates_out. Then the position and velocity state vectors position and velocity are updated using the acceleration measurements in accelerations_out. The function also updates the ''aiding'' vector Rb2t (body to navigation coordinate system rotation matrix) which is used in the Kalman filter.
[in,out] | position | The position estimate of the navigation system. |
[in,out] | velocity | The velocity estimate of the navigation system. |
[in,out] | quaternions | The orientation estimate of the navigation system. |
[out] | Rb2t | The body to navigation coordinate system rotation matrix estimate. |
[in] | accelerations_out | The acceleration measurements used in the update of the inertial navigation system equations. |
[in] | angular_rates_out | The angular rate measurements used in the update of the inertial navigation system equations. |
[in] | dt | The sampling period of the system. |
[in] | g | The magnitude of the local gravity vector. |
void time_up_data | ( | void | ) |
Function for doing a time update of the Kalman filter state covariance.
When called the function does a time update of the Kalman filter state covariance matrix stored in the vector cov_vector.
[in,out] | cov_vector | The vector representation of the Kalman filter covariance matrix. |
[in] | dt | The sampling period of the system. |
[in] | sigma_acceleration | The standard deviation of the accelerometer process noise. |
[in] | sigma_gyroscope | The standard deviation of the gyroscope process noise. |
[in] | accelerations_out | The acceleration measurements used in the update of the inertial navigation system equations. |
[in] | Rb2t | The vector current body to navigation coordinate system rotation matrix estimate. |
void update_imu_data_buffers | ( | void | ) |
Function that updates the IMU data buffers with the latest values read from the IMU, and writes the IMU data to that should be process at the current iteration to the processing variables.
The function updates the IMU data buffers acc_buffer_x_axis, acc_buffer_y_axis, acc_buffer_z_axis, gyro_buffer_x_axis, gyro_buffer_y_axis, gyro_buffer_z_axis with the values stored in the vectors accelerations_in and angular_rates_in. The function also updates the vectors accelerations_out and angular_rates_out. The data stored in these vectors is the data processed in the next iteration of the navigation algorithm.
[out] | accelerations_out | The acceleration data that is to be used in the next iteration of the navigation algorithm. |
[out] | angular_rates_out | The angular rate data that is to be used in the next iteration of the navigation algorithm. |
[in] | accelerations_in | The from the IMU latest read acceleration data. |
[in] | angular_rates_in | The from the IMU latest read angular rate data. |
void ZUPT_detector | ( | void | ) |
Function for detecting when the system has zero-velocity.
When called this function takes the acceleration and angular rate measurements stored in the IMU data buffers and runs a generalized likelihood ratio test to determine if the navigation system is stationary or moving. More information about the detector and it characteristics can be found in following papers:
[out] | zupt | The zero-velocity detection flag |
[in] | detector_Window_size | The window size of the zero-velocity detector. |
[in] | detector_threshold | The threshold used in the detector. |
[in] | sigma_acc_det | The standard deviation figure used to control the importance of the accelerometer measurements in the detection algorithm. |
[in] | sigma_gyro_det | The standard deviation figure used to control the importance of the gyroscope measurements in the detection algorithm. |
[in] | g | The magnitude of the local gravity vector. |
void zupt_update | ( | void | ) |
Wrapper function that checks if a zero-velocity update should be done, and then calls all navigation algorithm functions that should be executed during a zero-velocity update.
Wrapper function that checks if a zero-velocity update should be done, and then calls all navigation algorithm functions that should be executed during a zero-velocity update. The function first calls ZUPT_detector. If then flag zupt is set to true, it also calls the following functions:
Bool acc_calibration_finished_flag = false |
Flag that is set to true when the calibration is finished. Must be set to false before the calibration is started.
Threshold used to check that accelerometers were stationary during the calibration [ ].
Accelerations read from the IMU [ ]. These are written into the IMU data buffer.
Accelerations outputted from the IMU data buffer [ ].
Accelerometer biases (x,y,z-axis) [ ].
Rough altitude of the system [ ]. (Used to calculate the magnitude of the gravity vector)
Angular rates read from the IMU [ ]. These are written into the IMU data buffer.
Angular rates outputted from the IMU data buffer [ ].
Vector representation of the Kalman filter covariance matrix.
precision detector_threshold = 50000 |
Threshold used in the detector.
volatile uint8_t detector_Window_size = 3 |
The data window size used in the detector (OBS! Must be an odd number.).
uint8_t error_signal |
Error signaling vector. If zero no error has occurred.
Initial heading [ ].
vec3 initial_pos = {0, 0, 0} |
Initial position (North, East, Down) [ ].
Bool initialize_flag = true |
A flag that should be set to true when initialization is started and that becomes false when the initialization is finished.
Vector representation of the Kalman filter gain matrix.
Rough latitude of the system [ ]. (Used to calculate the magnitude of the gravity vector)
Bool new_orientation_flag = false |
Flag that is set to true when the IMU should be place in a new orientation. Should be set to false when the calibration procedure is started, and when the IMU has been placed in a new orientation by the user.
uint8_t nr_of_calibration_orientations = 6 |
Number of orientations used in the accelerometer calibration procedure. OBS! Most be at least 3 and less than 13.
uint32_t nr_of_calibration_samples = 800 |
Number of samples used at each orientation in the calibration procedure.
uint8_t nr_of_inital_alignment_samples = 16 |
Number of samples used in the initial alignment.
Attitude (quaternions) estimate.
Rotation matrix used as an "aiding" variable in the filter algorithm. Holds the same information as the quaternions.
precision sigma_acc_det = 0.035 |
Accelerometer noise standard deviation figure [ ], which is used to control how much the detector should trusts the accelerometer data.
precision sigma_acceleration = 0.7 |
Accelerometer process noise standard deviation [ ].
precision sigma_gyro_det = 0.006 |
Gyroscope noise standard deviation figure [ ], which is used to control how much the detector should trusts the gyroscope data.
precision sigma_gyroscope = 0.005235987755983 |
Gyroscope process noise standard deviation [ ].
vec3 sigma_initial_attitude = {0.00174,0.00174,0.00174} |
Standard deviations in the initial attitude uncertainties [ ].
vec3 sigma_initial_position = {0.00001,0.00001,0.00001} |
Standard deviations in the initial position uncertainties [ ].
vec3 sigma_initial_velocity = {0.01,0.01,0.01} |
Standard deviations in the initial velocity uncertainties [ ].
vec3 sigma_velocity = {0.1,0.1,0.1} |
Pseudo zero-velocity measurement noise standard deviations (north, east, down) [ ].
Variable holding the test statistics for the generalized likelihood ratio test, i.e., the zero-velocity detector.
bool zupt = false |
Flag that is set to true if a zero-velocity update should be done.