COMPASS_ORIENT parameter in master

381 views
Skip to first unread message

Andrew Tridgell

unread,
May 1, 2013, 11:27:47 PM5/1/13
to drones-...@googlegroups.com
Hi Michael,

I've added a COMPASS_ORIENT parameter to git master. It is an additional
rotation in the same manner as AHRS_ORIENTATION. It should only be
non-zero if you have an external compass.

I think Craig was hoping you'd add an option to set it in MP.

Cheers, Tridge

William Burkert

unread,
May 22, 2013, 6:20:45 AM5/22/13
to drones-...@googlegroups.com, and...@tridgell.net
Might you explain all of the orientation values?  I just added an external compass and the wiki

Andrew Tridgell

unread,
May 22, 2013, 6:44:35 AM5/22/13
to William Burkert, drones-...@googlegroups.com
Hi William,

> Might you explain all of the orientation values? I just added an
> external compass and the wiki

The parameter is explained here:

https://code.google.com/p/ardupilot-mega/wiki/APM_Parameters#Compass_orientation_%28COMPASS_ORIENT%29

Cheers, Tridge

William Burkert

unread,
Jun 1, 2013, 9:37:54 PM6/1/13
to drones-...@googlegroups.com, William Burkert, and...@tridgell.net
Andrew,
 
Thank-you for responding.  After I looked at all the values I thought I understood the parameter.  My compass orientation is components up, pins to the rear so I think YAW 180 is the proper selection.
 
For some reason I can no longer select the orientation pull-down in Mission Planner, did it go away? The pull-down seems like it is 'ghosted' out.  I suppose I think that is not the case since the orientation description still exists.
 
If I move the external magnetometer around while under Mission Planner TEST COMPASS I get changing values so I think it is working but I am afraid to fly my quadcopter without a working compass.
 
I also am having a terrible time with a new optical flow sensor v1.1 - it powers on but never any changing values while under test.
 
Is there any kind of a checklist of what one should do to setup, calibrate and know that everything is working?

Chester

unread,
Jun 24, 2013, 7:03:11 AM6/24/13
to drones-...@googlegroups.com, and...@tridgell.net
Looks like I found error in my setup with external GPS+Compass. Here is description. (Nick name: Chester)
I have compared compass offsets from my px4 and apm2.5 that has GPS+Compass and it was big difference.

Look like mounted external compass incorectly. But now I cant Undestand how to mount it correctly or correct value for СOMPASS_ORIENT.
Wiki says: The correct orientation should give the X axis forward, the Y axis to the right and the Z axis down. So if your aircraft is pointing west it should show a position value for the Y axis, and a value close to zero for the X axis.

I can try different parametrs in COMPASS_ORIENT but how to know that one of orientation is correct?
Currentrly my GPS was mounted like in picture. Arrow on the top shows forward.

Robert Lefebvre

unread,
Jun 24, 2013, 7:51:42 AM6/24/13
to drones-discuss
Are these shipping already? 


--
You received this message because you are subscribed to the Google Groups "drones-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drones-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Chester

unread,
Jun 24, 2013, 7:56:32 AM6/24/13
to drones-...@googlegroups.com
As I know. Right now Not. I was lucky to order in short period then it was available in 3drobotics store.

Randy Mackay

unread,
Jun 24, 2013, 9:22:36 AM6/24/13
to drones-...@googlegroups.com
Chester,

     If the copter is in the correction orientation and you point your APM north I think you should see numbers like this:
               X: 220
               Y: 0
               Z: 220

     I think if you are using an external compass the orientation should be ROTATION_ROLL_180 because I've always heard that that it's "components down, pins forward" which is the same as the APM1 and is ROLL_180 (I think).

     By the way, does anybody know where the trace is that needs to be cut?  If someone tells me I can give it a try myself with the prototype gps+compass that I have.

-Randy



From: Chester <anton....@gmail.com>
To: drones-...@googlegroups.com
Sent: Monday, June 24, 2013 8:56 PM
Subject: Re: [drones-discuss] Re: COMPASS_ORIENT parameter in master

Chester

unread,
Jun 24, 2013, 9:35:52 AM6/24/13
to drones-...@googlegroups.com, Randy Mackay
On Apm2.5 I had cuted traces near compass. Wiki page shows it good http://copter.ardupilot.com/wiki/common-external-magnetometer-for-improved-performance/ . After cut compass test showed mw error in init and then I connect external.

Olivier ADLER

unread,
Jun 24, 2013, 9:36:36 AM6/24/13
to drones-...@googlegroups.com, Randy Mackay

Randy, watch here for the trace to be cut.

http://copter.ardupilot.com/wiki/common-external-magnetometer-for-improved-performance/


Check as well that the external magnetometer board is set to the right voltage. It must be set to 3.3V. I think that it is shipped with a 5V setting (last board i bought was like this).


Olivier

Robert Lefebvre

unread,
Jun 24, 2013, 9:40:39 AM6/24/13
to drones-discuss, Randy Mackay
Yup.  And as Chester says, cut it, then do a mag test, it should show the mag is unhealthy, so you know you've done it right.  Then connect the external.

BTW, what kind of numbers would we see for a compass calibration if it was "perfect"?  0,0,0?  Or something else?  Like say you could mount it 10m from any interference, what would you see?


Randy Mackay

unread,
Jun 24, 2013, 9:58:46 AM6/24/13
to drones-...@googlegroups.com

     Thanks for the links re the trace.

      For compassmot you'd see 0,0,0.

      for the live calibration...well...every compass will need some offsets but with very little metal near them I'd expect between -30 ~ 30 on all axis.

-Randy



From: Robert Lefebvre <robert....@gmail.com>
To: drones-discuss <drones-...@googlegroups.com>
Cc: Randy Mackay <rmac...@yahoo.com>
Sent: Monday, June 24, 2013 10:40 PM

Subject: Re: [drones-discuss] Re: COMPASS_ORIENT parameter in master

Olivier ADLER

unread,
Jun 24, 2013, 10:14:39 AM6/24/13
to drones-...@googlegroups.com, Randy Mackay

I think that it depends about your local inclination. At the magnetic equator should it be 0,0,0 without external magnetic interference if you are in a anomaly free region ?

https://en.wikipedia.org/wiki/Magnetic_dip


Olivier.

Robert Lefebvre

unread,
Jun 24, 2013, 10:20:12 AM6/24/13
to drones-discuss, Randy Mackay
What about in Canada?  We should have a pretty strong downward orientation, so that would show up in the calibration?  Looks like on a line at almost +70°



Olivier ADLER

unread,
Jun 24, 2013, 10:44:52 AM6/24/13
to drones-...@googlegroups.com, Randy Mackay

Yes the more you are near the poles, the more inclination.

More inclination means that your compass need a perfect calibration and less interferences to give a reliable north.

There are some rare places on earth where inclination is 90° (not only at the magnetic poles), in this case the compass will not be able to give a reliable north indication. It will simply spin more or less sporadically.


You can get your inclination on the NOAA web site. In my location in France near Paris i have 63°.


http://www.ngdc.noaa.gov/geomag-web/#igrfwmm

Olivier.

Olivier ADLER

unread,
Jun 24, 2013, 11:15:00 AM6/24/13
to drones-...@googlegroups.com, Randy Mackay

The effect of earth magnetic field inclination on a 2D compass when a plane is rolling.

http://www.youtube.com/watch?feature=player_detailpage&v=xmJZSCJ5FCM


Hopefully we have a 3D compass.

But you can have the same problem on a badly calibrated 3D compass.


Olivier




On Monday, June 24, 2013 4:20:12 PM UTC+2, robert.lefebvre wrote:

Robert Lefebvre

unread,
Jun 24, 2013, 11:29:59 AM6/24/13
to drones-discuss, Randy Mackay
With this much inclination, what might I expect from a perfect calibration?  I'm just curious what is the goal I should shoot for?  The H8 frame I have designed is specifically laid out to give the best chance of a good calibration.  

So CompassMot should be zero.  But what about calibration, with declination of 70°?  0,0,-70?  I've never understood what the compass calibration numbers mean exactly.


Jonathan Challinger

unread,
Jun 24, 2013, 12:15:51 PM6/24/13
to drones-...@googlegroups.com
Robert, do you mean inclination?

This compass_orient parameter should only be used to adjust for alignment errors between the compass and the APM. You do not need to configure your inclination anywhere, as we are not trying to measure roll or pitch using the magnetometer. You do need to provide your declination, or enable auto-declination (enabled by default)

Other compass calibration numbers are:

Offsets: the magnetometer provides a 3d vector indicating the direction and magnitude of the magnetic field being applied to it. If the sensor were perfect and not sitting near anything magnetic, it would measure only the magnetic field of the earth (which is what we want). If there's a magnet nearby, we have to subtract off the influence of that magnet. That's what the compass offset calibration does (when you turn your copter around)

Motor calibration: the way this works is that we figure out the direction of the offset error applied by the motors, and the magnitude as a function of current (or throttle). Then we just subtract it off in flight.

Robert Lefebvre

unread,
Jun 24, 2013, 12:35:27 PM6/24/13
to drones-discuss
I think I mean inclination...

What I'm asking is this.  Where I live, the magnetic inclination is about 70° pointing down at the ground.  If I understand correctly.

So based on that, what is the absolute best possible Compass Offset I could have, if I had a perfect compass installation with zero interference from anything?  Just wondering what is a good goal to shoot for. 

Jonathan Challinger

unread,
Jun 24, 2013, 12:46:35 PM6/24/13
to drones-...@googlegroups.com

0,0,0

Robert Lefebvre

unread,
Jun 24, 2013, 12:52:55 PM6/24/13
to drones-discuss
Oh, really?  I thought the inclination would play in somewhere.  Ok.

How does the program handle that inclination?  Does it just discard the Z-component, and only look at the X,Y 2D vector? 

What happens if I'm pointing due south, in an area with 70° inclination into the ground.  Then I pitch the copter forward (south facing) 45°.  The X,Y component will now actually point forward, which is south, in the body frame.  

Are we rotating the magnetic vector back to earth-frame first?

Olivier ADLER

unread,
Jun 24, 2013, 1:13:45 PM6/24/13
to drones-...@googlegroups.com


With or without rotation i think that the inclination do play a role when there are frame interferences ? And for this reason i think that the compass must be recalibrated when you are traveling in a region of the world with a different inclination.

The latest Sparkfun competition seems to show that with a couple participant that did get compass problems.

I have a precision survey electronic compass, the manual say that it must be recalibrated (some kind of simplified compass dance) when changing survey locations for best results.

Olivier

Jonathan Challinger

unread,
Jun 24, 2013, 3:16:56 PM6/24/13
to drones-...@googlegroups.com
Yes, we are rotating the mag vector into earth frame.
It goes something like this:
- Create unit vector2 facing north (1.0,0.0) to represent earth's magnetic field.
- Rotate it by the set declination.
- Multiply the mag vector by the DCM matrix (puts mag vector in earth frame).
- Discard Z
- Determine the angle between the two vectors. This angle is the error we need to correct.

Robert Lefebvre

unread,
Jun 24, 2013, 4:11:16 PM6/24/13
to drones-discuss
So isn't it true then, that areas with more inclination, have shorter earth field vectors projections in the X,Y plane, which makes them even more influenced by frame and motor interference?

Olivier ADLER

unread,
Jun 24, 2013, 4:52:00 PM6/24/13
to drones-...@googlegroups.com

Exactly, the projected mag earth vector in the XY plane is shorter. More inclination means a shorter vector, and more frame interferences influence.

At 90° inclination the projected 2D vector lenght is null -> no more north heading, the compass become made regardless if it is a 2D or a 3D one.

At 80° inclination the projected lenght is about 6 time shorter. So you can expect 6 times more frame interference influence.

This mean that it will be more difficult to get a low compassmot interference level (<30%) with high inclination values.

This explain as well that we should see large differences betweens users interference levels depending about the region they are located in, even if they have the same frame and same setup.

On top of this, there are region in the world where the total magnetic field vector length is weaker.

The best situation for a compass is at the magnetic equator where inclination = 0°.


Olivier.

Robert Lefebvre

unread,
Jun 24, 2013, 5:48:40 PM6/24/13
to drones-discuss
Ok, good to know.  So, I don't think there's much we can do about this in the code (unless maybe Jonathan can work some magic?) but it's at least good to know this effect exists.

Olivier ADLER

unread,
Jun 24, 2013, 6:41:50 PM6/24/13
to drones-...@googlegroups.com


Yep, there is certainly nothing we can do, more inclination = smaller signal / noise ratio and filtering to enhance the signal / noise ratio means more compass drag.

This mean as well that a working setup in a given region of the world can stop working in another region if compass interference is too large.

This is one reason more to use an external compass, specially for scientific, competitions or pro work uses where reliability is a primary concern.


What we could do nevertheless is trying to detect if the compass does not give a reliable heading and alarm users.

I have such an alarm on my surveying electronic compass. Would it be  possible during flight to slowly correlate the compass with inertial measurements and set a flag for the next pre-arm check ?


Olivier
Message has been deleted

Olivier ADLER

unread,
Jun 24, 2013, 7:51:59 PM6/24/13
to drones-...@googlegroups.com

One more thing : Compassmot give us the magnetic interference induced by power distribution currents.


It's a good indication about the dynamic interferences we have on the frame, but it does not give us the static frame interferences amount.


It would be interesting after compass dance calibration to have a "Frame Static Interferences" value reported by Mission Planner.


Olivier.



john...@gmail.com

unread,
Jun 25, 2013, 4:06:41 PM6/25/13
to drones-...@googlegroups.com
I guess I am lucky in this regard, since I live and fly almost perfectly i the middle of the 0 declination line (Norwegian west coast). I imagine GPS operation at the declination dip pole would be "interesting".

- JAB

Olivier ADLER

unread,
Jun 25, 2013, 5:03:00 PM6/25/13
to drones-...@googlegroups.com

John, i was talking about inclination. Inclination and Declination are different.

There is no declination value at the dip poles because the magnetic field is fully vertical. Declination it the angle difference in the horizontal plane between the geographic north heading and the magnetic north heading.

Inclination is 90° at the dip poles and 0° along the magnetic equator line.

In my location near Paris in France i have about 0 degree declination too but 63° inclination.


Why do you think that GPS operation would be interesting at the Dip poles ? GPS is working normaly at the geographic poles, so i don't see why it would not work at dip poles ?

Here are a couple pictures of a GPS working at the geographic north pole :

http://gpsinformation.us/Maps/NorthPole/NorthPoleGPS.html

Only 4 satellites visible but it's working.


An interesting thing is that longitude has no meaning at geographic poles (90° latitude), and it's better to use UPS polar coordinates system to navigate over there.

In the polar regions, directions can become complicated, with all geographic north-south lines converging at the poles.
 

http://en.wikipedia.org/wiki/Universal_Polar_Stereographic_coordinate_system


Olivier

john...@gmail.com

unread,
Jun 25, 2013, 5:17:30 PM6/25/13
to drones-...@googlegroups.com
My reasoning was that at the dip pole, there is a theoretical point where you could get any declination just by moving the GPS unit a short distance.

- JAB

Robert Lefebvre

unread,
Jun 25, 2013, 6:11:10 PM6/25/13
to drones-discuss
I'm betting the reality is that the dip pole is over quite a large area.  I don't think a UAV would be covering distance fast enough to actually have the declination move around appreciably?


Olivier ADLER

unread,
Jun 25, 2013, 6:20:01 PM6/25/13
to drones-...@googlegroups.com


True. Anyway there are good chances that the compass will not work at all, regardless the theoretical declination it will spin or give unreliable values because of near 90° inclination.

The only thing it will show you reliably is the direction of the ground :) Not as bad but not very useful.


Perhaps we'll need to add a GPS heading mode so that scientists can use Arducopters at the earth magnetic poles.


Do we get Arducopter or ArduPlane flying near the poles yet ?

Olivier ADLER

unread,
Jun 25, 2013, 6:49:57 PM6/25/13
to drones-...@googlegroups.com

Sure Robert, but anyway the heading will not be reliable because of the 90° inclination. Adding a declination to an unreliable heading will always gives you a bad heading.

http://www.youtube.com/watch?v=wjGr7IegCVY&feature=player_detailpage

http://www.youtube.com/watch?v=4CU3c81fQGc&feature=player_detailpage

Another interesting curiosity :


If the navigator happens to be traveling along a rather straight line of equal declination, called an isogonic line, it can vary very little over thousands of kilometers. However; for one crossing isogonic lines at high latitudes, or near magnetic anomalies, the declination can change at over a degree per kilometer (6/10 mile). Navigators need periodically update the value to stay on course.


So we can assume that in extreme cases, it's possible to have a crash because of this for very long missions in very difficult areas !


There are places as well where traveling a few meters is enough to change declination a few degrees (ground with magnetite, ilmenite or iron deposits).


Olivier


 

Olivier ADLER

unread,
Jun 25, 2013, 7:42:15 PM6/25/13
to drones-...@googlegroups.com

Jonathan, are we using the mag vector directly to find the angle error ?

Would it be possible to filter it through the inertial sensors for more responsiveness and more stability ?

More doing this should allow to track compass interferences in realtime and reports anomalies in the log.



Olivier

Jonathan Challinger

unread,
Jun 25, 2013, 10:51:22 PM6/25/13
to drones-...@googlegroups.com

It is complementary filtered by the ahrs using the gyros.

Chester

unread,
Jun 26, 2013, 12:13:14 AM6/26/13
to drones-...@googlegroups.com, and...@tridgell.net
I solved my problemm with compass orientation in my GPS+Compass unit. I used Roll180. From of my copter is where RX on photo. Logs are atteched. No Yaw drift as before. All ok. Need some pid tuning but its another question.

On Thursday, May 2, 2013 9:27:47 AM UTC+6, Andrew Tridgell wrote:
Hi Michael,

I've added a COMPASS_ORIENT parameter to git master. It is an additional
rotation in the same manner as AHRS_ORIENTATION. It should only be
non-zero if you have an external compass.

I think Craig was hoping you'd add an option to set it in MP.

Cheers, Tridge
IMG_20130623_220623.jpg
2013-06-26 06-43-03.tlog
2013-06-26 06-57 3.log
Reply all
Reply to author
Forward
0 new messages