#define __code
#define __reentrant
+#define HAS_FLIGHT 1
+#define HAS_IGNITE 1
+#define HAS_USB 1
+#define HAS_GPS 1
+#ifndef HAS_ACCEL
+#define HAS_ACCEL 1
+#define HAS_ACCEL_REF 0
+#endif
+
#include <ao_data.h>
#define to_fix16(x) ((int16_t) ((x) * 65536.0 + 0.5))
int dummy;
};
-#define ao_add_task(t,f,n)
+#define ao_add_task(t,f,n) ((void) (t))
#define ao_log_start()
#define ao_log_stop()
FILE *emulator_in;
char *emulator_app;
char *emulator_name;
+char *emulator_info;
double emulator_error_max = 4;
double emulator_height_error_max = 20; /* noise in the baro sensor */
#define ao_xmemset(d,v,c) memset(d,v,c)
#define ao_xmemcmp(d,s,c) memcmp(d,s,c)
+#define AO_NEED_ALTITUDE_TO_PRES 1
#include "ao_convert.c"
struct ao_config {
#define DATA_TO_XDATA(x) (x)
-#define HAS_FLIGHT 1
-#define HAS_ADC 1
-#define HAS_USB 1
-#define HAS_GPS 1
-#ifndef HAS_ACCEL
-#define HAS_ACCEL 1
-#define HAS_ACCEL_REF 0
-#endif
#define GRAVITY 9.80665
extern int16_t ao_ground_accel, ao_flight_accel;
extern int16_t ao_accel_2g;
+typedef int16_t accel_t;
+
extern uint16_t ao_sample_tick;
extern int16_t ao_sample_height;
-extern int16_t ao_sample_accel;
+extern accel_t ao_sample_accel;
extern int32_t ao_accel_scale;
extern int16_t ao_ground_height;
extern int16_t ao_sample_alt;
uint16_t prev_tick;
#include "ao_kalman.c"
-#include "ao_sample_mm.c"
-#include "ao_flight_mm.c"
+#include "ao_sample.c"
+#include "ao_flight.c"
#define to_double(f) ((f) / 65536.0)
main_error = fabs(ao_test_main_height_time - main_time);
landed_error = fabs(ao_test_landed_height - landed_height);
landed_time_error = ao_test_landed_time - landed_time;
- if (drogue_error > emulator_error_max || main_error > emulator_error_max ||
- landed_time_error > emulator_error_max || landed_error > emulator_height_error_max) {
+ if (drogue_error > emulator_error_max || main_error > emulator_error_max) {
printf ("%s %s\n",
emulator_app, emulator_name);
+ if (emulator_info)
+ printf ("\t%s\n", emulator_info);
printf ("\tApogee error %g\n", drogue_error);
printf ("\tMain error %g\n", main_error);
printf ("\tLanded height error %g\n", landed_error);
uint16_t
uint16(uint8_t *bytes, int off)
{
- off++;
return (uint16_t) bytes[off] | (((uint16_t) bytes[off+1]) << 8);
}
ao_sleep(void *wchan)
{
if (wchan == &ao_data_head) {
- char type;
- uint16_t tick;
- uint16_t a, b;
- int ret;
+ char type = 0;
+ uint16_t tick = 0;
+ uint16_t a = 0, b = 0;
uint8_t bytes[1024];
union ao_telemetry_all telem;
char line[1024];
}
} else if (len == 99) {
ao_flight_started = 1;
- tick = uint16(bytes, 21);
- ao_flight_ground_accel = int16(bytes, 7);
- ao_config.accel_plus_g = int16(bytes, 17);
- ao_config.accel_minus_g = int16(bytes, 19);
+ tick = uint16(bytes+1, 21);
+ ao_flight_ground_accel = int16(bytes+1, 7);
+ ao_config.accel_plus_g = int16(bytes+1, 17);
+ ao_config.accel_minus_g = int16(bytes+1, 19);
type = 'A';
- a = int16(bytes, 23);
- b = int16(bytes, 25);
+ a = int16(bytes+1, 23);
+ b = int16(bytes+1, 25);
} else if (len == 98) {
ao_flight_started = 1;
- tick = uint16(bytes, 20);
- ao_flight_ground_accel = int16(bytes, 6);
- ao_config.accel_plus_g = int16(bytes, 16);
- ao_config.accel_minus_g = int16(bytes, 18);
+ tick = uint16(bytes+1, 20);
+ ao_flight_ground_accel = int16(bytes+1, 6);
+ ao_config.accel_plus_g = int16(bytes+1, 16);
+ ao_config.accel_minus_g = int16(bytes+1, 18);
type = 'A';
- a = int16(bytes, 22);
- b = int16(bytes, 24);
+ a = int16(bytes+1, 22);
+ b = int16(bytes+1, 24);
} else {
printf("unknown len %d\n", len);
continue;
static const struct option options[] = {
{ .name = "summary", .has_arg = 0, .val = 's' },
{ .name = "debug", .has_arg = 0, .val = 'd' },
+ { .name = "info", .has_arg = 1, .val = 'i' },
{ 0, 0, 0, 0},
};
-void run_flight_fixed(char *name, FILE *f, int summary)
+void run_flight_fixed(char *name, FILE *f, int summary, char *info)
{
emulator_name = name;
emulator_in = f;
+ emulator_info = info;
ao_summary = summary;
ao_flight_init();
ao_flight();
int summary = 0;
int c;
int i;
+ char *info = NULL;
#if HAS_ACCEL
emulator_app="full";
#else
emulator_app="baro";
#endif
- while ((c = getopt_long(argc, argv, "sd", options, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "sdi:", options, NULL)) != -1) {
switch (c) {
case 's':
summary = 1;
case 'd':
ao_flight_debug = 1;
break;
+ case 'i':
+ info = optarg;
+ break;
}
}
if (optind == argc)
- run_flight_fixed("<stdin>", stdin, summary);
+ run_flight_fixed("<stdin>", stdin, summary, info);
else
for (i = optind; i < argc; i++) {
FILE *f = fopen(argv[i], "r");
perror(argv[i]);
continue;
}
- run_flight_fixed(argv[i], f, summary);
+ run_flight_fixed(argv[i], f, summary, info);
fclose(f);
}
+ exit(0);
}