How sensor fusion works? - Simple explanation
ฝัง
- เผยแพร่เมื่อ 9 ก.พ. 2025
- Here i have shown how a simple sensor fusion is carried out, I have used a very basic filter called the complementary filter, it gives a good response for a cheap computation, ideal for low power microcontrollers such as the esp32.
Code link: github.com/pra...
I might understand it wrong, but if gyro is drifting wont it still drift in this case just at slower rate? If θg is angle we get from integration it will keep increasing no matter what gain you set. I feel like the solution would be adding the difference between θg and θa multiplied by some gain directly into integration loop.
In the math I did, I didn’t mention how I calculated the theta g, we need the theta new to add back into the theta g to complete the integration, also the theta from the accelerometer gives like a downward force to pull down the drift.
So you are receiving data from gyro&accel sensors you should not hook it up to a DJI Mini2 and use this for a baseline. I spent a lot of time building "quadcopters" 2006-2010 and lost interest, never built up a FPV but always knew the camera would help, maybe? So I bought the DJI Mini2 in 2023 and what a game changer but all data collected is sent to the CCP(DJI) and when I figured this out I have decided to not give in to the CCP and am waiting for an affordable US made alternative. The cameras are so stable too! There is only a noticeable drift on the Mini2 if you have a 10mph crosswind. I like that you are using th ESP32!
I also added a math showing what happens in the code exactly, here's the link [ imgur.com/a/m8ppLvm ]and i added an annotation on the video as well.
Vector compensation
I've just discovered a gold mine! Thanks a ton for this amazing video!
I'm glad you found it helpful!
My mentor mentioned this. He said since the gyro is so stable, we should give it the highest gain. Thats the theory. The truth is im still running kalman and if complementary it still depends on the system and other elements. This is cool
Glad that you found it cool!
@pratikphadte do you have the tilting issue with this approach? I found that if your drone tilts the angle pid will help, but in my tuning it seems no matter how high p angle is, to the oscillation point, it takes the left side super slow to recover to balance, even with d, compared to the right side which causes the tilt. I cant fix this tilting drifting issue at all. There is no middle point its either too weak/slow or just oscillate. I see you kept pid angle default as 2 0 0 and limit it on that shaft until rate is stable then come back to angle until stable?
@@yenle7296 I think the tilting issue is due to the poor IMU calibration, if its not that then i think it could also be due to the complementary filter gain, however, most of the errors should reduce significantly in the IMU calibration step, my drone stopped tilting when i calibrated the IMU properly.
@@pratikphadte i only calibrated using carbon aeronautic tutorial. I used his code to wait for 2 seconds and minus raterollcalibration. For acceleration i add and minus some numbers to get all 3 axis to 1g. In your new code you dont use this but i saw you plus minus some numbers right away how did you get it?
@ i did a simple calibration, where I only calibrated the gyro and the accel Z axis. It’s same method as that of CA
Great explanation bro
👌👌👌
Glad you liked it!
Awesome 🔥
Thanks!
Are you following the Carbon Aeronautics manual?
What’s the cost of your setup?
Hi i am not an expert but i have intrest in electronic to reduce the drift you can use the acceleration data from the other to axis like when you are moving the drone and input stop use the accelerometer to check for the velocity in x and y direction and cancel it out till net velocity is not zero give it retardation and calculate the distance traveled and try to go back and add damping to stablelize
Hi, thanks that idea seems logical, the complementary filter does similar stuff , it tries to add and subtract the drift from the gyro.
The idea you mentioned about x and y axis , is it ideal for a ground robot? Also can you share some examples to look for , just for me to understand
Can you make a video, on how to filter out noise from IMU sensor using low pass filter ?
This video is a way to combine a high pass and low pass filter, the gyro is high pass and the accel is low pass. This is filtering in one way
kya aap ko hindi aati hai,
main bhi ek quadcopter drone bana rah hau jisme main ne MPU9250 and ESP32C2 borad use kar raha hau
kya aap meri help kar sakate hai?
bhaiiii sexyyy kya explain kiya hai ! I wish you were my teacher back in college
Thank you! Glad you liked it!
So you are receiving data from gyro&accel sensors you should now hook up to a DJI Mini2 and use this for your baseline. I spent a lot of time building "quadcopters" 2006-2010 and lost interest, never built up a FPV but always knew the camera would help, maybe? So I bought the DJI Mini2 in 2023 and what a game changer but all data collected is sent to (thru) the CCP(DJI) and when I figured this out I have decided to not give in to the CCP and am waiting for an affordable US made alternative. The DJI cameras are so stable too! There is only a noticeable drift on the Mini2 if you have a 10mph crosswind. DJI is who you want to try and use for what to end up with, I like that you are using the ESP32!
Yeah, i mainly work towards the learning aspect, and for people who want to get in drones in an affordable manner.
DJI is a closed system and is the best out there.
Hi prathik could u please check mail?
Yes! I did!
useless video dude! i don't know what you were aiming to present in it
Oh damn, my bad that it didnt convey the message, i was trying to explain how you can get good angles by fusing 2 sensors.