mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 02:55:07 +08:00
drivers/magnetometer/hmc5883: fix Z direction
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
board_adc start
|
board_adc start
|
||||||
|
|
||||||
# Internal I2C bus
|
# Internal I2C bus
|
||||||
hmc5883 -T -I -R 12 start
|
hmc5883 -T -I -R 2 start
|
||||||
qmc5883l -I -R 6 start
|
qmc5883l -I -R 6 start
|
||||||
|
|
||||||
mpu6000 -s -R 2 start
|
mpu6000 -s -R 2 start
|
||||||
|
|||||||
@@ -8,9 +8,6 @@ rgbled_ncp5623c start -I
|
|||||||
|
|
||||||
board_adc start
|
board_adc start
|
||||||
|
|
||||||
# Internal I2C bus
|
|
||||||
hmc5883 -T -I -R 4 start
|
|
||||||
|
|
||||||
# Internal SPI (auto detect ms5611 or ms5607)
|
# Internal SPI (auto detect ms5611 or ms5607)
|
||||||
if ! ms5611 -T 5607 -s -b 1 start
|
if ! ms5611 -T 5607 -s -b 1 start
|
||||||
then
|
then
|
||||||
@@ -80,7 +77,7 @@ then
|
|||||||
mpu6000 -s -b 1 start
|
mpu6000 -s -b 1 start
|
||||||
|
|
||||||
# v2.0 Has internal hmc5883 on SPI1
|
# v2.0 Has internal hmc5883 on SPI1
|
||||||
hmc5883 -T -s -b 1 -R 8 start
|
hmc5883 -T -s -b 1 start
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $BOARD_FMUV3 = 21 ]
|
if [ $BOARD_FMUV3 = 21 ]
|
||||||
|
|||||||
@@ -8,9 +8,6 @@ rgbled_ncp5623c start -I
|
|||||||
|
|
||||||
board_adc start
|
board_adc start
|
||||||
|
|
||||||
# Internal I2C bus
|
|
||||||
hmc5883 -T -I -R 4 start
|
|
||||||
|
|
||||||
# Internal SPI (auto detect ms5611 or ms5607)
|
# Internal SPI (auto detect ms5611 or ms5607)
|
||||||
if ! ms5611 -T 5607 -s -b 1 start
|
if ! ms5611 -T 5607 -s -b 1 start
|
||||||
then
|
then
|
||||||
@@ -80,7 +77,7 @@ then
|
|||||||
mpu6000 -s -b 1 start
|
mpu6000 -s -b 1 start
|
||||||
|
|
||||||
# v2.0 Has internal hmc5883 on SPI1
|
# v2.0 Has internal hmc5883 on SPI1
|
||||||
hmc5883 -T -s -b 1 -R 8 start
|
hmc5883 -T -s -b 1 start
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $BOARD_FMUV3 = 21 ]
|
if [ $BOARD_FMUV3 = 21 ]
|
||||||
|
|||||||
@@ -16,10 +16,10 @@ pwm_out sensor_reset 50
|
|||||||
# Internal SPI
|
# Internal SPI
|
||||||
ms5611 -s start
|
ms5611 -s start
|
||||||
|
|
||||||
# hmc5883 internal SPI bus is rotated 90 deg yaw
|
# hmc5883 internal SPI bus
|
||||||
if ! hmc5883 -T -s -R 2 start
|
if ! hmc5883 -T -s -R 12 start
|
||||||
then
|
then
|
||||||
# lis3mdl internal SPI bus is rotated 90 deg yaw
|
# lis3mdl internal SPI bus
|
||||||
lis3mdl -s start
|
lis3mdl -s start
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -281,10 +281,6 @@ int HMC5883::collect()
|
|||||||
|
|
||||||
uint8_t check_counter;
|
uint8_t check_counter;
|
||||||
|
|
||||||
float xraw_f;
|
|
||||||
float yraw_f;
|
|
||||||
float zraw_f;
|
|
||||||
|
|
||||||
_px4_mag.set_error_count(perf_event_count(_comms_errors));
|
_px4_mag.set_error_count(perf_event_count(_comms_errors));
|
||||||
|
|
||||||
perf_begin(_sample_perf);
|
perf_begin(_sample_perf);
|
||||||
@@ -361,28 +357,15 @@ int HMC5883::collect()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if (_px4_mag.external()) {
|
||||||
* RAW outputs
|
// legacy handling of the popular 3DR external compass
|
||||||
*
|
// x pointing to the right, y pointing backwards, and z down
|
||||||
* to align the sensor axes with the board, x and y need to be flipped
|
_px4_mag.update(timestamp_sample, math::negate(report.y), math::negate(report.x), math::negate(report.z));
|
||||||
* and y needs to be negated
|
|
||||||
*/
|
} else {
|
||||||
if (!_px4_mag.external()) {
|
_px4_mag.update(timestamp_sample, math::negate(report.x), report.y, math::negate(report.z));
|
||||||
// convert onboard so it matches offboard for the
|
|
||||||
// scaling below
|
|
||||||
report.y = -report.y;
|
|
||||||
report.x = -report.x;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the standard external mag by 3DR has x pointing to the
|
|
||||||
* right, y pointing backwards, and z down, therefore switch x
|
|
||||||
* and y and invert y */
|
|
||||||
xraw_f = -report.y;
|
|
||||||
yraw_f = report.x;
|
|
||||||
zraw_f = report.z;
|
|
||||||
|
|
||||||
_px4_mag.update(timestamp_sample, xraw_f, yraw_f, zraw_f);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
periodically check the range register and configuration
|
periodically check the range register and configuration
|
||||||
registers. With a bad I2C cable it is possible for the
|
registers. With a bad I2C cable it is possible for the
|
||||||
|
|||||||
Reference in New Issue
Block a user