aboutsummaryrefslogtreecommitdiff
path: root/src/modules/commander
diff options
context:
space:
mode:
authorAnton Babushkin <anton.babushkin@me.com>2013-08-22 17:32:59 +0200
committerAnton Babushkin <anton.babushkin@me.com>2013-08-22 17:32:59 +0200
commitc0c5c1c70c8bac5660ac902371e3745125af2a6b (patch)
treeb2326f50c792ed864bad88769ecfceb56b4dd177 /src/modules/commander
parentb5bb20995be8c0f55bed4f2f2bd6cee9efdcf03e (diff)
parentb7cc1c880f94138655696d7bd4a526fc218a4242 (diff)
downloadpx4-firmware-c0c5c1c70c8bac5660ac902371e3745125af2a6b.tar.gz
px4-firmware-c0c5c1c70c8bac5660ac902371e3745125af2a6b.tar.bz2
px4-firmware-c0c5c1c70c8bac5660ac902371e3745125af2a6b.zip
Merge branch 'master' into seatbelt_multirotor_new
Diffstat (limited to 'src/modules/commander')
-rw-r--r--src/modules/commander/accelerometer_calibration.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/modules/commander/accelerometer_calibration.cpp b/src/modules/commander/accelerometer_calibration.cpp
index b3a5d012b..b6217a414 100644
--- a/src/modules/commander/accelerometer_calibration.cpp
+++ b/src/modules/commander/accelerometer_calibration.cpp
@@ -230,6 +230,12 @@ int do_accel_calibration_measurements(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);
@@ -391,6 +397,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) {
@@ -400,8 +408,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++) {