Using a pixhawk with ardupilot to measure heading and geocoordinates

Dear all
This is my first post on this forum though i have been referring to questions asked by others for solving issues i face. I am not too familiar with Ardupilot but i’m in the process of learning to communicate with autopilots using Mavlink .

I am in the process of using a pixhawk 2.4.8 (I think its a clone) with Ardupilot 4.5.4 stable (copter) for an entirely different application which is to measure bearing of an object at a distance ( up to 2000m away ) accurately. The device has a holybro M10 compass and GPS module connected to the Pixhawk and the Pixhawk is again connected to a raspberrypi4. A viewing monocular scope is fitted on the device and the axis of the monocular scope and the compass module are fully aligned.

The Rpi continuously receives message stream from the Pixhawk and three values are parsed . These are ‘hdng’ , ‘lat’ and ‘lon’ from the ‘GLOBAL_POSITION_INT’ message. (I know that using a Pixhawk is absolutely avoidable and the compass module could have been directly connected to the rpi. i did this for the ease of use and also i didnt find any libraries to integrate the IST8310 compass with Rpi)

In order for this device to work well the compass is to have a very accurate reading . Though I am getting readings with two decimal places , I see that there is a varying error of 2 to 3 and sometimes 4 degrees in the readings. At times the heading readings are accurate. it is to be noted that on a given measurement time i get consistent readings on the same feature. ie, consistent errors. on a different day the errors would be different. a feature which gives correct reading on one day may give a wrong reading on an other day. Sometimes these inaccuracies are due to presence of large metallic objects next to it like my car and sometimes there are no apparent reasons for the readings to be wrong. I have set the compass auto declination on and the declination value being used by the AC seems to be very close to that in my region.

There are no motors or ESCs on this device to create too much magnetic interference . only one lipo battery and raspberry pi.

compass_orient is 6 since the holybro data sheet says it is to be kept so for compass calibration to succeed even if the pixhawk and M10 module have their arrows aligned to same direction.

I have not disabled the internal compass ( pixhawk im using has one internal compass) but the compass_auto_rot is set to 2

I must admit that I have used a T6 Aluminum machined adaptor to integrate all stuff together. From what I understood, T6 aluminum is non ferrous and non magnetic and is not likely to cause any magnetic interference but im not sure. also the viewing monocular scope has a machined aluminum casing which is pretty close to the compass.

Following are my doubts

  1. Would the inaccuracies in the compass be due to presence of aluminium base . is there any way to determine magnetic interference . Documentation talks about compass motor calibration but that does not apply to me as i dont have any motors. is there any parameter i can use to minitor my interference other than by doing compass_mot calibration? would the x,y and z offsets give an idea? if yes which parameter to be monitored?

  2. Is the declination value corrected only when the copter is in flight ? in my case the pixhawk does not even Arm. I believe the GPS location is captured as soon as a 3D fix is obtained and the corresponding declination value is extracted from the look up table. but is it applied to the heading readings when the pixhawk is disarmed . Some discussions made me feel that corrections are applied to the compass readings only after the copter has taken flight. if thats the case , i would apply declination corrections in my rpi code after extracting the heading from Global position int message.

  3. The Pixhawk and my M10 compass/GPS module may not be a 100% aligned with each other. There may be a difference of up to Following are my doubts 2 degrees since its eyeball aligned. would that difference in angle cause any corrections to the measurements made by the external compass. i do not fully understand what compass_rot set to 2 does. Does it modify the reading of the compass. for example if my M10 compass is reading 210 and the heading of the pixhawk is 208 ( two degrees error in alignment) . will the compass reading be corrected by 2 degrees in the ‘hdng’ value provided by global_position_int message?

  4. I am using google maps to plot bearing lines from own position along the bearing angle to check for correctness . if the line passes through the building or feature i am seeing through the cross hairs of the scope , that would mean that my compass is accurate. but many a times , i miss the target by almost 100 m ( to anyone who may be getting this doubt, yes the axis of the monocular scope is perfectly aligned with the compass heading .

I would be very glad if someone could point me in the right direction so that I can make my compass point in the right direction.

if finally it boils down to a hardware limitation i would swap the compass with some other more accurate compass ( guidance on choosing a good compass module would also be a great help to me if this happens to be the case)

Thanks to all of you geniuses in advance
Atul

Interesting use case for Ardupilot :smiley: have you thought about using moving baseline RTK instead of a compass?

1 Like

Disable the pixhawk internal compass before you go any further. its notoriously unreliable.

1 Like

I did consider RTK for yaw measurement since ive heard that its pretty reliable but i do not have the budget to buy one and experiment :neutral_face:

@geofrancis thanks for the tip. ill definitely do that. But i’m not sure the readings of compass 2 ( the internal one ) is used for any corrections of compass 1. what i understand is its compared for consistency and an error is spit out in case both are having a mismatch in readings beyond a certain value. as of now i am not having any bad compass health issues. Kindly correct me if im wrong. Not withstanding ill still disable the internal compass.