2016-07-07 05:26:11 -03:00
|
|
|
/*
|
|
|
|
very simple example module
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
2016-07-13 20:26:03 -03:00
|
|
|
#include <AP_Module_Structures.h>
|
2016-07-07 05:26:11 -03:00
|
|
|
|
2016-07-13 22:30:34 -03:00
|
|
|
void ap_hook_setup_start(uint64_t time_us)
|
2016-07-07 05:26:11 -03:00
|
|
|
{
|
|
|
|
printf("setup_start called\n");
|
|
|
|
}
|
|
|
|
|
2016-07-13 22:30:34 -03:00
|
|
|
void ap_hook_setup_complete(uint64_t time_us)
|
2016-07-07 05:26:11 -03:00
|
|
|
{
|
|
|
|
printf("setup_complete called\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define degrees(x) (x * 180.0 / M_PI)
|
|
|
|
|
2016-07-13 22:30:34 -03:00
|
|
|
void ap_hook_AHRS_update(const struct AHRS_state *state)
|
2016-07-07 05:26:11 -03:00
|
|
|
{
|
|
|
|
static uint64_t last_print_us;
|
|
|
|
if (state->time_us - last_print_us < 1000000UL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
last_print_us = state->time_us;
|
|
|
|
// print euler angles once per second
|
|
|
|
printf("AHRS_update (%.1f,%.1f,%.1f)\n",
|
|
|
|
degrees(state->eulers[0]),
|
|
|
|
degrees(state->eulers[1]),
|
|
|
|
degrees(state->eulers[2]));
|
|
|
|
}
|
2016-07-13 20:26:03 -03:00
|
|
|
|
2016-07-13 22:30:34 -03:00
|
|
|
void ap_hook_gyro_sample(const struct gyro_sample *state)
|
2016-07-13 20:26:03 -03:00
|
|
|
{
|
|
|
|
static uint64_t last_print_us;
|
|
|
|
if (state->time_us - last_print_us < 1000000UL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
last_print_us = state->time_us;
|
|
|
|
// print gyro rates once per second
|
|
|
|
printf("gyro (%.1f,%.1f,%.1f)\n",
|
|
|
|
degrees(state->gyro[0]),
|
|
|
|
degrees(state->gyro[1]),
|
|
|
|
degrees(state->gyro[2]));
|
|
|
|
}
|
|
|
|
|
2016-07-13 22:30:34 -03:00
|
|
|
void ap_hook_accel_sample(const struct accel_sample *state)
|
2016-07-13 20:26:03 -03:00
|
|
|
{
|
|
|
|
static uint64_t last_print_us;
|
|
|
|
if (state->time_us - last_print_us < 1000000UL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
last_print_us = state->time_us;
|
|
|
|
// print accels once per second
|
|
|
|
printf("accel (%.1f,%.1f,%.1f)\n",
|
|
|
|
state->accel[0],
|
|
|
|
state->accel[1],
|
|
|
|
state->accel[2]);
|
|
|
|
}
|