micropython-IMU / micropython-fusion

Sensor fusion calculating yaw, pitch and roll from the outputs of motion tracking devices
MIT License
325 stars 70 forks source link

Calibration and IMU DLPF settings #8

Open csebe12 opened 4 years ago

csebe12 commented 4 years ago

Dear Peter,

I am working on an off-road robot that uses a gps module and the MPU9250 to navigate between waypoints. I am using your library for the MPU9250 together with this library to get readings for heading, and I'm trying to set up a PID controller to get to the waypoints. I have a couple of questions regarding this setup.

Best regards, Ben

peterhinch commented 4 years ago

The problem with calibration is the magnetometer. The accel and gyro will behave consistently over long periods of time. But the mag is a sensitive beast and you will need to calibrate it repeatedly - it will throw fusion way out if this isn't done.

The fusion calibrate method is intended to help you do this. You may need to go through the process each time you move the robot to a new location. In conjunction with the physical movement of the sensor around the axes it works out the local bias enabling the fusion algorithm to compensate. The physical position of the IMU is critical: don't locate it anywhere near high current wiring e.g. to the wheel motors.

Those rates sound high, but it all depends on the target hardware - what processor are you using? I'm surprised you've resorted to threading: can you not just query the fusion algorithm on demand, letting the PID run as fast as possible? Or use the asynchronous version?

Re the LPF I found a big issue is vibration. In my balancing robot (which is not off-road) I had to develop a mechanical LPF (a mass, rubber mounted) to stop vibration from overwhelming the PID. Filtering is something of a trial-and-error process. Especially for off-road work - something I've never tried. I can imagine distinguishing between vibration and off-road movement is difficult. See the notes in the doc about sampling theory.