Estimate orientation from recorded IMU data by using a complementary filter, represented by an insCF filter object.
Load the rpy_9axis.mat file into the workspace. The file contains recorded accelerometer, gyroscope, and magnetometer sensor data from a device oscillating in pitch (around the y-axis), yaw (around the z-axis), and roll (around the x-axis). The file also contains the sample rate of the recording. Extract the sensor data and sample rate from the loaded workspace variable.
Create a timetable from the accelerometer, gyroscope, and magnetometer data.
Create an insCF filter object using sensor models for accelerometer, magnetometer, and gyroscope. To model orientation, specify insCFMotionOrientation as the motion model.
Specify the initial orientation of your sensors. You can obtain the initial orientation by using the ecompass function with the accelerometer and magnetometer data at the first time step.
Specify the sensor gains. The sensor gain value must be between 0 and 1.
Fuse the accelerometer, gyroscope, and magnetometer data using the insCF filter.
Visualize the estimated orientation.