#include <stdio.h>
#include <signal.h>
#define Nx 3
#define Ny 1
#define Nu 1
#define SAMPLE_RATE 200 // hz
#define DT (1.0/SAMPLE_RATE)
#define ACCEL_LP_TC 20*DT // fast LP filter for accel
#define PRINT_HZ 10
#define BMP_RATE_DIV 10 // optionally sample bmp less frequently than mpu
static int running = 0;
static void __signal_handler(__attribute__ ((unused)) int dummy)
{
running=0;
return;
}
static void __dmp_handler(void)
{
int i;
double accel_vec[3];
static int bmp_sample_counter = 0;
for(i=0;i<3;i++) accel_vec[i]=mpu_data.
accel[i];
}
bmp_sample_counter++;
if(bmp_sample_counter>=BMP_RATE_DIV){
bmp_sample_counter=0;
}
return;
}
int main(void)
{
signal(SIGINT, __signal_handler);
running = 1;
printf("initializing barometer\n");
printf("initializing DMP\n");
printf("waiting for sensors to settle");
fflush(stdout);
printf("\r\n");
printf(" altitude |");
printf(" velocity |");
printf(" accel_bias |");
printf(" alt (bmp) |");
printf(" vert_accel |");
printf("\n");
while(running){
printf("\r");
printf(
"%8.2fm |", kf.
x_est.
d[0]);
printf(
"%7.2fm/s |", kf.
x_est.
d[1]);
printf(
"%7.2fm/s^2|", kf.
x_est.
d[2]);
printf(
"%9.2fm |", bmp_data.
alt_m);
fflush(stdout);
}
printf("\n");
return 0;
}