I have problems configuring Pixhawk and external GPS (Ublox Neo-M8N). I can not arm pixhawk due to “Compasses inconsistence” error message -> internal and external compasses are pointing in different directions (>45º). Calibration is well done, so the questions that can help me to debug the problem are:
How can I get the external and internal compass direction, just to check they are different?
When I calibrate the compass, there are 2 green bars that advance from left to right. Both in the same direction. Finally I got an offset values (x,y,z). What does these values means (I thought compass provided only the direction relative to the geographic “cardinal directions”, so only 1 value)?.
In the compass calibration the arrow in the Pixhawk and arrow in the GPS plastic enclosure are pointing at the same point (GPS cable in the back). Before disable internal compass, I would like to assure the right value in the orientation. Could someone confirm “Rotation none” is the correct value (compass menu - compass#1 box)?
You can check compass orientation using the method described at the link below. You can see these when connected to the copter via Mission Planner (or other ground station) and looking at the mx, my, mz (external), and mx2, my2, mz2 (internal) values. In Mission Planner they’re in the status tab.
The “compass” is actually a three axis magnetometer. The offsets are the magnetic offsets in all three axes. Are any of them high, say over 100 counts? High values indicate magnetic interference near the compass.
It sounds like the compass orientation is set correctly. If both arrows are pointed the same direction it should be “Rotation None”. 99% of the time the direction arrows are correct, but if you’re running into problems don’t trust them (I had one mis-marked from an unnamed overseas seller). So double check using the method above if you’re not getting correct results with “rotation none”.
The offsets are lower than 100 in compass#1: -97,-56, 30 (x,y,z). Compass#2: -465, -34, 196 (x,y,z). I have calibrated using fitness Relaxed.
On the other hand, I have followed the “Checking compass orientation” and I guess something is wrong. Let me explain and include some examples:
Ardupilot guide mentions: “Z-component should be positive - when pitching the vehicle down”. In my case when I pitch down, X components increase (Z components are positive). mx=blue, mx2=yellow, mz=orange, mz2=pink, my=green, my2=red
Ardupilot guide mentions: “X component should increase in value - when rolling the vehicle right, the Y component should increase in value”. In my case when I roll right, Y components increase value, but X components mantein the value.
Do you think it’s ok? should I keep “Rotation None”?
Now a generic question. Magnetometer measures Magnetic field and as you mentioned, flight controller gets all three axes. I supose compass is based on Magnetometer. Which are the utility of them (mx,my,mz)? just get the geographic directions? is not enough with GPS or compass is useful only in some flight modes when GPS is not required?
Compass orientation looks correct. Based on your graphs they look good for the pitch and roll movements you show. There’s a very small skew because the two compasses aren’t perfectly aligned, but that shouldn’t cause any real problems.
Your compass offsets for the internal compass are very high. Are you sure there’s not a magnetic source somewhere near the Pixhawk? I don’t see anything bad on the top side, but maybe there’s something metal or magnetic in the card you attached everything to? You also might try re-calibrating with the default fitness if you haven’t already.
If all else fails, it should be safe to disable the internal compass. The external compass, at least, appears to be working well.
As for the magnetometer, it’s pretty essential for computing heading, so it’s needed for all GPS flight modes. For example, in order to fly north, the aircraft needs to know how to point north. But it’s also used to help determine the aircraft attitude along with the gyros and accelerometers, so it even improves how well the aircraft knows its pitch and roll angle. Because the 3D magnetic field vector is pointing in a (nearly) constant geographic direction, it’s helpful as an absolute attitude reference for the aircraft.
I’m not able to calibrate external compass in default fitness. I’m calibrating it in an indoor environment with FC connected to a desktop. I’m not aware about any metal or magnetic field in the room. I will get a laptop and try it again outside.
Magnetic offset values after calibration are related to real north direction? how does MP really know it?
Is there a formula (using mx,my,mz values) that provides the north?
External compass means not mounted inside the Pixhawk.So your compass should be set as external.It may or may not be ROLL_180.It may have a 45 degree yaw in the way it is mounted to the GPS board.There’s no way of telling easily other than opening it up and looking at the magnetometer.These cheap M8N boards can differ a lot.It’s only usually a Ublox, or clone, chip they share.The layout could be any way around.If, after compass calibration as external, it points exactly at the cardinal points when you turn it 90 degrees at a time then it is correct and should tally up with the board mounted magnetometer - which already knows which way it’s pointing.
Give that a go.
Most of the M8Ns wrk without trouble but I have two that gave me nightmares figuring out which way the chip was mounted.Arrows on the GPS case really count for nothing.And no real standards it seems to me unless you buy a branded unit.
Second Jagger’s note that the compass marking may not be correct. But I think you went through it methodically and verified the correct orientation.
Magnetic offsets are the zero offsets for each axis of sensor measurement. They are determined during calibration, and are roughly halfway between the minimum and maximum measured values as the magnetometer is moved in all axes (the reality of calibration is a bit more complex). If there are no magnetic items near the magnetometer, these should be near zero, as the bias of the sensor itself is usually small. These offsets aren’t related to North in any way, they’re just offsets to the sensor measurements.
It’s worth re-doing compass calibration outside. But also double check what’s near the Pixhawk, a single steel item close to the Pixhawk can cause large offsets. It doesn’t necessarily need to be a magnet, as any iron object can become magnetic.
Think of the magnetometer measurement as a vector pointing in some direction in 3D space. It points somewhere near North and often quite a bit towards the ground. Magnetic North is found by the direction of this vector in the horizontal plane. True North is found by applying a correction offset to this vector (magnetic declination) based on your GPS location, either manually or automatically depending on the value of COMPASS_AUTODEC.
Thanks. Completely agree that opening it up will provide really chipset orientation. However I followed Ardupilot “Checking Compass orientation” rules and seems it’s ok (“Rotation none”).
Once I calibrate, arrow points to the the right cardinal point.
It’s not always necessary, but you should calibrate your compass any time you change the configuration of the drone, for good measure. There are some items, particularly the power electronics, which create a magnetic field around the drone, so if you move the compass, it can change the calibration.
The biggest problem I ever had with one of these units was a 45 degree yaw on the compass.After calibration as ROLL_180,which that unit used it appeared at first glance to be calibrated ok.When I turned it about 90 degrees it pointed to E,S and W close enough ( I thought).But it flew like a turkey.It was only by using a hiking compass and square that I found that it was just a few degrees off of the cardinal points.Just a few.I ran through a lot of the available yaw figures and rechecked with the hiking compass until I got it nailed.I turned the copter exactly 90 degrees each time and got it to point exactly at the cardinal points and not 3,5 or 6 degrees off.It made a huge difference and was difficult to spot.I eventually physically check my several hours of experimenting by opening the GPS case and finding that 45 degree twist on the magnetometer chip.
Just saying that it’s not always easy to spot an incorrect orientation of the compass.Took me hours to work it out first time and sometimes still catches me out when I recalibrateon that copter…Hope it’s an easy fix.
@Jagger, I had the same issue, the marking on the case was 45 degrees off from the chip and I had a really hard time finding the proper orientation. I tried 180 roll like you said and it almost seemed to work. But then I found the Arducopter wiki page below, and found that it’s by far the best way to determine orientation. Basically, you tilt the copter in various ways and watch the magnetometer values, and based on how it changes when you tilt it, you can determine which axis is X, Y, and Z. Once I found that it took like 2 minutes to get the right orientation.
As I showed in my previous graphs, both (internal and external magnetometer) have same behaviour/pattern when I pitch/roll/yaw (both lines are parallel). So it means both orientation are OK or both have same bad orientation (almost improbable), isn’t it?
Out of curiosity, if possible could you send me a photo with the 45 degree chipset yaw on the compass (and a chipset with good orientation)? and detail the way to open the enclosure? after the compass master class, I’m would like to open and check it physically, although I’m almost sure I have it well configured.
The solution on those particular units is to take the screws out of the bottom of the unit and separate the two halves of the case. Note the X-> Y-> Z-> orientation markings of the mag chip and adjust your compass orientation accordingly. I have found those anywhere from Yaw 45 to Roll 180, yaw 315, depending on which day it was and who walked in off the street in China and soldered the wires on the chip when they made it.
The compass will just wander around in circles until you get the orientation right because it confuses the EKF. I’ve had a couple of those, that despite setting the orientation according to the markings on the chip, still failed to work properly. Since the compass is a critical component it is highly recommended to buy a higher quality unit such as one made by Hex Aero.
Yeah, the ProfiCNC/Hex is much better unit. It uses the ICM20948 mag chip and is well supported. I see you have a Pixhawk 2.4.8 so it may require breaking out the I2C for the compass to hook it up. The Here GPS unit comes with the plug for the Pixhawk 2.1 with 8 pins and the safety switch built into it. But that is also documented and easy to do if you do a search on it. They might even make a cable for the Here unit to hook up to the older Pixhawk. Even the GPS receiver in the Here unit is much better. Those ones like shown in the photo in this thread are supposed to be Neo M8N but in my experience they don’t get as many satellites as the Here unit on the same day, same place. I got both in several helicopters and the Here wins every time.