jremington / ICM_20948-AHRS

Mahony Fusion Filter and Tilt compensated compass for ICM_20948
32 stars 7 forks source link

Calibration question #10

Closed pitchuk closed 5 months ago

pitchuk commented 5 months ago

Firstly thanks for putting this all together. I have run the ICM_20948_get_cal_data.ino and saved the data into two .csv files. I am running the python code with py [mypath to file]\calibrate3.py but it errors with

raise FileNotFoundError(f"{path} not found.") FileNotFoundError: mag3_raw.csv not found.

I can't seem to fine any information on the naming and where the relative path should be. Could you please help. I am sure I am doing somthing silly.

jremington commented 5 months ago

I simply run the program from the command line, after setting setting the default directory to the one containing the data. Otherwise, you either have to add the full path of the data file into the Python code, or edit the Python code to interactively ask for and accept a data file name containing the full path.

pitchuk commented 5 months ago

Hi jremington, thanks for the quick response. I have the two files in the same folder, is that right? or is there a addition to the cmd line that states the path? I did try briefly the Code::Blocks IDE as well but it wanted a complier and there where a lot of pointions and normally more comfortable with python

jremington commented 5 months ago

On Windows I issue the appropriate cd command to set the path to the data directory, before running the Python program.

pitchuk commented 5 months ago

That was it! I didn't change directory, and called calibrate3 with full path.

It reads the mag3_raw.csv file and outputs the code to paste for the mag, should there also be accelerometer and gyro calibration?? I did create a acc3_raw.csv file too but don't think it did anything with this

jremington commented 5 months ago

The program reads only the one file named in the code. Change the file name in the code to read the acc3 file.

Gyro calibration is normally done by collecting a few hundred readings while the sensor is held still. Average the values for each axis, which are the offsets to be subtracted from subsequent readings.

pitchuk commented 5 months ago

Hi jremington, I feel I am getting a little confused again.

The ICM_20948_tiltcomp.ino has 4 floats A_B, A_Ainv, M_B, & M_Ainv. The calibrate3.py generates the M_B, & M_Ainv. How do I generate A_B & A_Ainv or is this not needed?

From just calibrating the magnetometer it is out from true north but stable. I guess I could do an offset for this. Howver if I tilt the IMU-20948 45 deg it increases the heading over 120deg

Basically all I really wish is to get an accurate compass direction within a degree or 2. I also have an LSM9DS1 which I tink you also have code for if it is better chip?

Thanks

jremington commented 5 months ago

For best results calibrate the magnetometer and accelerometer independently.

The procedure is the same for both, and you get two results (a set of offsets and a matrix) for each sensor. So, four results total.

pitchuk commented 5 months ago

Thank you for all you help. I think i have my head around everything