Interpretation of KF-GINS program of open source integrated navigation library of Wuhan University (By GPT3.5)

KF-GINS analysis report (By GPT3.5)

KF-GINS source code:
https://github.com/i2Nav-WHU/KF-GINS

Next, please analyze the following project file by file

[0/16] Please give an overview of the following program file: .\KF-GINS-main\src\common\angle.h

This file is a C++ header file that defines constants and functions for angle conversion.

The file first defines two constants: D2R represents the ratio of angle to radian (ie π/180), and R2D represents the ratio of radian to angle (ie 180/π).

Next, a class named Angle is defined, which defines four static functions: rad2deg and deg2rad realize the conversion between radians and angles, and rad2deg and deg2rad also have two functions whose formal parameters are Eigen matrices, which can convert each element in the corresponding matrix from radians to angles or angles to radians.

Finally, the file is protected with headers to prevent multiple inclusions.

[1/16] Please give an overview of the following program file: .\KF-GINS-main\src\common\earth.h

This program file defines a Earthclass called , which contains some earth-related functions and constants.

Among them, the member functions are:

  • gravity: Calculate the normal acceleration due to gravity at a certain location.
  • meridianPrimeVerticalRadius: Calculate the meridian circle radius and Maoyou circle radius.
  • RN: Calculate the radius of the unitary circle.
  • cne: Calculate the transformation matrix from the navigation coordinate system to the earth-centered ground-fixed coordinate system.
  • qne: Calculate the conversion quaternion from the navigation coordinate system to the earth-centered ground-fixed coordinate system.
  • blh: Convert the quaternion from the navigation coordinate system to the earth-centered earth-fixed coordinate system to obtain latitude and longitude.
  • blh2ecef: Geodetic coordinates (latitude, longitude and elevation) to earth-centered earth-fixed coordinates.
  • ecef2blh: Earth-centered earth-fixed coordinates to earth coordinates.
  • DRi: The relative position of the n system is converted to the relative position of the earth coordinates.
  • DR: The relative position of the earth coordinates is converted to the relative position of the n system.
  • local2global: Convert local coordinates (expanded at origin) to earth coordinates.
  • global2local: Earth coordinates to local coordinates (expand at origin).
  • local2global: Convert local coordinates (expanded at origin) to earth coordinates and rotation matrix.
  • global2local: Earth coordinates and rotation matrix to local coordinates (expand at origin).
  • iewe: The angular velocity of the earth's rotation is projected to the e system.
  • iewn: The angular velocity of the earth's rotation is projected to the n system.
  • iewn: The rotational angular velocity of the n system relative to the e system is projected to the n system.

The constants defined in this class are:

  • WGS84_WIE: Earth rotation angular velocity.
  • WGS84_F: Flatness.
  • WGS84_RA: semi-major axis a.
  • WGS84_RB: Semi-minor axis b.
  • WGS84_GM0: Earth's gravitational constant.
  • WGS84_E1: First eccentricity squared.
  • WGS84_E2: second eccentricity squared.

[2/16] Please give an overview of the following program file: .\KF-GINS-main\src\common\logging.h

The program file is a header file named "logging.h", which provides a Logging class whose main functions are:

  • Initialize the glog logging system;
  • Some macros are defined, such as LOGI, LOGW, LOGE, LOGF and DLOGI, etc., for generating logs;
  • Some printing and formatting output functions are defined, such as printMatrix() and doubleData(), which are used to convert matrix and floating-point data into string format;

Specifically, the program file contains the following sections:

  • Declarations of header files and namespaces;
  • Log output macro definition;
  • Definition of the Logging class;
  • Member function definition of the Logging class;

In short, the main functions of this program file are: it provides functions such as log output, matrix printing, and floating-point data format output. It is a general and convenient log output tool library.

[3/16] Please give an overview of the following program file: .\KF-GINS-main\src\common\rotation.h

This program file is a C++ header file named "rotation.h". This file defines a class named "Rotation", which contains multiple static methods for conversion between matrix and quaternion, conversion between Euler angle and matrix, cross product operation of vector, etc. The specific method is as follows:

  • matrix2quaternion(): Convert the rotation matrix to a quaternion;
  • quaternion2matrix(): Convert quaternion to rotation matrix;
  • matrix2euler(): Convert the rotation matrix to Euler angles (ZYX order, front bottom right IMU);
  • quaternion2euler(): Convert quaternion to Euler angle (ZYX order, IMU at the front bottom right);
  • rotvec2quaternion(): Convert the rotation vector to a quaternion;
  • quaternion2vector(): Convert quaternion to rotation vector;
  • euler2matrix(): Convert Euler angles to rotation matrix (ZYX order);
  • euler2quaternion(): Convert Euler angles to quaternions;
  • skewSymmetric(): Calculate the cross product matrix of the vector;
  • quaternionleft(): Calculate the left multiplication matrix of the quaternion;
  • quaternionright(): Calculate the right multiplication matrix of the quaternion.

The matrix and vector operation related functions in the Eigen library are called in the header file. Additionally, this header file contains a statement of the GNU General Public License.

[4/16] Please give an overview of the following program file: .\KF-GINS-main\src\common\types.h

The program file common\types.h defines three data types: GNSS, IMU, and Pose, which represent global navigation satellite system data, inertial measurement unit data, and attitude data, respectively. These structures contain different member variables, which are used to represent the information required by each data type. In the GNSS and IMU structures, time represents the timestamp, blh and std represent the position and standard deviation, dtheta and dvel represent angular velocity and linear velocity, and odovel represents the original velocity. In the Pose structure, R represents the rotation matrix, and t represents the translation vector. In addition, the program file also refers to some types in the Eigen library, and uses the typedef keyword to define new type names, which simplifies the writing of codes.

[5/16] Please give an overview of the following program file: .\KF-GINS-main\src\fileio\filebase.h

This is a C++ program file named fileio\filebase.h. This file defines a FileBase class for file read and write operations. This class has the following member functions:

  • Constructor: Default constructor.
  • Destructor: The destructor of a class.
  • close(): Close the file operation function.
  • isOpen(): Function to determine whether the file is open.
  • isEof(): Function to determine whether the file has reached the end of the file.
  • fstream(): Get the file stream function.
  • columns(): Returns the file column number function.

This class also has the following member variables:

  • filefp_: file pointer.
  • filetype_: file type, TEXT or BINARY.
  • columns_: number of file columns.

The main function of this file is to encapsulate the file operation function, which is convenient for other files to call.

[6/16] Please give an overview of the following program file: .\KF-GINS-main\src\fileio\fileloader.h

The program file is a header file named fileloader.h.

This file defines a FileLoader class, which inherits from the FileBase class. The main role of the FileLoader class is to read and load files containing data. This class contains the following public member functions:

  • Constructor: used to create a FileLoader object.
  • open() function: used to open the specified file and set the number of columns and file type required for reading.
  • load() function: used to load a continuous data block.
  • loadn() function: used to load files containing multiple data blocks.
  • load() function: used to load data from the specified file into the specified vector.
  • loadn() function: used to load multiple data blocks from the specified file into the specified two-dimensional vector.

The FileLoader class also includes a private member function load_(), which is used to actually perform the reading operation of the file. It also contains a private member variable data_, which is used to temporarily store the loaded data blocks.

The copyright information for the file and the terms of use of the GNU General Public License are described in comments throughout the file.

[7/16] Please give an overview of the following program file: .\KF-GINS-main\src\fileio\filesaver.h

This program file defines a class called FileSaver, which is a subclass of the FileBase class. This class provides functions for opening files and writing data to files. This class is used for data storage. The program is written in C++ language and depends on fstream, string and vector standard libraries, as well as the absl::strings::string_view class in the absl library. The class defined in this file writes data to a local disk file in text or binary format in the form of a file stream. Among them, the dump function writes a one-dimensional vector to a file, and the dumpn function writes a two-dimensional vector to a file.

[8/16] Please give an overview of the following program file: .\KF-GINS-main\src\fileio\gnssfileloader.h

The program file is a header file based on C++ language, named gnssfileloader.h, which is mainly used to read the content of GNSS files. A GnssFileLoader class is defined in the file, which inherits from the FileLoader class and implements a member function next() to read the next GNSS data. This function loads the data into the data_ vector, then assigns the gnss_ structure and returns it. There is also a constructor defined in the file that takes a filename and number of columns and opens it as text. The data read from the file contains the GNSS position coordinates and velocity information within 24 hours.

[9/16] Please give an overview of the following program file: .\KF-GINS-main\src\fileio\imufileloader.h

The program file is named imufileloader.h, and defines a class named ImuFileLoader, which inherits the FileLoader class and is used to load IMU (inertial measurement unit) data from text or binary files. The class contains a constructor, a next() method, a starttime() method, and an endtime() method.

The function of the constructor ImuFileLoader is to open a file with a given file name, store the type of file (text file or binary file), the amount of data contained in each line, and the sampling rate. The sampling time dt is then calculated from the sampling rate.

The next() method reads the next line in the data file and parses it into an IMU object. This method also calculates the dt between the two IMU times and stores it into the dt member variable of the IMU object. If the IMU time interval is greater than 0.1 seconds, the dt of the IMU object will be set to dt_. If there is an 8th element in the data file, it will be stored in the odovel member variable of the IMU object.

The starttime() method moves the file reading pointer to the beginning of the file and returns the timestamp of the first line of data.

The endtime() method moves the file reading pointer to the end of the file and returns the timestamp of the last line of data. If the file type is a text file, the position of the last line is determined by reading a carriage return.

[10/16] Please give an overview of the following program file: .\KF-GINS-main\src\kf-gins\gi_engine.h

The program file name is "gi_engine.h", which belongs to a header file in the KF-GINS program package, and mainly includes the declaration and definition of the GIEngine class. GIEngine is a GNSS/INS (Global Positioning System/Inertial Navigation System) integrated navigation algorithm based on EKF (Extended Kalman Filter). Its main functions include adding new IMU (inertial measurement unit) data and GNSS (global navigation satellite system) data, processing new IMU data, interpolating IMU data, getting current time, getting current IMU state, getting current state covariance, etc. Among them, Kalman prediction and Kalman update are Kalman filtering process based on EKF. In addition, some auxiliary functions are included, such as IMU error compensation, status update, covariance checking, etc.

[11/16] Please give an overview of the following program file: .\KF-GINS-main\src\kf-gins\insmech.h

The program file is a C++ header file named kf-gins\insmech.h. This file defines a C++ class called INSMech, which contains static functions for calculating the internal mechanical combination (INS Mechanization). calculateInternalMechanization. This C++ class defines the following three static functions: posUpdate, velUpdate, and attUpdate. Each function takes two IMU data and the PVA state of the previous second as input, and the current PVA state as output. Overall, the program file implements an algorithm for calculating INS Mechanization.

[12/16] Please give an overview of the following program file: .\KF-GINS-main\src\kf-gins\kf_gins_types.h

This is a C++ program file, named kf_gins_types.h, which mainly contains the definition of some structures. Commonly used structures include:

  1. Attitude: Indicates the attitude, including quaternion, direction cosine matrix and Euler angle;
  2. PVA: Represents position, velocity and attitude, including three vectors, where attitude is defined by Attitude;
  3. NavState: Indicates the navigation state, including position, velocity, Euler angle and IMU error;
  4. ImuError: Indicates the error deviation and scale factor error of the IMU;
  5. ImuNoise: Indicates the noise of the IMU (angular velocity random walk, acceleration random walk, gyroscope bias, accelerometer bias, gyroscope scale factor error, accelerometer scale factor error, and time-related items);
  6. GINSOptions: Indicates the options of the GNSS/INS navigation system, including the initial state and state standard deviation, IMU noise parameters, and installation parameters.

In addition, the program file also contains some constants and function definitions.

[13/16] Please give an overview of the following program file: .\KF-GINS-main\src\kf_gins.cpp

This program is a GNSS/INS (full name Global Navigation Satellite System/Inertial Navigation System) integrated navigation system based on Extended Kalman Filter (EKF). This program encapsulates a GIEngineclass, which implements functions such as EKF filtering algorithm, navigation status update, and error compensation. The program provides an interface that can read IMU data and GNSS data, process them, and output navigation state estimation results and related statistical indicators.

The program consists of a main function in which external libraries such as libraries (for matrix operations) and libraries (for timing and displaying processing progress) mainare used . The main function first reads a configuration file in YAML format, then reads IMU data and GNSS data (read from the file), loads the configuration parameters into the structure, and constructs the object. Then, the program will set the path and format of the output file, align and process the data, and finally output the navigation status and related statistics.EigenabslGINSOptionsGIEngine

The functions in the program loadConfigare used to read the configuration file, store the relevant parameters in GINSOptionsthe structure, and convert them to the standard units used in the program. writeNavResultThe function is used to save the navigation state to the navigation result file, and writeSTDthe function is used to save the standard deviation of the covariance matrix to the corresponding file.

[14/16] Please give an overview of the following program file: .\KF-GINS-main\src\kf-gins\gi_engine.cpp

The program file is an implementation of a GNSS/INS integrated navigation system based on the Extended Kalman Filter (EKF), and the file name is "gi_engine.cpp". By fusing GNSS and IMU measurements, the system is able to provide more accurate navigation state estimates than either GNSS or IMU alone.

The program begins by defining a class named "GIEngine", whose constructor receives system setup options, and sets some initial values ​​and covariance matrix, as well as initialization of the system noise matrix. A function called "initialize" is implemented to initialize the position, velocity, attitude and IMU error. The following "newImuProcess" function is the core part of the whole program. In this function, by judging whether the GNSS data is valid, it is decided whether to update the GNSS navigation state and feedback the system state. At the same time, the propagation of the system state and the update of the covariance matrix are calculated through the IMU measurement value. The function "imuCompensate" is used to compensate the error in the IMU, and pass the IMU data to the function "insPropagation" for state propagation. The last function "insPropagation" realizes the initialization of the state transition matrix, propagation noise matrix, and noise drive matrix, and calculates the state update and attitude error propagation of the IMU through the mechanical arrangement algorithm, thereby updating the state and covariance matrix.

This program realizes the basic functions of GNSS/INS fusion navigation, and provides a method for the effective fusion of GNSS and IMU measurements.

[15/16] Please give an overview of the following program file: .\KF-GINS-main\src\kf-gins\insmech.cpp

This program file is a part of KF-GINS (EKF-based GNSS/INS integrated navigation system), which realizes the three main steps of the mechanical part of INS: velocity update, position update and attitude update. In the speed update, the speed is updated according to the specific force integral item and the gravity/Gothic integral item; in the position update, the position is updated according to the speed extrapolation to the intermediate time; in the attitude update, the speed and position at the intermediate time are obtained according to the speed update, and then the rotation quaternion is calculated to update the attitude matrix.

This program file involves several subfunctions and matrix calculations, some important parts of which include:

  • Update of Speed ​​by Specific Force Integral Term
  • Extrapolation of Velocity and Position
  • Calculation of geographic parameters such as meridian and Maoyou circle radii
  • Gravity/Gothic integral terms update velocity
  • Calculation of attitude matrix and rotation quaternion

These calculations implement key steps in the processing of IMU measurements and navigation calculations.

Based on your own analysis above, summarize the overall function and structure of the program. Then use a markdown table to organize the functions of each file (including common\angle.h, common\earth.h, common\logging.h, common\rotation.h, common\types.h, fileio\filebase.h, fileio\fileloader.h, fileio\filesaver.h, fileio\gnssfileloader.h, fileio\imufileloader.h, kf-gins\gi_eng ine.h, kf-gins\insmech.h, kf-gins\kf_gins_types.h, kf_gins.cpp, kf-gins\gi_engine.cpp, kf-gins\insmech.cpp).

The overall function design of the program

This program is a navigation system based on GNSS/INS fusion, which can read GNSS and IMU data, calculate the navigation status by combining the two, and output it to a file. The overall structure is divided into two parts:

  1. The header files located in the common folder are used to provide some basic mathematical tool functions and data type definitions, etc.
  2. The source files located in the fileio and kf-gins folders are used to provide input and output of data and calculation and implementation of GNSS/INS navigation system.

Summary of File Functions

file name Function
angle.h Provides functions for converting between radians and angles.
earth.h Provides the definition of related parameters of the earth, such as rotation angular velocity, semi-major axis and semi-minor axis, gravitational constant, etc.
logging.h Provides functions such as log output, matrix printing, and formatted output of floating-point data.
rotation.h Provides some functions for rotation matrix calculations.
types.h Some basic data types and constants used in the program are defined.
filebase.h The file operation function is encapsulated, which is convenient for other files to call.
fileloader.h Read the file and save the data to memory.
filesaver.h Save data in memory as a file.
gnssfileloader.h Read GNSS data files.
imufileloader.h Read IMU data files.
gi_engine.h Implemented the initialization and covariance calculation of the GNSS/INS navigation engine.
insmech.h Implemented a mechanical orchestration algorithm that resolves IMU measurements to PVA states.
kf_gins_types.h Options for GNSS/INS navigation systems are defined, including initial state and state standard deviation, IMU noise parameters, installation parameters, etc.
kf_gins.cpp The main function, reads the configuration file and executes the GNSS/INS navigation system.
gi_engine.cpp Implemented the functions of the GNSS/INS navigation engine.
insmech.cpp Implemented mechanical orchestration algorithm.

Guess you like

Origin blog.csdn.net/kanhao100/article/details/129890678