PX4 Firmware
PX4 Autopilot Software http://px4.io
gyro_calibration.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 *
3 * Copyright (c) 2013-2017 PX4 Development Team. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 * 3. Neither the name PX4 nor the names of its contributors may be
16 * used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 ****************************************************************************/
33 
34 /**
35  * @file gyro_calibration.cpp
36  *
37  * Gyroscope calibration routine
38  */
39 
40 #include <px4_platform_common/px4_config.h>
41 #include "gyro_calibration.h"
42 #include "calibration_messages.h"
43 #include "calibration_routines.h"
44 #include "commander_helper.h"
45 
46 #include <px4_platform_common/posix.h>
47 #include <px4_platform_common/defines.h>
48 #include <px4_platform_common/time.h>
49 #include <stdio.h>
50 #include <unistd.h>
51 #include <fcntl.h>
52 #include <poll.h>
53 #include <math.h>
54 #include <string.h>
55 #include <drivers/drv_hrt.h>
58 #include <drivers/drv_gyro.h>
59 #include <systemlib/mavlink_log.h>
60 #include <parameters/param.h>
61 #include <systemlib/err.h>
62 
63 static const char *sensor_name = "gyro";
64 
65 static constexpr unsigned max_gyros = 3;
66 
67 /// Data passed to calibration worker routine
68 typedef struct {
70  int32_t device_id[max_gyros];
71  int gyro_sensor_sub[max_gyros];
73  struct gyro_calibration_s gyro_scale[max_gyros];
76 
77 static calibrate_return gyro_calibration_worker(int cancel_sub, void *data)
78 {
79  gyro_worker_data_t *worker_data = (gyro_worker_data_t *)(data);
80  unsigned calibration_counter[max_gyros] = { 0 }, slow_count = 0;
81  const unsigned calibration_count = 5000;
82  sensor_gyro_s gyro_report;
83  unsigned poll_errcount = 0;
84 
85  struct sensor_correction_s sensor_correction {}; /**< sensor thermal corrections */
86 
87  if (orb_copy(ORB_ID(sensor_correction), worker_data->sensor_correction_sub, &sensor_correction) != 0) {
88  for (unsigned i = 0; i < 3; i++) {
89  sensor_correction.gyro_scale_0[i] = 1.0f;
90  sensor_correction.gyro_scale_1[i] = 1.0f;
91  sensor_correction.gyro_scale_2[i] = 1.0f;
92  }
93  }
94 
95  px4_pollfd_struct_t fds[max_gyros];
96 
97  for (unsigned s = 0; s < max_gyros; s++) {
98  fds[s].fd = worker_data->gyro_sensor_sub[s];
99  fds[s].events = POLLIN;
100  }
101 
102  memset(&worker_data->gyro_report_0, 0, sizeof(worker_data->gyro_report_0));
103 
104 
105  /* use slowest gyro to pace, but count correctly per-gyro for statistics */
106  while (slow_count < calibration_count) {
107  if (calibrate_cancel_check(worker_data->mavlink_log_pub, cancel_sub)) {
109  }
110 
111  /* check if there are new thermal corrections */
112  bool updated;
113  orb_check(worker_data->sensor_correction_sub, &updated);
114 
115  if (updated) {
116  orb_copy(ORB_ID(sensor_correction), worker_data->sensor_correction_sub, &sensor_correction);
117  }
118 
119  int poll_ret = px4_poll(&fds[0], max_gyros, 1000);
120 
121  if (poll_ret > 0) {
122  unsigned update_count = calibration_count;
123 
124  for (unsigned s = 0; s < max_gyros; s++) {
125  if (calibration_counter[s] >= calibration_count) {
126  // Skip if instance has enough samples
127  continue;
128  }
129 
130  bool changed;
131  orb_check(worker_data->gyro_sensor_sub[s], &changed);
132 
133  if (changed) {
134  orb_copy(ORB_ID(sensor_gyro), worker_data->gyro_sensor_sub[s], &gyro_report);
135 
136  if (s == 0) {
137  // take a working copy
138  worker_data->gyro_scale[s].x_offset += (gyro_report.x - sensor_correction.gyro_offset_0[0]) *
139  sensor_correction.gyro_scale_0[0];
140  worker_data->gyro_scale[s].y_offset += (gyro_report.y - sensor_correction.gyro_offset_0[1]) *
141  sensor_correction.gyro_scale_0[1];
142  worker_data->gyro_scale[s].z_offset += (gyro_report.z - sensor_correction.gyro_offset_0[2]) *
143  sensor_correction.gyro_scale_0[2];
144 
145  // take a reference copy of the primary sensor including correction for thermal drift
146  orb_copy(ORB_ID(sensor_gyro), worker_data->gyro_sensor_sub[s], &worker_data->gyro_report_0);
147  worker_data->gyro_report_0.x = (gyro_report.x - sensor_correction.gyro_offset_0[0]) * sensor_correction.gyro_scale_0[0];
148  worker_data->gyro_report_0.y = (gyro_report.y - sensor_correction.gyro_offset_0[1]) * sensor_correction.gyro_scale_0[1];
149  worker_data->gyro_report_0.z = (gyro_report.z - sensor_correction.gyro_offset_0[2]) * sensor_correction.gyro_scale_0[2];
150 
151  } else if (s == 1) {
152  worker_data->gyro_scale[s].x_offset += (gyro_report.x - sensor_correction.gyro_offset_1[0]) *
153  sensor_correction.gyro_scale_1[0];
154  worker_data->gyro_scale[s].y_offset += (gyro_report.y - sensor_correction.gyro_offset_1[1]) *
155  sensor_correction.gyro_scale_1[1];
156  worker_data->gyro_scale[s].z_offset += (gyro_report.z - sensor_correction.gyro_offset_1[2]) *
157  sensor_correction.gyro_scale_1[2];
158 
159  } else if (s == 2) {
160  worker_data->gyro_scale[s].x_offset += (gyro_report.x - sensor_correction.gyro_offset_2[0]) *
161  sensor_correction.gyro_scale_2[0];
162  worker_data->gyro_scale[s].y_offset += (gyro_report.y - sensor_correction.gyro_offset_2[1]) *
163  sensor_correction.gyro_scale_2[1];
164  worker_data->gyro_scale[s].z_offset += (gyro_report.z - sensor_correction.gyro_offset_2[2]) *
165  sensor_correction.gyro_scale_2[2];
166 
167  } else {
168  worker_data->gyro_scale[s].x_offset += gyro_report.x;
169  worker_data->gyro_scale[s].y_offset += gyro_report.y;
170  worker_data->gyro_scale[s].z_offset += gyro_report.z;
171 
172  }
173 
174  calibration_counter[s]++;
175 
176  }
177 
178  // Maintain the sample count of the slowest sensor
179  if (calibration_counter[s] && calibration_counter[s] < update_count) {
180  update_count = calibration_counter[s];
181  }
182 
183  }
184 
185  if (update_count % (calibration_count / 20) == 0) {
186  calibration_log_info(worker_data->mavlink_log_pub, CAL_QGC_PROGRESS_MSG, (update_count * 100) / calibration_count);
187  }
188 
189  // Propagate out the slowest sensor's count
190  if (slow_count < update_count) {
191  slow_count = update_count;
192  }
193 
194  } else {
195  poll_errcount++;
196  }
197 
198  if (poll_errcount > 1000) {
200  return calibrate_return_error;
201  }
202  }
203 
204  for (unsigned s = 0; s < max_gyros; s++) {
205  if (worker_data->device_id[s] != 0 && calibration_counter[s] < calibration_count / 2) {
206  calibration_log_critical(worker_data->mavlink_log_pub, "ERROR: missing data, sensor %d", s)
207  return calibrate_return_error;
208  }
209 
210  worker_data->gyro_scale[s].x_offset /= calibration_counter[s];
211  worker_data->gyro_scale[s].y_offset /= calibration_counter[s];
212  worker_data->gyro_scale[s].z_offset /= calibration_counter[s];
213  }
214 
215  return calibrate_return_ok;
216 }
217 
219 {
220  int res = PX4_OK;
221  gyro_worker_data_t worker_data = {};
222 
224 
225  worker_data.mavlink_log_pub = mavlink_log_pub;
226 
227  struct gyro_calibration_s gyro_scale_zero;
228  gyro_scale_zero.x_offset = 0.0f;
229  gyro_scale_zero.x_scale = 1.0f;
230  gyro_scale_zero.y_offset = 0.0f;
231  gyro_scale_zero.y_scale = 1.0f;
232  gyro_scale_zero.z_offset = 0.0f;
233  gyro_scale_zero.z_scale = 1.0f;
234 
235  int device_prio_max = 0;
236  int32_t device_id_primary = 0;
237 
238  worker_data.sensor_correction_sub = orb_subscribe(ORB_ID(sensor_correction));
239 
240  for (unsigned s = 0; s < max_gyros; s++) {
241  char str[30];
242 
243  // Reset gyro ids to unavailable.
244  worker_data.device_id[s] = 0;
245  // And set default subscriber values.
246  worker_data.gyro_sensor_sub[s] = -1;
247  (void)sprintf(str, "CAL_GYRO%u_ID", s);
248  res = param_set_no_notification(param_find(str), &(worker_data.device_id[s]));
249 
250  if (res != PX4_OK) {
251  calibration_log_critical(mavlink_log_pub, "Unable to reset CAL_GYRO%u_ID", s);
252  return PX4_ERROR;
253  }
254 
255  // Reset all offsets to 0 and scales to 1
256  (void)memcpy(&worker_data.gyro_scale[s], &gyro_scale_zero, sizeof(gyro_scale_zero));
257 #ifdef __PX4_NUTTX
258  sprintf(str, "%s%u", GYRO_BASE_DEVICE_PATH, s);
259  int fd = px4_open(str, 0);
260 
261  if (fd >= 0) {
262  worker_data.device_id[s] = px4_ioctl(fd, DEVIOCGDEVICEID, 0);
263  res = px4_ioctl(fd, GYROIOCSSCALE, (long unsigned int)&gyro_scale_zero);
264  px4_close(fd);
265 
266  if (res != PX4_OK) {
268  return PX4_ERROR;
269  }
270  }
271 
272 #else
273  (void)sprintf(str, "CAL_GYRO%u_XOFF", s);
274  res = param_set_no_notification(param_find(str), &gyro_scale_zero.x_offset);
275 
276  if (res != PX4_OK) {
277  PX4_ERR("unable to reset %s", str);
278  }
279 
280  (void)sprintf(str, "CAL_GYRO%u_YOFF", s);
281  res = param_set_no_notification(param_find(str), &gyro_scale_zero.y_offset);
282 
283  if (res != PX4_OK) {
284  PX4_ERR("unable to reset %s", str);
285  }
286 
287  (void)sprintf(str, "CAL_GYRO%u_ZOFF", s);
288  res = param_set_no_notification(param_find(str), &gyro_scale_zero.z_offset);
289 
290  if (res != PX4_OK) {
291  PX4_ERR("unable to reset %s", str);
292  }
293 
294  (void)sprintf(str, "CAL_GYRO%u_XSCALE", s);
295  res = param_set_no_notification(param_find(str), &gyro_scale_zero.x_scale);
296 
297  if (res != PX4_OK) {
298  PX4_ERR("unable to reset %s", str);
299  }
300 
301  (void)sprintf(str, "CAL_GYRO%u_YSCALE", s);
302  res = param_set_no_notification(param_find(str), &gyro_scale_zero.y_scale);
303 
304  if (res != PX4_OK) {
305  PX4_ERR("unable to reset %s", str);
306  }
307 
308  (void)sprintf(str, "CAL_GYRO%u_ZSCALE", s);
309  res = param_set_no_notification(param_find(str), &gyro_scale_zero.z_scale);
310 
311  if (res != PX4_OK) {
312  PX4_ERR("unable to reset %s", str);
313  }
314 
316 #endif
317 
318  }
319 
320  // We should not try to subscribe if the topic doesn't actually exist and can be counted.
321  const unsigned orb_gyro_count = orb_group_count(ORB_ID(sensor_gyro));
322 
323  // Warn that we will not calibrate more than max_gyros gyroscopes
324  if (orb_gyro_count > max_gyros) {
325  calibration_log_critical(mavlink_log_pub, "Detected %u gyros, but will calibrate only %u", orb_gyro_count, max_gyros);
326  }
327 
328  for (unsigned cur_gyro = 0; cur_gyro < orb_gyro_count && cur_gyro < max_gyros; cur_gyro++) {
329 
330  // Lock in to correct ORB instance
331  bool found_cur_gyro = false;
332 
333  for (unsigned i = 0; i < orb_gyro_count && !found_cur_gyro; i++) {
334  worker_data.gyro_sensor_sub[cur_gyro] = orb_subscribe_multi(ORB_ID(sensor_gyro), i);
335 
336  sensor_gyro_s report{};
337  orb_copy(ORB_ID(sensor_gyro), worker_data.gyro_sensor_sub[cur_gyro], &report);
338 
339 #ifdef __PX4_NUTTX
340 
341  // For NuttX, we get the UNIQUE device ID from the sensor driver via an IOCTL
342  // and match it up with the one from the uORB subscription, because the
343  // instance ordering of uORB and the order of the FDs may not be the same.
344 
345  if (report.device_id == (uint32_t)worker_data.device_id[cur_gyro]) {
346  // Device IDs match, correct ORB instance for this gyro
347  found_cur_gyro = true;
348 
349  } else {
350  orb_unsubscribe(worker_data.gyro_sensor_sub[cur_gyro]);
351  }
352 
353 #else
354 
355  // For the DriverFramework drivers, we fill device ID (this is the first time) by copying one report.
356  worker_data.device_id[cur_gyro] = report.device_id;
357  found_cur_gyro = true;
358 
359 #endif
360  }
361 
362  if (!found_cur_gyro) {
363  calibration_log_critical(mavlink_log_pub, "Gyro #%u (ID %u) no matching uORB devid", cur_gyro,
364  worker_data.device_id[cur_gyro]);
366  break;
367  }
368 
369  if (worker_data.device_id[cur_gyro] != 0) {
370  // Get priority
371  int32_t prio;
372  orb_priority(worker_data.gyro_sensor_sub[cur_gyro], &prio);
373 
374  if (prio > device_prio_max) {
375  device_prio_max = prio;
376  device_id_primary = worker_data.device_id[cur_gyro];
377  }
378 
379  } else {
380  calibration_log_critical(mavlink_log_pub, "Gyro #%u no device id, abort", cur_gyro);
381  }
382  }
383 
384  int cancel_sub = calibrate_cancel_subscribe();
385 
386  unsigned try_count = 0;
387  unsigned max_tries = 20;
388  res = PX4_ERROR;
389 
390  do {
391  // Calibrate gyro and ensure user didn't move
392  calibrate_return cal_return = gyro_calibration_worker(cancel_sub, &worker_data);
393 
394  if (cal_return == calibrate_return_cancelled) {
395  // Cancel message already sent, we are done here
396  res = PX4_ERROR;
397  break;
398 
399  } else if (cal_return == calibrate_return_error) {
400  res = PX4_ERROR;
401 
402  } else {
403  /* check offsets */
404  float xdiff = worker_data.gyro_report_0.x - worker_data.gyro_scale[0].x_offset;
405  float ydiff = worker_data.gyro_report_0.y - worker_data.gyro_scale[0].y_offset;
406  float zdiff = worker_data.gyro_report_0.z - worker_data.gyro_scale[0].z_offset;
407 
408  /* maximum allowable calibration error in radians */
409  const float maxoff = 0.01f;
410 
411  if (!PX4_ISFINITE(worker_data.gyro_scale[0].x_offset) ||
412  !PX4_ISFINITE(worker_data.gyro_scale[0].y_offset) ||
413  !PX4_ISFINITE(worker_data.gyro_scale[0].z_offset) ||
414  fabsf(xdiff) > maxoff ||
415  fabsf(ydiff) > maxoff ||
416  fabsf(zdiff) > maxoff) {
417 
418  calibration_log_critical(mavlink_log_pub, "motion, retrying..");
419  res = PX4_ERROR;
420 
421  } else {
422  res = PX4_OK;
423  }
424  }
425 
426  try_count++;
427 
428  } while (res == PX4_ERROR && try_count <= max_tries);
429 
430  if (try_count >= max_tries) {
431  calibration_log_critical(mavlink_log_pub, "ERROR: Motion during calibration");
432  res = PX4_ERROR;
433  }
434 
435  calibrate_cancel_unsubscribe(cancel_sub);
436 
437  for (unsigned s = 0; s < max_gyros; s++) {
438  px4_close(worker_data.gyro_sensor_sub[s]);
439  }
440 
441  if (res == PX4_OK) {
442 
443  /* set offset parameters to new values */
444  bool failed = false;
445 
446  failed = failed || (PX4_OK != param_set_no_notification(param_find("CAL_GYRO_PRIME"), &(device_id_primary)));
447 
448  bool tc_locked[3] = {false}; // true when the thermal parameter instance has already been adjusted by the calibrator
449 
450  for (unsigned uorb_index = 0; uorb_index < max_gyros; uorb_index++) {
451  if (worker_data.device_id[uorb_index] != 0) {
452  char str[30];
453 
454  /* check if thermal compensation is enabled */
455  int32_t tc_enabled_int;
456  param_get(param_find("TC_G_ENABLE"), &(tc_enabled_int));
457 
458  if (tc_enabled_int == 1) {
459  /* Get struct containing sensor thermal compensation data */
460  struct sensor_correction_s sensor_correction; /**< sensor thermal corrections */
461  memset(&sensor_correction, 0, sizeof(sensor_correction));
462  orb_copy(ORB_ID(sensor_correction), worker_data.sensor_correction_sub, &sensor_correction);
463 
464  /* don't allow a parameter instance to be calibrated again by another uORB instance */
465  if (!tc_locked[sensor_correction.gyro_mapping[uorb_index]]) {
466  tc_locked[sensor_correction.gyro_mapping[uorb_index]] = true;
467 
468  /* update the _X0_ terms to include the additional offset */
469  int32_t handle;
470  float val;
471 
472  for (unsigned axis_index = 0; axis_index < 3; axis_index++) {
473  val = 0.0f;
474  (void)sprintf(str, "TC_G%u_X0_%u", sensor_correction.gyro_mapping[uorb_index], axis_index);
475  handle = param_find(str);
476  param_get(handle, &val);
477 
478  if (axis_index == 0) {
479  val += worker_data.gyro_scale[uorb_index].x_offset;
480 
481  } else if (axis_index == 1) {
482  val += worker_data.gyro_scale[uorb_index].y_offset;
483 
484  } else if (axis_index == 2) {
485  val += worker_data.gyro_scale[uorb_index].z_offset;
486 
487  }
488 
489  failed |= (PX4_OK != param_set_no_notification(handle, &val));
490  }
491 
493  }
494 
495  // Ensure the calibration values used the driver are at default settings
496  worker_data.gyro_scale[uorb_index].x_offset = 0.f;
497  worker_data.gyro_scale[uorb_index].y_offset = 0.f;
498  worker_data.gyro_scale[uorb_index].z_offset = 0.f;
499  }
500 
501  (void)sprintf(str, "CAL_GYRO%u_XOFF", uorb_index);
502  failed |= (PX4_OK != param_set_no_notification(param_find(str), &(worker_data.gyro_scale[uorb_index].x_offset)));
503  (void)sprintf(str, "CAL_GYRO%u_YOFF", uorb_index);
504  failed |= (PX4_OK != param_set_no_notification(param_find(str), &(worker_data.gyro_scale[uorb_index].y_offset)));
505  (void)sprintf(str, "CAL_GYRO%u_ZOFF", uorb_index);
506  failed |= (PX4_OK != param_set_no_notification(param_find(str), &(worker_data.gyro_scale[uorb_index].z_offset)));
507 
508  (void)sprintf(str, "CAL_GYRO%u_ID", uorb_index);
509  failed |= (PX4_OK != param_set_no_notification(param_find(str), &(worker_data.device_id[uorb_index])));
510 
511 #ifdef __PX4_NUTTX
512  /* apply new scaling and offsets */
513  (void)sprintf(str, "%s%u", GYRO_BASE_DEVICE_PATH, uorb_index);
514  int fd = px4_open(str, 0);
515 
516  if (fd < 0) {
517  failed = true;
518  continue;
519  }
520 
521  res = px4_ioctl(fd, GYROIOCSSCALE, (long unsigned int)&worker_data.gyro_scale[uorb_index]);
522  px4_close(fd);
523 
524  if (res != PX4_OK) {
526  }
527 
528 #endif
529  }
530  }
531 
532  if (failed) {
533  calibration_log_critical(mavlink_log_pub, "ERROR: failed to set offset params");
534  res = PX4_ERROR;
535  }
536  }
537 
538  /* if there is a any preflight-check system response, let the barrage of messages through */
539  px4_usleep(200000);
540 
541  if (res == PX4_OK) {
543 
544  } else {
546  }
547 
549 
550  /* give this message enough time to propagate */
551  px4_usleep(600000);
552 
553  return res;
554 }
#define CAL_ERROR_SENSOR_MSG
static orb_advert_t * mavlink_log_pub
int orb_copy(const struct orb_metadata *meta, int handle, void *buffer)
Definition: uORB.cpp:90
#define CAL_QGC_DONE_MSG
Gyroscope driver interface.
static const char * sensor_name
__EXPORT int param_get(param_t param, void *val)
Copy the value of a parameter.
Definition: parameters.cpp:589
gyro scaling factors; Vout = (Vin * Vscale) + Voffset
Definition: drv_gyro.h:54
__EXPORT int param_set_no_notification(param_t param, const void *val)
Set the value of a parameter, but do not notify the system about the change.
Definition: parameters.cpp:820
Common calibration messages.
int do_gyro_calibration(orb_advert_t *mavlink_log_pub)
int orb_priority(int handle, int32_t *priority)
Definition: uORB.cpp:121
int gyro_sensor_sub[max_gyros]
int px4_poll(px4_pollfd_struct_t *fds, nfds_t nfds, int timeout)
Airspeed sensor calibration routine.
#define CAL_ERROR_RESET_CAL_MSG
static int32_t device_id[max_accel_sens]
High-resolution timer with callouts and timekeeping.
Global flash based parameter store.
void calibrate_cancel_unsubscribe(int cmd_sub)
Called to cancel the subscription to the cancel command.
int orb_subscribe(const struct orb_metadata *meta)
Definition: uORB.cpp:75
#define ORB_ID(_name)
Generates a pointer to the uORB metadata structure for a given topic.
Definition: uORB.h:87
Commander helper functions definitions.
static constexpr unsigned max_gyros
#define GYRO_BASE_DEVICE_PATH
Definition: drv_gyro.h:49
Data passed to calibration worker routine.
uint8_t * data
Definition: dataman.cpp:149
#define CAL_ERROR_APPLY_CAL_MSG
int orb_unsubscribe(int handle)
Definition: uORB.cpp:85
calibrate_return
#define CAL_QGC_STARTED_MSG
static calibrate_return gyro_calibration_worker(int cancel_sub, void *data)
Simple error/warning functions, heavily inspired by the BSD functions of the same names...
int32_t device_id_primary
__BEGIN_DECLS typedef void * orb_advert_t
ORB topic advertiser handle.
Definition: uORB.h:134
int fd
Definition: dataman.cpp:146
int orb_group_count(const struct orb_metadata *meta)
Get the number of published instances of a topic group.
Definition: uORB.cpp:110
__EXPORT param_t param_find(const char *name)
Look up a parameter by name.
Definition: parameters.cpp:370
int device_prio_max
int px4_open(const char *path, int flags,...)
__EXPORT void param_notify_changes(void)
Notify the system about parameter changes.
Definition: parameters.cpp:323
bool calibrate_cancel_check(orb_advert_t *mavlink_log_pub, int cancel_sub)
Used to periodically check for a cancel command.
int orb_check(int handle, bool *updated)
Definition: uORB.cpp:95
int orb_subscribe_multi(const struct orb_metadata *meta, unsigned instance)
Definition: uORB.cpp:80
#define GYROIOCSSCALE
set the gyro scaling constants to (arg)
Definition: drv_gyro.h:71
#define calibration_log_critical(_pub, _text,...)
int32_t device_id[max_gyros]
sensor_gyro_s gyro_report_0
struct gyro_calibration_s gyro_scale[max_gyros]
#define CAL_QGC_PROGRESS_MSG
#define CAL_QGC_FAILED_MSG
int calibrate_cancel_subscribe()
Called at the beginning of calibration in order to subscribe to the cancel command.
orb_advert_t * mavlink_log_pub
#define calibration_log_info(_pub, _text,...)
int px4_close(int fd)
int px4_ioctl(int fd, int cmd, unsigned long arg)