1
$\begingroup$

On many drones are already external magnetometers. Unfortunately, the orientation of such sensors is sometimes unknown. E.g. the sensor can be tilted 180° (pitch/roll) or X° in yaw. I was wondering, whether one could calculate the rotation of the sensor relative to the vehicle by application of the accelerometer and gyrometer? Theoretically, the accelerometer yields a vector down and can be used for calculation of the coordinate system. The discrepancy between magnetometer and gyrometer then, may be used for calculation of the correct orientation of the compass. Later the compass should be used for yaw calculation. Below is the starting orientation of both sensors (just an example, the orientation of the compass can be anything). Does someone know a good way to figure out the rotation of the compass?

enter image description here

$\endgroup$
2
  • $\begingroup$ When you say the sensor can be tilted, do you mean in relation to the vehicle? Or during flight while on the vehicle? $\endgroup$
    – Octopus
    Oct 1, 2015 at 19:50
  • $\begingroup$ In relation to the vehicle. $\endgroup$
    – dgrat
    Oct 2, 2015 at 10:02

3 Answers 3

1
$\begingroup$

I'll try to go through your question as best as I can:

I was wondering, whether one could calculate the rotation of the sensor relative to the vehicle by application of the accelerometer and gyrometer?

Without any more information than an accelerometer and a gyro, no, you cannot, because gyros measure velocity and accelerometers measure acceleration, which means that you can only use those to find a position by using a constant of integration.

The constant of integration here would be an initial velocity for the first integration of accelerometer output, and and initial position and heading for the second integration of accelerometer output and gyro output, respectively.

The gyro and accelerometer will only ever give you relative positions and headings. You would need to find an initial heading to align those outputs to a (literal) global coordinate system, at which point you would be using whatever device you used for initial heading to compare with the magnetometer.

Theoretically, the accelerometer yields a vector down and can be used for calculation of the coordinate system.

I would be careful regarding this - see Ben's question/comment regarding his experience that 3-axis accelerometers tend to have a left-handed coordinate system. That is, if you haven't read the datasheet on the accelerometer, you could mis-interpret the orientation of the sensor because it's not using the coordinate system you think it is.

The discrepancy between magnetometer and gyrometer then, may be used for calculation of the correct orientation of the compass. Later the compass should be used for yaw calculation.

I don't know if you're using magnetometer and compass interchangeably here or if you are actually referring to two different devices, but as stated above, a gyro will only ever output a relative heading, so you can't use it to determine any absolute heading. This means that you can't use it to set/test/check the alignment of an absolute output device such as a magnetometer.

Below is the starting orientation of both sensors (just an example, the orientation of the compass can be anything). Does someone know a good way to figure out the rotation of the compass?

I don't know how specific you are trying to get with your measurement, but in general, I would just command the vehicle to point North. If you have a rotationally symmetric vehicle like a quadcopter then you'll have to determine which arm/end of the vehicle is "forward" (should correspond to a "move forward" command) and mark that end. Once the vehicle stops actively maneuvering to reach your heading command you can use a manual/secondary compass to determine true North and mark/compare the difference between that position and "forward" on your vehicle.

If you need a more precise measurement or if you can't command an absolute heading, then your only other choice is to try to get access to the electronics. I would look for the magnetometer chip itself, find the orientation of the chip, then read the datasheet and determine how it senses North. The chip will be soldered to a board which, in turn, will be attached to the vehicle. You can then relate compass orientation to the craft.

$\endgroup$
0
$\begingroup$

If you put a strong magnet under the magnetometer, its readings of direction should match the accelerometer reading for gravity. You could then place the magnet in the other cardinal directions in order to resolve any ambiguity in the orientation you calculate.

$\endgroup$
3
  • $\begingroup$ Using magnets near the compass could lead to decalibration. $\endgroup$
    – Octopus
    Oct 1, 2015 at 19:51
  • $\begingroup$ This is absolutely not an answer for anything. $\endgroup$
    – dgrat
    Oct 2, 2015 at 10:04
  • $\begingroup$ @dgrat please elaborate. $\endgroup$
    – Ian
    Oct 2, 2015 at 12:57
0
$\begingroup$

Since the gyros are only good for measuring rotational rates, they are essentially useless at calculating your orientation. The accelerometers, as you say, will calculate exactly your reference plane, but it seems your question is about an arbitrary yaw within that plane.

Now this is where the compass becomes important: for measuring the yaw. Since the compass is fixed to the frame, it should be known at design time how its orientation differs from the vehicle's.

$\endgroup$
1
  • $\begingroup$ It is not abaout calculation of the yaw. It is about the calculation of the sensor board orientation. If the compass is 180° around the roll axis rotated, then the board will yield inverted tilt values in relation to the compass. E.g. gyro +45° and compass -45° :D $\endgroup$
    – dgrat
    Oct 2, 2015 at 10:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.