- printf("%7.2f height %g accel %g state %s k_height %g k_speed %g k_accel %g drogue %g main %g error %d\n",
- (double) (ao_adc_static.tick + tick_offset) / 100,
- height,
- accel,
- ao_state_names[ao_flight_state],
- ao_k_height / 65536.0,
- ao_k_speed / 65536.0 / 16.0,
- ao_k_accel / 65536.0 / 16.0,
- drogue_height / 65536.0,
- main_height / 65536.0,
- ao_error_h_sq_avg);
+ time = (double) (ao_adc_static.tick + tick_offset) / 100;
+ if (!ao_summary) {
+ printf("%7.2f height %g accel %g state %s k_height %g k_speed %g k_accel %g drogue %d main %d error %d\n",
+ time,
+ height,
+ accel,
+ ao_state_names[ao_flight_state],
+ ao_k_height / 65536.0,
+ ao_k_speed / 65536.0 / 16.0,
+ ao_k_accel / 65536.0 / 16.0,
+ drogue_height,
+ main_height,
+ ao_error_h_sq_avg);
+ }
+
+ if (ao_test_max_height < height) {
+ ao_test_max_height = height;
+ ao_test_max_height_time = time;
+ }
+ if (height > ao_config.main_deploy) {
+ ao_test_main_height_time = time;
+ ao_test_main_height = height;
+ }
+ }
+}
+
+void
+ao_test_exit(void)
+{
+ double drogue_error;
+ double main_error;
+
+ if (!ao_test_main_height_time) {
+ ao_test_main_height_time = ao_test_max_height_time;
+ ao_test_main_height = ao_test_max_height;
+ }
+ drogue_error = fabs(ao_test_max_height_time - drogue_time);
+ main_error = fabs(ao_test_main_height_time - main_time);
+ if (drogue_error > emulator_error_max || main_error > emulator_error_max) {
+ printf ("%s %s\n",
+ emulator_app, emulator_name);
+ printf ("\tApogee error %g\n", drogue_error);
+ printf ("\tMain error %g\n", main_error);
+ printf ("\tActual: apogee: %d at %7.2f main: %d at %7.2f\n",
+ ao_test_max_height, ao_test_max_height_time,
+ ao_test_main_height, ao_test_main_height_time);
+ printf ("\tComputed: apogee: %d at %7.2f main: %d at %7.2f\n",
+ drogue_height, drogue_time, main_height, main_time);
+ exit (1);