Custom firmware - - Accelerometer calibration

Hello, I’m working on a thesis about automatic control and I’m using Eclipse, but I’m not sure if the readings I’m getting from the pixhawk are the best I can get, I think they would improve if the accelerometer is calibrated. I’m also getting drift from the yaw angle.

I have these questions.
If I calibrate the accelerometer using mission planner and then, I upload my code, the calibration will not work, right?
Is there a way to calibrate the accelerometer without using mission planner?
I mean, a simple code, using the functions from the library “AP_AccelCal”, I read it several times, but I didn’t undertand it very well, I’m not very good at programming.

This is the code I’m using to get the angles.

static AP_InertialSensor ins;

AP_AHRS_NavEKF ahrs(ins, barometer, gps, sonar);
AP_AHRS_DCM ahrs(ins, barometer, gps, sonar);

static AP_InertialNav_NavEKF inertial_nav(ahrs);

void setup()

void loop ()
roll = ToDeg(ahrs.roll);
pitch = ToDeg(ahrs.pitch);
yaw = ToDeg(ahrs.yaw);

gyro = ins.get_gyro();
phd = ToDeg(gyro.x);
thd = ToDeg(gyro.y);
psid = ToDeg(gyro.z);


Thanks in advance, I’m sorry if I didn’t express myself very well.

You can calibrate from a log. Basically, do the calibration, save the log file, flash your custom firmware, copy over offsets from the saved log.

Thanks for answering, could you be more specific? I did the calibration process, I got the calibration values, accel_cal_x, y, z, gyro_cal_x. etc. Where do I write these values?

After flashing your custom firmware, use a gcs (eg missionplanner) to show the full parameter list, find each of the calibration parameters and insert the values you’ve saved/written down, then write them to the flight controller (there are other ways to transfer the values across, but that is the easiest to explain).

I still don’t get it, I can’t use a gcs to show the full parameter, If I flash my custom firmware, I can’t connect the pixhawk with the mission planner, I also try to read the log file located in the custom firmware folder and I get an error “Log Browse will not function correctly without FMT messages in your log”.

Ok. The only time I’ve seen that FMT error is when the SD card was corrupted/incorrectly formatted. But if it’s working with a standard firmware and not your custom stuff, probably not that, so logging may be broken somewhere. Can you link your custom source? Someone like @peterbarker might be able to see the problem

Hello, what do you mean by link your custom source? do you want me to upload the file I use to flash the pixhawk?
If so, which file do you need?

Again, sorry for my bad English and thanks.

Your English is much better than my Italian!
I think I may have misunderstood you at the beginning though. It will be difficult for people to help from the compiled firmware: source code (the .cpp and .h files) will be needed.
It might be best to move this to Gitter

where some great technical support hangs out.

1 Like

Thank you so much for your support! I´ll move to that Gitter.

Hi Carlos,

I am looking to do the same as I am also using custom firmware.

Just wondering if you managed to get the calibration? I don’t mind doing my own calibration routine as it is pretty simple, but I am particularly interested in knowing how did you save the calibration for it to be the one that you specified after you restarted the system.