SRA-VJTI / sra-board-component

ESP-IDF component for SRA Board
https://sravjti.in/sra-board-component/
MIT License
36 stars 20 forks source link

MPU calibration #71

Closed RISHI27-dot closed 1 year ago

RISHI27-dot commented 2 years ago

Calibrate the MPU6050 before use to account for the initial position.

Calculate the offset using the average of the initial 200 raw accelerometer and gyroscope readings. Take this offset out of each new raw value read.

RISHI27-dot commented 1 year ago

I am unclear about how calibration according to the given example will help to account for the initial position of the MPU. I have written code according to the given example but that results in very bad self balancing.

My understanding of calibration is that when the bot is standing upright the pitch and roll values should be 0 but due to fault in initial readings of MPU, we get 1-2 degree of deviation. Calibration should account for this deviation. So this is how we will do calibration (according to me): - Hold the bot upright initially and average out the initial 200 raw value reading and subtract the reading from all the future raw values read.

@gautam-dev-maker is the approach I am following correct ?

gautam-dev-maker commented 1 year ago

Why hold the bot upright, sra-board-component is independent of Wall-E. The aim of calibration is just to provide the value of offset in IMU. The value of offset doesn't change with the position of bot, it's rather constant (or supposed to be).

The offset may be there because of loose fit of mpu6050.

In your approach you are calibrating everytime when read_mpu() function is called, this makes the read_mpu() extremely slow. Has this been tested?

when to call the calibration function should be the choice of programmer, instead of calling it in read_mpu().

I hope this clears your doubt. (Note : For it's application in self-balancing, the offset needs to be accounted in the algorithm, therefore it is not the concern of this issue or this repository for that matter.)

RISHI27-dot commented 1 year ago

In your approach you are calibrating everytime when read_mpu() function is called, this makes the read_mpu() extremely slow. Has this been tested?

Calibration is only performed once, and the static parameter calc_offset ensures this. As a result, the read_mpu() function is not slowed down by this.

I hope this clears your doubt.

yes.