diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2013-08-19 22:51:30 +0200 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2013-08-19 22:51:30 +0200 |
commit | deb426b66002da2562531b37e4ac0f8097c8a6eb (patch) | |
tree | add3aaec3729fd7b8f9730e7f68e5b51e1e5f57f /src/modules | |
parent | d90345a16619a6a056ca9158961db36787d97678 (diff) | |
parent | dccdc977d5be4f957bcaea036b66d0391b29fd2b (diff) | |
download | px4-firmware-deb426b66002da2562531b37e4ac0f8097c8a6eb.tar.gz px4-firmware-deb426b66002da2562531b37e4ac0f8097c8a6eb.tar.bz2 px4-firmware-deb426b66002da2562531b37e4ac0f8097c8a6eb.zip |
Merge branch 'sensor_selftests'
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/commander/accelerometer_calibration.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/modules/commander/accelerometer_calibration.c b/src/modules/commander/accelerometer_calibration.c index 6a304896a..fbb73d997 100644 --- a/src/modules/commander/accelerometer_calibration.c +++ b/src/modules/commander/accelerometer_calibration.c @@ -226,6 +226,12 @@ int do_accel_calibration_mesurements(int mavlink_fd, float accel_offs[3], float if (orient < 0) return ERROR; + if (data_collected[orient]) { + sprintf(str, "%s direction already measured, please rotate", orientation_strs[orient]); + mavlink_log_info(mavlink_fd, str); + continue; + } + sprintf(str, "meas started: %s", orientation_strs[orient]); mavlink_log_info(mavlink_fd, str); read_accelerometer_avg(sensor_combined_sub, &(accel_ref[orient][0]), samples_num); @@ -380,6 +386,8 @@ int read_accelerometer_avg(int sensor_combined_sub, float accel_avg[3], int samp int count = 0; float accel_sum[3] = { 0.0f, 0.0f, 0.0f }; + int errcount = 0; + while (count < samples_num) { int poll_ret = poll(fds, 1, 1000); if (poll_ret == 1) { @@ -389,8 +397,12 @@ int read_accelerometer_avg(int sensor_combined_sub, float accel_avg[3], int samp accel_sum[i] += sensor.accelerometer_m_s2[i]; count++; } else { - return ERROR; + errcount++; + continue; } + + if (errcount > samples_num / 10) + return ERROR; } for (int i = 0; i < 3; i++) { |