Implementing Per-Motor Calibration

Hi!

I am curious as to whether it would be possible to make the per-motor calibration procedure used by the SkyViper accessible to normal users. I have looked through the code and seen that this calibration is enabled in motor_test.cpp where motor_test_throttle_type is set to MOTOR_TEST_COMPASS_CAL, but I can’t seem to find the declaration of this enum in the mavlink docs. If I understand correctly, what I would have to do to initiate this calibration is send a mavlink command mavlink_motor_test_start() with the throttle_type uint_8 set to the right value and it will perform the test, saving the updated per-motor compass corrections.

  1. Is this accurate?
  2. Will this functionality be added to Mission Planner any time soon?

Thanks!

1 Like

Hello? Can anyone help with this?

Hi Peter,

OK, not sure how this works actually so I’ll get the info from @tridge and update the wiki.

1 Like

Thanks! I was actually able to find the enum I was looking for in Mavlink 2.3. I was able to initiate the calibration by connecting through mavproxy and running:
motortest 1 3 40 5 4
This spins up each motor in sequence per the MAV_CMD_DO_MOTOR_TEST definition.

It would be helpful to add this to the wiki though. Let me know if I can help by adding it.

2 Likes

OK great! I’ve added an issue for the Mission Planner to add support for this.

It’s perhaps too much to expect normal users to kick it off using mavproxy so perhaps once we have the MP screen we should extend the wiki and/or make a video to demonstrate the process.

@tridge I was reading through AP_Compass_Backend.cpp and wanted to confirm that the intended functionality is to prefer use of per-motor calibration over compass-motor calibration. If that is true, performing a compass-mot calibration is pointless if one is has enabled the per-motor compass calibration.

The comment also says “only valid for first compass.” I would like to use my external compass with the per-motor calibration. How would I go about configuring this compass to be used with per-motor calibration?

Any news for per motor compass calibration in MP? I think its not possible to do in MP yet, isn’it?

I’ve try to set COMPASS_PMOT_EN to 1 and perform the usual compassmot in MP, but the procedure its the same and also the relative value COMPASS_PMOT are all at 0, so its not working.

Hi I’ll share here some things I had to guess to use this nice functionality, with MAVProxy it’s quite simple.

The drone needs to be secured like for compass motor with props able to spin.

To start a per motor calibration in the mavproxy command line you can type (this will immediately arm the motors in sequence):

motortest 1 3 10 5 4

The parameters to keep an eye on are the 3rd and the 4th which are throttle % and sampling time in seconds (the above will run the motors at 10% for 5 seconds each).
If you have more than 4 motors you can change the last parameter, but I don’t know if it’s supported because I can only see parameters for 4 motors.

In my case it worked to just run it at 100% throttle for 10 seconds.
When the procedure ends it automatically saves the offsets per motor in COMPASS_PMOT*_* parameters and enables this calibration with COMPASS_PMOT_EN = 1 (which disables standard compass mot offsets).

Another parameter to set manually is COMPASS_PMOT_EXP which defaults to 0.65 and is not set by the motor test procedure.
This exp is used in this formula to map the correction of each motor on its thrust (from 0 to 1):

compensation * ( (battery_voltage * thrust) ^ exp )

//compensation = COMPASS_PMOT*_* parameters

To calculate this expo I sampled each motor at various throttle percentages (25% - 50% - 75% - 100%) and then I tried to fit an exponential curve to those samples (in particular to the Z axis ones, starting from the motor with the biggest offset).


(the red curve is obtained using offset_z_at_100throttle * current_throttle ^ expo)

I looked also a the graphs for the other 3 motors and I found that an exponent of 1.5 fits nicely with my data so i set COMPASS_PMOT_EXP = 1.5


I hope that someone can confirm that this is the right way to set it.
If that’s the case maybe this can be added to the wiki.

1 Like