- Notifications
You must be signed in to change notification settings - Fork1
aerotinez/AHRS
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Bienvenue!/Welcome!
This repository is for anyone wishing to try out the MPU-9250 9-axis IMU + magnetometer connected through Arduino in MATLAB. The main codes can be found in/src/
.
Make sure you have theMATLAB support package for Arduino hardware installed. Followthese tutorials to learn how to set up your Arduino in MATLAB andthis tutorial from MathWorks to learn how to connect your MPU-9250 to your Arduino board. Clone this repository and you're ready to go!
Each algorithm has a.StartUI()
method which displays a real-time animation of your connected MPU-9250. For example, to use run UI with the Extended Kalman Filter ahrs you could do:
% don't forget to add the source code to your pathaddpath("<~/path-to-/AHRS/src/>");% create arduino and MPU9250 objectsa= arduino('<your-serial-port>','<your-board>','Libraries','I2C');ts=0.01;% sample timefs=1/ts;% sample frequency (rate)imu= mpu9250(a,'SampleRate',fs,'SamplesPerRead',1,'OutputFormat','matrix');% call the ekfahrs= EKF();% input your imuahrs.SetIMU(imu);% call the UI and enjoy!ahrs.StartUI();
Want to filter a set of MPU-9250 readings offline? No problem! Make sure your sensor data is stored in n-by-3 matrices and use the.Filter()
method of the filter you wish to use! The filtered result is output as an n-by-3 matrix of Tait-Bryan/Euler angles in degrees ordered as[roll, pitch, yaw]
. Make sure to set the sample time for your data in your chosen filter usingahrs.SetSampleTime(<your sample time here>)
.
ahrs= EKF();filtered_data=ahrs.Filter(accel_data,gyro_data,mag_data);
Additionally, once you have your filtered data, you can plot it using.Plot()
and even compare it with data from another filtering method.
% plot your filtered datafig=ahrs.Plot(filtered_data);clearvarsfig;% plot your most recently filtered data against other baseline data to compare filter performacefig=ahrs.Plot(filtered_data,other_filtered_data);
You can calibrate your MPU-9250's magnetometer for hard and soft iron biases by simply calling the.MagCal()
method of any AHRS algorithm in/src/
!
% ^^ ...setup your arduino and mpu9250 objects as shown before% choose any filter algorithmahrs= EKF();% input your imuahrs.SetIMU(imu);% call MagCal and follow the instructions in the console for 60 secondsahrs.MagCal();% the resulting calibrations will be given in microTesla for the hard iron% bias vector and as a 3x3 scaling matrix for the soft iron bias
- quaternion-based extended kalman filter
EKF.m
- add end & pause buttons to
UI.m
- add bias estimation & compensation to
EKF.m
- complementary filter
- mahony filter
- madgwick filter
- UKF?