Open fralbo opened 3 years ago
I have the same issue in an aircraft, during a turn the value drifts due to the accelerometes detecing the gravity force being level and correcting the gyro, though it is not actually level.
Yes and I'm surprised that most of these chips and library are noticed to be usable on drones as its exactly the same problem on such vehicles as well.
I think we should only use gyro values, not quaternions or AHRS algorithm.
After we need a way to fix long-term drift of gyro integration. I though about magnetometer. Detecting a straight direction means that roll is equal to 0. That's enough for motorbike but for an aircraft, we also have to correct the pitch. Maybe with an altimeter.
Regards.
Le dim. 8 août 2021 à 20:21, georgegohl888 @.***> a écrit :
I have the same issue in an aircraft, during a turn the value drifts due to the accelerometes detecing the gravity force being level and correcting the gyro, though it is not actually level.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jrowberg/i2cdevlib/issues/586#issuecomment-894835727, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADWOCCMSIQGDGR4FRUGKEZLT33DLFANCNFSM45L33IEQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .
@fralbo Do you happen to know what algorithm hyperIMU uses for calculating the inclination?
Not exactly but it usually relies on Kalman filters or something like that which is basically a mix on gyrometers and accelerometers. That's fine for all vehicule turning flat but for motorbike or drone its absolutely wrong. So I now only use gyrometers as explained above.
My impression was that hyperIMU does what you would expect.
Below I made the same experiment at the same time on the same part of a road, in red with my smartphone using HyperIMU application and in blue with an Arduino Beetle connected to a GY-521 MPU6050 board. As you can see when I get a turn, driving at regular speed, the red curve is pretty horizontal meaning I keep the same inclination angle which is what I made.
Then it would be great to use the same algorithm with gyro and acc values from the mpu6050.
I tried and got the same results. Accelerometers are definitely not usable for banking vehicule.
@fralbo Do you have a code example. I would be really interested.
There is a possible solution
I have given 2 options and the second is easier but the first is necessary to explain why.
DMP has 2 modes DMP_FEATURE_LP_QUAT (Gyro Only) DMP_FEATURE_6X_LP_QUAT (Accelerometer and Gyro)
When I created the DMP Image instance I set the DMP_Feature to the Accelerometer and Gyro Quaternion calculations.
So How do I Change this :)
Well, it's easy... I hope This is for V6.12 of the DMP image.
Just after loading the DMP (Next line of code) image into the MPU6050 Memory but before starting it up
if (!writeProgMemoryBlock(dmpMemory, MPU6050_DMP_CODE_SIZE)) return 1; // Loads the DMP image into the MPU6050 Memory // Should Never Fail <<< Loads the DMP Image
Let's make some changes as follows:
#define CFG_8 (2718)
#define CFG_LP_QUAT (2712)
unsigned char regs[4];
// Disable DMP_FEATURE_6X_LP_QUAT
memset(regs, 0xA3, 4);
mpu_write_mem(CFG_8, 4, regs);
// Enable DMP_FEATURE_LP_QUAT
regs[0] = 0xC0;
regs[1] = 0xC2;
regs[2] = 0xC4;
regs[3] = 0xC6;
mpu_write_mem(CFG_LP_QUAT, 4, regs);
//This is the function example needed to write to a specific byte of memory in the DMP Image loaded into the MPU6050
int mpu_write_mem(unsigned short mem_addr, unsigned short length, unsigned char *data){
unsigned char tmp[2];
if (!data) return -1;
if (!st.chip_cfg.sensors) return -1;
tmp[0] = (unsigned char)(mem_addr >> 8);
tmp[1] = (unsigned char)(mem_addr & 0xFF);
I2Cdev::writeBytes(devAddr,0x6D, 2,tmp) // sets the mem location to write to in the DMP Image
I2Cdev::writeBytes(devAddr,0x6F, 2,data) //What to change
return 0;
}
The above code is derived from the Invensense example and additional modifications will likely be needed to get the writeBytes functions to work with Jeff's library.
Alternative Easier option
replace Bank 10 of DMP V6.12 (Lines 311 to 327) with the following changes already added to the DMP image prior to loading (Not Tested!! Sorry.)
/* bank # 10 */
0x9A, 0x08, 0x10, 0xB7, 0x9F, 0x10, 0xD8, 0xF1, 0xB0, 0xBA, 0xAE, 0xB0, 0x8A, 0xC2, 0xB2, 0xB6,
0x8E, 0x9E, 0xF1, 0xFB, 0xD9, 0xF4, 0x1D, 0xD8, 0xF9, 0xD9, 0x0C, 0xF1, 0xD8, 0xF8, 0xF8, 0xAD,
0x61, 0xD9, 0xAE, 0xFB, 0xD8, 0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xBB, 0xB3, 0xB7, 0xF1, 0xAA, 0xF9, 0xDA, 0xFF, 0xD9, 0x80, 0x9A, 0xAA, 0x28,
0xB4, 0x80, 0x98, 0xA7, 0x20, 0xB7, 0x97, 0x87, 0xA8, 0x66, 0x88, 0xF0, 0x79, 0x51, 0xF1, 0x90,
0x2C, 0x87, 0x0C, 0xA7, 0x81, 0x97, 0x62, 0x93, 0xF0, 0x71, 0x71, 0x60, 0x85, 0x94, 0x01, 0x29,
Z
@fralbo Do you have a code example. I would be really interested.
The code is in my first Post.
@ZHomeSlice that's very interesting. I switched to ICM-20948, I'll take a look to see if there is a similar option.
Hello, I have a strange situation using your library to read inclination angle on a motorbike. Below I made the same experiment at the same time on the same part of a road, in red with my smartphone using HyperIMU application and in blue with an Arduino Beetle connected to a GY-521 MPU6050 board. As you can see when I get a turn, driving at regular speed, the red curve is pretty horizontal meaning I keep the same inclination angle which is what I made. But strangely, the measure I get on MPU6050 seems to slightly drift to zero. I precise that everything is fine when I move to the board on my desk. The problem only occurs when I use it on my motorbike and I guess it could be caused by a "high" gravity force during the turn which could cause the anti-drift feature to overload the gyro reading. As you can see the offset the problem causes during the turn is more or less found on the next turn (h).
At the moment, I didn't make the same test with another library but do you think it could be caused by your lib or internally in the MPU6050 ?
My code is the following one: