main content

imu sensor fusion with simulink -凯发k8网页登录

this example shows how to generate and fuse imu sensor data using simulink®. you can accurately model the behavior of an accelerometer, a gyroscope, and a magnetometer and fuse their outputs to compute orientation.

inertial measurement unit

an inertial measurement unit (imu) is a group of sensors consisting of an accelerometer measuring acceleration and a gyroscope measuring angular velocity. frequently, a magnetometer is also included to measure the earth's magnetic field. each of these three sensors produces a 3-axis measurement, and these three measurements constitute a 9-axis measurement.

attitude heading and reference system

an attitude heading and reference system (ahrs) takes the 9-axis sensor readings and computes the orientation of the device. this orientation is given relative to the ned frame, where n is the magnetic north direction. the ahrs block in simulink accomplishes this using an indirect kalman filter structure.

simulink system

open the simulink model that fuses imu sensor data

open_system('imufusionsimulinkmodel');

inputs and configuration

the inputs to the imu block are the device's linear acceleration, angular velocity, and the orientation relative to the navigation frame. the orientation is of the form of a quaternion (a 4-by-1 vector in simulink) or rotation matrix (a 3-by-3 matrix in simulink) that rotates quantities in the navigation frame to the body frame. in this model, the angular velocity is simply integrated to create an orientation input. the angular velocity is in rad/s and the linear acceleration is in m/s^2. because the ahrs has only one input related to translation (the accelerometer input), it cannot distinguish between gravity and linear acceleration. therefore, the ahrs algorithm assumes that linear acceleration is a slowly varying white noise process. this is a common assumption for 9-axis fusion algorithms.

true north vs magnetic north

magnetic field parameter on the imu block dialog can be set to the local magnetic field value. magnetic field values can be found on the or using the wrldmagm function in the aerospace toolbox™. the magnetic field values on the imu block dialog correspond the readings of a perfect magnetometer that is orientated to true north. therefore, the orientation input to the imu block is relative to the ned frame, where n is the true north direction. however, the ahrs filter navigates towards magnetic north, which is typical for this type of filter. therefore, the orientation input to the imu and the estimated orientation at the output of the ahrs differ by the declination angle between true north and magnetic north.

this simulation is setup for latitude and longitude. the magnetic field at this location is set as [27.5550, -2.4169, -16.0849] microtesla in the imu block. the declination at this location is about

simulation

simulate the model. the imu input orientation and the estimated output orientation of the ahrs are compared using quaternion distance. this is preferable compared to differencing the euler angle equivalents, considering the euler angle singularities.

sim('imufusionsimulinkmodel');

estimated orientation

the difference in estimated vs true orientation should be nearly , which is the declination at this latitude and longitude.

gyroscope bias

the second output of the ahrs filter is the bias-corrected gyroscope reading. in the imu block, the gyroscope was given a bias of 0.0545 rad/s or 3.125 deg/s, which should match the steady state value in the gyroscope bias scope block.

further exercises

by varying the parameters on the imu, you should see a corresponding change in orientation on the output of the ahrs. you can set the parameters on the imu block to match a real imu datasheet and tune the ahrs parameters to meet your requirements.

网站地图