Compass power calibration script fails

I am attempting to do the compass power calibration, and have made a log I want to analyze. I download the script mag_compensation.py from Github, but when I run it I get an error:

File “C:\mag_compensation.py”, line 73
PX4-Autopilot/mag_compensation.py at release/1.13 · PX4/PX4-Autopilot
^
SyntaxError: invalid character ‘·’ (U+00B7)

Am I missing some Python dependencies? I am not able to find out.

Have a look at line 73 in the script. Apparently there is a character there that it doesn’t understand.

Thanks, but that doesn’t make sense. I am using the script just downloaded from Github, so I would expect it should not be wrong

Could it be that you downloaded the html file rather then the raw Python file?

How embarrasing :man_facepalming:
Thanks for pointing out the error done by many others.

Now I am starting to get the real challenges. It appears my logs don’t have the same topics as the older logs that this script is based on. Instead of “sensor_mag.00.x”, it uses the format “vehicle_magnetometer.00.magnetometer_ga.00” and so on. I tried changing the topic name and variable names but it appears it doesn’t get the data from the magnetometers (it doesn’t go into the if statements starting at line 116).

I get no error message, but the output is:

←[91m
current-based compensation: ←[0m

param set CAL_MAG_COMP_TYP 2

The the scripts exits.

The same thing happens for thrust-based compensation (except that CAL_MAG_COMP_TYP 1 is stated). I suspect it may have something to do with the variable “timestamp” that I am not able to find in most topics and it appears the script is looking for it, but I am not sure.