diff options
author | Julian Oes <julian@oes.ch> | 2013-08-19 16:32:56 +0200 |
---|---|---|
committer | Julian Oes <julian@oes.ch> | 2013-08-19 16:32:56 +0200 |
commit | 12df5dd2699f163bc5551b2be611665fc58fb001 (patch) | |
tree | f2449bf4122db9c62e41f95eb2754872a724eb14 | |
parent | bc717f1715590a6915c223dde53fe6e1139f92d2 (diff) | |
download | px4-firmware-12df5dd2699f163bc5551b2be611665fc58fb001.tar.gz px4-firmware-12df5dd2699f163bc5551b2be611665fc58fb001.tar.bz2 px4-firmware-12df5dd2699f163bc5551b2be611665fc58fb001.zip |
Corrected orientation of external mag
-rw-r--r-- | src/drivers/hmc5883/hmc5883.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/drivers/hmc5883/hmc5883.cpp b/src/drivers/hmc5883/hmc5883.cpp index 9e9c067d5..692f890bd 100644 --- a/src/drivers/hmc5883/hmc5883.cpp +++ b/src/drivers/hmc5883/hmc5883.cpp @@ -860,12 +860,13 @@ HMC5883::collect() _reports[_next_report].z = ((report.z * _range_scale) - _scale.z_offset) * _scale.z_scale; } else { #endif - /* the standard external mag seems to be rolled 180deg, therefore y and z inverted */ - _reports[_next_report].x = ((report.x * _range_scale) - _scale.x_offset) * _scale.x_scale; + /* the standard external mag by 3DR has x pointing to the right, y pointing backwards, and z down, + * therefore switch and invert x and y */ + _reports[_next_report].x = ((((report.y == -32768) ? 32767 : -report.y) * _range_scale) - _scale.x_offset) * _scale.x_scale; /* flip axes and negate value for y */ - _reports[_next_report].y = ((((report.y == -32768) ? 32767 : -report.y) * _range_scale) - _scale.y_offset) * _scale.y_scale; + _reports[_next_report].y = ((((report.x == -32768) ? 32767 : -report.x) * _range_scale) - _scale.y_offset) * _scale.y_scale; /* z remains z */ - _reports[_next_report].z = ((((report.z == -32768) ? 32767 : -report.z) * _range_scale) - _scale.z_offset) * _scale.z_scale; + _reports[_next_report].z = ((report.z * _range_scale) - _scale.z_offset) * _scale.z_scale; #ifdef PX4_I2C_BUS_ONBOARD } #endif |