compass orientation with external compass

1,104 views
Skip to first unread message

Andrew Tridgell

unread,
Jul 3, 2013, 3:57:35 AM7/3/13
to Craig Elder, drones-...@googlegroups.com
Hi Craig,

I've been looking at the compass orientation doc page here:

http://copter.ardupilot.com/wiki/common-installing-3dr-ublox-gps-compass-module/

I think we also need the instructions (and photos!) for the PX4, which
is different.

The PX4 has a different base orientation of its compass to the
APM2. That means that when you use an external compass on the PX4 you
need a different COMPASS_ORIENT setting.

For the default orientation of the PX4 (ie. SD card side up, with SD
card at the rear of the aircraft), you need the following settings for
an external compass, if you point the external compass white arrow
forward:

AHRS_ORIENTATION=0
COMPASS_ORIENT=4 (Yaw180)

For the default orientation of the APM2 with an external compass you need:

AHRS_ORIENTATION=0
COMPASS_ORIENT=8 (Roll180)

If you had the PX4 upside down, then you would need:

AHRS_ORIENTATION=8
COMPASS_ORIENT=12 (Pitch180)

It is important that users understand that the AHRS_ORIENTATION affects
the orientation of the compass too. So for an external compass the two
orientations combine. The reason it works this way is that when the
compass was attached to the board we didn't want users to have to set
two parameters, so we made it that when you changed the AHRS_ORIENTATION
master orientation it also applied to the compass.

With an external compass I suspect this is going to be pretty confusing
for users. They'll need to know how to combine rotations, and it isn't a
matter of just adding them up.

To solve this I think we'll need to do one of the following:

- add a COMPASS_EXTERNAL=0/1 parameter. If set to 1 then it would
decouple the two orientations, so changing AHRS_ORIENTATION doesn't
change the compass orientation

- add some graphical feedback to MissionPlanner and other ground
stations so users can easily tell if their compass is correctly
oriented. I'm not sure what that would look like.

- implement something to auto-detect the compass orientation. That
should be possible based on the gyro/accel changes when rotating the
board, but I'm not sure what form the interface should take

- create a JavaScript web page that allows users to select different
orientations of the board and the compass, plus their board type, and
have it spit out the correct AHRS_ORIENTATION and COMPASS_ORIENT
settings. The web page would show the board and compass in their
chosen orientation.

Another slight issue with the external compass on the APM2 is that the
connectors on the compass+GPS combo are rather unfortunately placed. The
cables from the APM2.6 have to be twisted around to get both APM2 and
compass+GPS in the "correct" orientation. This makes for messier wiring,
and also means you can't put the compass as far from the APM2.6 as you
can if you had the connectors on the other side (or we just put the
white arrow on the other end of the circuit board, and recommended a
different COMPASS_ORIENT setting).

Cheers, Tridge

Tom Coyle

unread,
Jul 3, 2013, 2:28:55 PM7/3/13
to drones-...@googlegroups.com, Craig Elder, and...@tridgell.net, tri...@tridgell.net
Hi Tridge,
 
Nice take on compass orientation. Very comprehensive. A couple of questions though:
 
I had the AHRS _ORIENTATION on the Px4 set to 8 because I have the I/O on the top, but I missed the compass orientation and need to roll it 180 which I will do the next time I work with the PX4.
 
As for the APM2x, you are saying that the COMPASS_ORIENT needs to be set to 8 (Roll 180). Are you assuming that the Roll 180 is necessary when using the new combined GPS/compass module because the compass is on the bottom, which makes sense? However, if you are using just an off-board HMC5883L stand alone compass, like I have on my Rover, and you keep the components right side up, then there should be no need to require the Roll 180, right?
 
Comments please!
 
Regards,
Tom C

Craig Elder

unread,
Jul 3, 2013, 2:45:55 PM7/3/13
to Tom Coyle, drones-discuss, Andrew Tridgell, tri...@tridgell.net
Tom, you only need to set the COMPASS_ORIENT with your PX4 if you are using an external compass.  If you are using the on board compass and invert the board, the AHRS _ORIENTATION parameter will take care of both the compass and the AHRS

Marco Robustini

unread,
Jul 3, 2013, 2:55:33 PM7/3/13
to drones-...@googlegroups.com, Craig Elder, and...@tridgell.net, tri...@tridgell.net
I personally believe that having the possibility to orient the board and the compass as we want to be exceptional, unfortunately the bitmap setting about this in the Planner is not clear in my opinion.

Marco

Craig Elder

unread,
Jul 3, 2013, 2:56:32 PM7/3/13
to Marco Robustini, drones-discuss, Andrew Tridgell, tri...@tridgell.net
Marco, we're working on making it clearer.

Gary McCray

unread,
Jul 3, 2013, 3:02:06 PM7/3/13
to drones-...@googlegroups.com, Craig Elder, and...@tridgell.net, tri...@tridgell.net
Hi Tom,

In reply to your second question, as long as you have external mag right side up you do not need roll 180 on the compass, generally for now that only applies to the combo board with compass and GPS. 

Right now, the combo board the compass versus the board orientation settings "tricky", they are working towards a better solution. 

I am going to try and make this issue a bit clearer in the Wiki posts on the external mag and on the combo board. 

If worse came to worse, I could probably include a chart of at least the most common configurations.

I use the PX4 upside down too, but the only time you need to change the compass orientation is for and external compass, otherwise it follows board orientation.

Andrew Tridgell

unread,
Jul 3, 2013, 6:10:17 PM7/3/13
to Gary McCray, drones-...@googlegroups.com, Craig Elder
Hi Gary,

Another thing it would be useful to add to the compass docs is that the
PX4 will auto-detect an external compass and use it if available at boot
time. The APM2.5 won't - it will only use an external compass if you
disable the internal compass.

The reason it works this way is that the external compass connector on
the PX4 is on a separate I2C bus, so the PX4 can use both compasses and
choose which one to run with. On the APM2.5 the connector is on the same
bus as the internal compass, so it isn't possible to select which
compass you want in software.

Cheers, Tridge

Tom Coyle

unread,
Jul 3, 2013, 8:52:50 PM7/3/13
to drones-...@googlegroups.com, Gary McCray, Craig Elder, and...@tridgell.net
Tridge/Gary,
 
Thanks for the responses, much appreciated. Nice to know about being able to use an external compass on the PX4.
 
Regards,
Tom C

Gary McCray

unread,
Jul 3, 2013, 9:51:27 PM7/3/13
to Tom Coyle, drones-...@googlegroups.com, Craig Elder, Andrew Tridgell
Hi Tridge, 

Good to know that.

I'll definitely get that in there, I was wondering.

While your here, I wonder if we could possibly get a second version of common page, one that copies to plane and copter only not rover, I am sure I do not need to tell you why.

It could still live on the Dev site and maybe we could call it pc-common- or whatever you want.

Seemed like it should be easy, but while there are a lot of potential candidates for plane and copter common pages, not as many for rover so could be quite handy.

And I figured since you wrote the previous one, this would hopefully be really easy to implement.

And Craig definitely is interested in making as many pages as possible common to reduce multiple copy errors.

Thank You.

Gary

Andrew Tridgell

unread,
Jul 4, 2013, 12:45:57 AM7/4/13
to Gary McCray, Tom Coyle, drones-...@googlegroups.com, Craig Elder
Hi Gary,

> While your here, I wonder if we could possibly get a second version of
> common page, one that copies to plane and copter only not rover, I am sure
> I do not need to tell you why.

we could, but I think it is easier to just not list the common pages
that aren't relevant to rover in the menus/TOC of the rover site. The
pages will still be there, but wouldn't be linked from anywhere.

> And Craig definitely is interested in making as many pages as possible
> common to reduce multiple copy errors.

great!

Cheers, Tridge

Tom Coyle

unread,
Jul 10, 2013, 10:53:30 AM7/10/13
to drones-...@googlegroups.com, Gary McCray, Craig Elder, and...@tridgell.net
Hi Tridge,
 
To connect an external compass to the PX4, there appears to be only one 4 pin I2C connector on the PX4 IO board and that is I2C3. The pin out on the PX4 IO I2C3 connector is identical to the connector pin out on the 3DR APM2.5 I2C connector so I assume that an external HMC5883L using the 3DR I2C pin out will work on the PX4 IO I2C3 connector?
 
Regards,
Tom C

On Wednesday, July 3, 2013 6:10:17 PM UTC-4, Andrew Tridgell wrote:

Craig Elder

unread,
Jul 10, 2013, 2:54:50 PM7/10/13
to Tom Coyle, drones-discuss, Gary McCray, Andrew Tridgell
Correct.
I have been using it for a few weeks like that.

Gary McCray

unread,
Jul 10, 2013, 5:16:32 PM7/10/13
to drones-...@googlegroups.com, Craig Elder, and...@tridgell.net, tri...@tridgell.net
I have now clarified and illustrated the implementation of the PX4 External magnetometer on the external magnetometer wiki page and the combination GPS magnetometer board wiki pages.

Andrew Tridgell

unread,
Jul 10, 2013, 9:08:33 PM7/10/13
to Gary McCray, drones-...@googlegroups.com, Craig Elder
Thanks Gary, looks good!
Should we also add a link from the first page to the second, so if
people stumble on the first one for external mag, they know how to get
info on the GPS+mag combo.

Note that when doing links from common pages to other common pages you
should use a relative link.

So when creating the link, set the URL to

/wiki/common-installing-3dr-ublox-gps-compass-module/

and it will go to the right place on all the wikis. The web browser will
add the vehicle specific prefix (like http://copter.ardupilot.com).

This is actually best practice for all intra-site links, even for non
common pages. So for example on the flight modes page for APM:Plane
you'll see that the link to the geo-fencing is to /wiki/geofencing-3/
not to http://plane.ardupilot.com/wiki/geofencing-3/

Cheers, Tridge
Reply all
Reply to author
Forward
0 new messages