# gnss-ins-sim **Repository Path**: nemo777/gnss-ins-sim ## Basic Information - **Project Name**: gnss-ins-sim - **Description**: 21321323213124214124 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-10-03 - **Last Updated**: 2022-10-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # GNSS-INS-SIM **GNSS-INS-SIM** is an GNSS/INS simulation project, which generates reference trajectories, IMU sensor output, GPS output, odometer output and magnetometer output. Users choose/set up the sensor model, define the waypoints and provide algorithms, and **gnss-ins-sim** can generate required data for the algorithms, run the algorithms, plot simulation results, save simulations results, and generate a brief summary. # Contents ------ * [Requirements](#requirements) * [Demos](#demos) * [Get started](#get-started) * [Step 1 Define the IMU model](#step-1-define-the-imu-model) * [Step 2 Create a motion profile](#step-2-create-a-motion-profile) * [Step 3 Create your algorithm](#step-3-create-your-algorithm) * [Step 4 Run the simulation](#step-4-run-the-simulation) * [Step 5 Show results](#step-5-show-results) * [Acknowledgement](#Acknowledgement) # Requirements - Numpy ( version>1.10 ) - Matplotlib # Demos We provide the following demos to show how to use this tool: | file name | description | |---|---| | demo_no_algo.py | A demo of generating data, saving generated data to files and plotting (2D/3D)interested data, no user specified algorithm. | | demo_allan.py | A demo of Allan analysis of gyroscope and accelerometer data. The generated Allan deviation is shown in figures.| | demo_free_integration.py | A demo of a simple strapdown system. The simulation runs for 1000 times. The statistics of the INS results of the 1000 simulations are generated.| | demo_inclinometer_mahony.py | A demo of an dynamic inclinometer algorithm based on Mahony's theory. This demo shows how to generate error plot of interested data.| | demo_aceinna_vg.py | A demo of DMU380 dynamic tilt algorithm. The algorithm is first compiled as a shared library. This demo shows how to call the shared library. This is the algorithm inside Aceinna's VG/MTLT products.| | demo_aceinna_ins.py | A demo of DMU380 GNSS/INS fusion algorithm. The algorithm is first compiled as a shared library. This demo shows how to call the shared library. This is the algorithm inside Aceinna's INS products.| | demo_multiple_algorithms.py | A demo of multiple algorithms in a simulation. This demo shows how to compare resutls of multiple algorithm.| | demo_gen_data_from_files.py | This demo shows how to do simulation from logged data files.| # Get started ## Step 1 Define the IMU model ### Step 1.1 Define the IMU error model IMU error model can be specified in two ways: #### Choose a built-in model There are three built-in IMU models: 'low-accuracy', 'mid-accuracy' and 'high accuracy'. #### Manually define the model ```python imu_err = { # gyro bias, deg/hr 'gyro_b': np.array([0.0, 0.0, 0.0]), # gyro angle random walk, deg/rt-hr 'gyro_arw': np.array([0.25, 0.25, 0.25]), # gyro bias instability, deg/hr 'gyro_b_stability': np.array([3.5, 3.5, 3.5]), # gyro bias instability correlation, sec. # set this to 'inf' to use a random walk model # set this to a positive real number to use a first-order Gauss-Markkov model 'gyro_b_corr': np.array([100.0, 100.0, 100.0]), # accelerometer bias, m/s^2 'accel_b': np.array([0.0e-3, 0.0e-3, 0.0e-3]), # accelerometer velocity random walk, m/s/rt-hr 'accel_vrw': np.array([0.03119, 0.03009, 0.04779]), # accelerometer bias instability, m/s^2 'accel_b_stability': np.array([4.29e-5, 5.72e-5, 8.02e-5]), # accelerometer bias instability correlation, sec. Similar to gyro_b_corr 'accel_b_corr': np.array([200.0, 200.0, 200.0]), # magnetometer noise std, uT 'mag_std': np.array([0.2, 0.2, 0.2]) } ``` ### Step 1.2 Create an IMU object ```python imu = imu_model.IMU(accuracy=imu_err, axis=6, gps=False) imu = imu_model.IMU(accuracy='low-accuracy', axis=9, gps=True) ``` axis = 6 to generate only gyro and accelerometer data. axis = 9 to generate magnetometer data besides gyro and accelerometer data. gps = True to generate GPS data, gps = False not. ## Step 2 Create a motion profile A motion profile specifies the initial states of the vehicle and motion command that drives the vehicle to move, as shown in the following table. | Ini lat (deg) | ini lon (deg) | ini alt (m) | ini vx_body (m/s) | ini vy_body (m/s) | ini vz_body (m/s) | ini yaw (deg) | ini pitch (deg) | ini roll (deg) | |---|---|---|---|---|---|---|---|---| | 32 | 120 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | command type | yaw (deg) | pitch (deg) | roll (deg) | vx_body (m/s) | vy_body (m/s) | vz_body (m/s) | command duration (s) | GPS visibility | | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 200 | 1 | | ... | ... | ... | ... | ... | ... | ... | ... | ... | The initial position should be given in the LLA (latitude, longitude and altitude) form. The initial velocity is specified in the vehicle body frame. The initial attitude is represented by Euler angles of ZYX rotation sequence. Motion commands define how the vehicle moves from its initial state. The simulation will generate true angular velocity, acceleration, magnetic field, position, velocity and attitude according to the commands. Combined with sensor error models, these true values are used to generate gyroscope, accelerometer, magnetometer and GPS output. There is only one motion command in the above table. Indeed, you can add more motion commands to specify the attitude and velocity of the vehicle. You can also define GPS visibility of the vehicle for each command. Five command types are supported, as listed below. | Command type | Comment | |---|---| | 1 | Directly define the Euler angles change rate and body frame velocity change rate. The change rates are given by column 2~7. The units are deg/s and m/s/s. Column 8 gives how long the command will last. If you want to fully control execution time of each command by your own, you should always choose the motion type to be 1 | | 2 | Define the absolute attitude and absolute velocity to reach. The target attitude and velocity are given by column 2~7. The units are deg and m/s. Column 8 defines the maximum time to execute the command. If actual executing time is less than max time, the remaining time will not be used and the next command will be executed immediately. If the command cannot be finished within max time, the next command will be executed after max time. | | 3 | Define attitude change and velocity change. The attitude and velocity changes are given by column 2~7. The units are deg and m/s. Column 8 defines the maximum time to execute the command. | | 4 | Define absolute attitude and velocity change. The absolute attitude and velocity change are given by column 2~7. The units are deg and m/s. Column 8 defines the maximum time to execute the command. | | 5 | Define attitude change and absolute velocity. The attitude change and absolute velocity are given by column 2~7. The units are deg and m/s. Column 8 defines the maximum time to execute the command. | ### An example of motion profile | Ini lat (deg) | ini lon (deg) | ini alt (m) | ini vx_body (m/s) | ini vy_body (m/s) | ini vz_body (m/s) | ini yaw (deg) | ini pitch (deg) | ini roll (deg) | |---|---|---|---|---|---|---|---|---| | 32 | 120 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | command type | yaw (deg) | pitch (deg) | roll (deg) | vx_body (m/s) | vy_body (m/s) | vz_body (m/s) | command duration (s) | GPS visibility | | 1 | 0| 0 | 0 | 0 | 0 | 0 | 200 | 1 | | 5 | 0 | 45 | 0 | 10 | 0 | 0 | 250 | 1 | | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 1 | | 3 | 90 | -45 | 0 | 0 | 0 | 0 | 25 | 1 | | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 50 | 1 | | 3 | 180 | 0 | 0 | 0 | 0 | 0 | 25 | 1 | | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 50 | 1 | | 3 | -180 | 0 | 0 | 0 | 0 | 0 | 25 | 1 | | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 50 | 1 | | 3 | 180 | 0 | 0 | 0 | 0 | 0 | 25 | 1 | | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 50 | 1 | | 3 | -180 | 0 | 0 | 0 | 0 | 0 | 25 | 1 | | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 50 | 1 | | 3 | 180 | 0 | 0 | 0 | 0 | 0 | 25 | 1 | | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 50 | 1 | | 3 | -180 | 0 | 0 | 0 | 0 | 0 | 25 | 1 | | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 50 | 1 | | 5 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 1 | The initial latitude, longitude and altitude of the vehicle are 32deg, 120deg and 0 meter, respectively. The initial velocity of the vehicle is 0. The initial Euler angles are 0deg pitch, 0deg roll and 0deg yaw, which means the vehicle is level and its x axis points to the north. | command type | yaw (deg) | pitch (deg) | roll (deg) | vx_body (m/s) | vy_body (m/s) | vz_body (m/s) | command duration (s) | GPS visibility | |---|---|---|---|---|---|---|---|---| | 1 | 0| 0 | 0 | 0 | 0 | 0 | 200 | 1 | This command is of type 1. Command type1 directly gives Euler angle change rate and velocity change rate. In this case, they are zeros. That means keep the current state (being static) of the vehicle for 200sec. During this period, GPS is visible. | command type | yaw (deg) | pitch (deg) | roll (deg) | vx_body (m/s) | vy_body (m/s) | vz_body (m/s) | command duration (s) | GPS visibility | |---|---|---|---|---|---|---|---|---| | 5 | 0 | 45 | 0 | 10 | 0 | 0 | 250 | 1 | This command is of type 5. Command type 5 defines attitude change and absolute velocity. In this case, the pitch angle will be increased by 45deg, and the velocity along the x axis of the body frame will be accelerated to 10m/s. This command should be executed within 250sec. | command type | yaw (deg) | pitch (deg) | roll (deg) | vx_body (m/s) | vy_body (m/s) | vz_body (m/s) | command duration (s) | GPS visibility | |---|---|---|---|---|---|---|---|---| | 3 | 90 | -45 | 0 | 0 | 0 | 0 | 25 | 1 | This command is of type 3. Command type 3 defines attitude change and velocity change. In this case, the yaw angle will be increased by 90deg, which is a right turn. The pitch angle is decreased by 45deg. The velocity of the vehicle does not change. This command should be executed within 25sec. The following figure shows the trajectory generated from the motion commands in the above table. The trajectory sections corresponding to the above three commands are marked by command types 1, 5 and 3.