kriswiner / MPU9250

Arduino sketches for MPU9250 9DoF with AHRS sensor fusion
1.03k stars 471 forks source link

MPU9250_BasicAHRS with MPUTeapot #301

Open rkuo2000 opened 6 years ago

rkuo2000 commented 6 years ago

Hi, I have modified MPU9250_BasicAHRS to support MPUTeapot my code is in https://github.com/rkuo2000/arduino/tree/master/examples/MPU9250_BasicAHRS

I don't connect to LCD, so I removed LCD display part, and added teapot packet Serial.write ( line #427)

ifdef OUTPUT_TEAPOT // for Teapot Packet

// display quaternion values in InvenSense Teapot demo format:         
teapotPacket[2] = int(q[0] * 16384) >>8;
teapotPacket[3] = int(q[0] * 16384) & 0x00ff;
teapotPacket[4] = int(q[1] * 16384) >> 8;
teapotPacket[5] = int(q[1] * 16384) & 0x00ff;
teapotPacket[6] = int(q[2] * 16384) >> 8;
teapotPacket[7] = int(q[2] * 16384) & 0x00ff;
teapotPacket[8] = int(q[3] * 16384) >> 8;
teapotPacket[9] = int(q[3] * 16384) & 0x00ff;
Serial.write(teapotPacket, 14);     
teapotPacket[11]++; // packetCount, loops at 0xFF on purpose                     

else // for Teapot Packet

if(SerialDebug) {

...

The MPUTeapot can display 3D plane rotating according to the quaternions, but it seems the yaw will be drifting, the quaternions print out show it is dripping too (both MPUTeapot.pde & MPU9250_BasicAHRS.ino)

But when I use MPU9250 DMP quaternions, it is not drifting and very stable. https://github.com/rkuo2000/arduino/tree/master/examples/MPU9250_DMP_AHRS Could you tell where the problem could be ?

Richard

kriswiner commented 6 years ago

No, but how did you calibrate your sensors?

On Mon, Jul 30, 2018 at 9:22 PM, Richard Kuo notifications@github.com wrote:

Hi, I have modified MPU9250_BasicAHRS to support MPUTeapot my code is in https://github.com/rkuo2000/arduino/tree/master/examples/ MPU9250_BasicAHRS

I am using nodeMCU, so I removed LCD display part, and added teapot packet Serial.write ( line #427)

ifdef OUTPUT_TEAPOT // for Teapot Packet

// display quaternion values in InvenSense Teapot demo format: teapotPacket[2] = int(q[0] 16384) >>8; teapotPacket[3] = int(q[0] 16384) & 0x00ff; teapotPacket[4] = int(q[1] 16384) >> 8; teapotPacket[5] = int(q[1] 16384) & 0x00ff; teapotPacket[6] = int(q[2] 16384) >> 8; teapotPacket[7] = int(q[2] 16384) & 0x00ff; teapotPacket[8] = int(q[3] 16384) >> 8; teapotPacket[9] = int(q[3] 16384) & 0x00ff; Serial.write(teapotPacket, 14); teapotPacket[11]++; // packetCount, loops at 0xFF on purpose

else // for Teapot Packet

if(SerialDebug) { ...

The MPUTeapot can display 3D plane rotating according to the quaternions, but it seems the yaw will be dripping, the quaternions print out show it is dripping too (both MPUTeapot.pde & MPU9250_BasicAHRS.ino)

But when I use MPU9250 DMP quaternions, it is not dripping and very stable. Could you tell where the problem could be ?

Richard

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/301, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qjUNJ1uaFyPtJIjADEoL3s1y7ijlks5uL9uFgaJpZM4Vnk1k .

rkuo2000 commented 6 years ago

I did not modify calibrateMPU9250, let me look into the calibration, thanks for the direction :D

kriswiner commented 6 years ago

If you are using the old basic code it doesn't do magnetometer calibration, so you will need to add this to get any kind of accuracy and stability.

On Mon, Jul 30, 2018 at 11:35 PM, Richard Kuo notifications@github.com wrote:

I did not modify calibrateMPU9250, let me look into the calibration, thanks for the direction :D

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/301#issuecomment-409111256, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qtVgBdFLkzDgRL2DC2tZe-Jd3QFPks5uL_rDgaJpZM4Vnk1k .

rkuo2000 commented 6 years ago

Yes, after adding magcalMPU9250, just a little drifting shown on Teapot now :D For the little yaw drifting, maybe I did not do it well in figure-8 ? I test it with a magnet, it looks immune to me.

My modified code is based on MPU9250_MS5637_AHRS_t3.ino MS5637 and Interrupt are commented, and added Teapot packet https://github.com/rkuo2000/arduino/tree/master/examples/MPU9250_BasicAHRS2

kriswiner commented 6 years ago

I would run the sensors (at least the gyro) at 500 or 1000 Hz sample rate and make sure your MCU is able to achieve at least 4 kHz fusion rate for best results. Of course, you need to make sure the accel and gyro bias offsets are corrected as well.

On Wed, Aug 1, 2018 at 1:52 AM, Richard Kuo notifications@github.com wrote:

Yes, after adding magcalMPU9250, just a little dripping shown on Teapot now :D For the little yaw dripping, maybe I did not do it well in figure-8 ? I test it with a magnet, it looks immune to me.

My modified code is based on MPU9250_MS5637_AHRS_t3.ino MS5637 and Interrupt are commented, and added Teapot packet https://github.com/rkuo2000/arduino/tree/master/examples/ MPU9250_BasicAHRS2

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/301#issuecomment-409501681, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qiK9kNLBdyOAWQnOHlA5lZ1YtmeSks5uMWw4gaJpZM4Vnk1k .

rkuo2000 commented 6 years ago

I will look into those bias and calibration, thanks !