Skip to content
Snippets Groups Projects
Commit 655446fe authored by Andrew Tridgell's avatar Andrew Tridgell
Browse files

INS: make it possible to do accel cal on a different serial port

parent 8aa8f81b
No related branches found
No related tags found
No related merge requests found
...@@ -233,7 +233,9 @@ AP_InertialSensor::_init_accel(void (*delay_cb)(unsigned long t), void (*flash_l ...@@ -233,7 +233,9 @@ AP_InertialSensor::_init_accel(void (*delay_cb)(unsigned long t), void (*flash_l
#if !defined( __AVR_ATmega1280__ ) #if !defined( __AVR_ATmega1280__ )
// perform accelerometer calibration including providing user instructions and feedback // perform accelerometer calibration including providing user instructions and feedback
bool AP_InertialSensor::calibrate_accel(void (*delay_cb)(unsigned long t), void (*flash_leds_cb)(bool on), void (*send_msg)(const prog_char_t *, ...)) bool AP_InertialSensor::calibrate_accel(void (*delay_cb)(unsigned long t), void (*flash_leds_cb)(bool on),
void (*send_msg)(const prog_char_t *, ...),
void (*wait_key)(void))
{ {
Vector3f samples[6]; Vector3f samples[6];
Vector3f new_offsets; Vector3f new_offsets;
...@@ -274,20 +276,9 @@ bool AP_InertialSensor::calibrate_accel(void (*delay_cb)(unsigned long t), void ...@@ -274,20 +276,9 @@ bool AP_InertialSensor::calibrate_accel(void (*delay_cb)(unsigned long t), void
msg = PSTR("on it's back"); msg = PSTR("on it's back");
break; break;
} }
if (send_msg == NULL) { send_msg(PSTR("USER: Place APM %S and press any key.\n"), msg);
Serial.printf_P(PSTR("USER: Place APM %S and press any key.\n"), msg);
}else{
send_msg(PSTR("USER: Place APM %S and press any key.\n"), msg);
}
// wait for user input wait_key();
while( !Serial.available() ) {
delay_cb(20);
}
// clear unput buffer
while( Serial.available() ) {
Serial.read();
}
// clear out any existing samples from ins // clear out any existing samples from ins
update(); update();
...@@ -306,11 +297,7 @@ bool AP_InertialSensor::calibrate_accel(void (*delay_cb)(unsigned long t), void ...@@ -306,11 +297,7 @@ bool AP_InertialSensor::calibrate_accel(void (*delay_cb)(unsigned long t), void
// run the calibration routine // run the calibration routine
if( _calibrate_accel(samples, new_offsets, new_scaling) ) { if( _calibrate_accel(samples, new_offsets, new_scaling) ) {
if (send_msg == NULL) { send_msg(PSTR("Calibration successful\n"));
Serial.printf_P(PSTR("Calibration successful\n"));
}else{
send_msg(PSTR("Calibration successful\n"));
}
// set and save calibration // set and save calibration
_accel_offset.set(new_offsets); _accel_offset.set(new_offsets);
...@@ -319,15 +306,9 @@ bool AP_InertialSensor::calibrate_accel(void (*delay_cb)(unsigned long t), void ...@@ -319,15 +306,9 @@ bool AP_InertialSensor::calibrate_accel(void (*delay_cb)(unsigned long t), void
return true; return true;
} }
if (send_msg == NULL) { send_msg(PSTR("Calibration failed (%.1f %.1f %.1f %.1f %.1f %.1f)\n"),
Serial.printf_P(PSTR("Calibration failed (%.1f %.1f %.1f %.1f %.1f %.1f)\n"), new_offsets.x, new_offsets.y, new_offsets.z,
new_offsets.x, new_offsets.y, new_offsets.z, new_scaling.x, new_scaling.y, new_scaling.z);
new_scaling.x, new_scaling.y, new_scaling.z);
} else {
send_msg(PSTR("Calibration failed (%.1f %.1f %.1f %.1f %.1f %.1f)\n"),
new_offsets.x, new_offsets.y, new_offsets.z,
new_scaling.x, new_scaling.y, new_scaling.z);
}
// restore original scaling and offsets // restore original scaling and offsets
_accel_offset.set(orig_offset); _accel_offset.set(orig_offset);
_accel_scale.set(orig_scale); _accel_scale.set(orig_scale);
......
...@@ -52,8 +52,9 @@ public: ...@@ -52,8 +52,9 @@ public:
#if !defined( __AVR_ATmega1280__ ) #if !defined( __AVR_ATmega1280__ )
// perform accelerometer calibration including providing user instructions and feedback // perform accelerometer calibration including providing user instructions and feedback
virtual bool calibrate_accel(void (*delay_cb)(unsigned long t), virtual bool calibrate_accel(void (*delay_cb)(unsigned long t),
void (*flash_leds_cb)(bool on) = NULL, void (*flash_leds_cb)(bool on),
void (*send_msg)(const prog_char_t *, ...) = NULL); void (*send_msg)(const prog_char_t *, ...),
void (*wait_key)(void));
#endif #endif
/// Perform cold-start initialisation for just the gyros. /// Perform cold-start initialisation for just the gyros.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment