47 #ifndef DRAGSPEED_SEND_ABI_MESSAGE
48 #define DRAGSPEED_SEND_ABI_MESSAGE TRUE
51 #ifndef DRAGSPEED_ACCEL_ID
52 #define DRAGSPEED_ACCEL_ID ABI_BROADCAST
55 #ifndef DRAGSPEED_COEFF_X
56 #define DRAGSPEED_COEFF_X 1.0
59 #ifndef DRAGSPEED_COEFF_Y
60 #define DRAGSPEED_COEFF_Y 1.0
64 #define DRAGSPEED_R 0.25
67 #ifndef DRAGSPEED_FILTER
68 #define DRAGSPEED_FILTER 0.8
88 #ifdef DRAGSPEED_ZERO_X
91 #ifdef DRAGSPEED_ZERO_Y
94 #if defined(DRAGSPEED_ZERO_X) && defined(DRAGSPEED_ZERO_Y)
134 #if DRAGSPEED_SEND_ABI_MESSAGE
157 static bool calibrate_prev =
FALSE;
159 static int num_samples_x = 0;
160 static int num_samples_y = 0;
176 "[dragspeed] Error: zero measurement should be calibrated before drag coefficient!\n");
186 + sinf(att->
psi) * vel_ins->
x, -sinf(att->
psi) * vel_ins->
y
187 + cosf(att->
psi) * vel_ins->
x };
189 if (fabsf(vel_ins_body.
x) > 0.5) {
192 coeff.
x = (coeff.
x * num_samples_x + this_coeff) / (num_samples_x + 1);
195 if (fabsf(vel_ins_body.
y) > 0.5) {
198 coeff.
y = (coeff.
y * num_samples_y + this_coeff) / (num_samples_y + 1);
202 if (num_samples_x > 1000 && num_samples_y > 1000 && coeff.
x != 0
219 static bool calibrate_prev =
FALSE;
221 static int num_samples = 0;
235 float ins_speed = sqrtf(vel_ins->
x * vel_ins->
x + vel_ins->
y * vel_ins->
y);
236 if (ins_speed < 0.1) {
243 if (num_samples > 1000) {
257 + sinf(att->
psi) * vel_ins->
x, -sinf(att->
psi) * vel_ins->
y
258 + cosf(att->
psi) * vel_ins->
x };
261 &vel_ins_body.
x, &vel_ins_body.
y);
Main include for ABI (AirBorneInterface).
Common tools for ABI middelware.
Event structure to store callbacks in a linked list.
void dragspeed_init(void)
bool dragspeed_is_calibrating(void)
#define DRAGSPEED_ACCEL_ID
static void calibrate_zero(struct Int32Vect3 *accel)
Calibrate zero velocity by measuring the accelerations while the drone hovers in-place.
static abi_event accel_ev
struct dragspeed_t dragspeed
bool dragspeed_calibrate_coeff(void)
static void send_dragspeed(struct transport_tx *trans, struct link_device *dev)
#define DRAGSPEED_COEFF_X
bool dragspeed_calibrate_zero(void)
static void accel_cb(uint8_t sender_id, uint32_t stamp, struct Int32Vect3 *accel)
static void calibrate_coeff(struct Int32Vect3 *accel)
Calibrate drag coefficient by comparing accelerometer measurements to INS velocities.
#define DRAGSPEED_COEFF_Y
#define ACCEL_FLOAT_OF_BFP(_ai)
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
static struct EnuCoor_f * stateGetSpeedEnu_f(void)
Get ground speed in local ENU coordinates (float).
vector in East North Up coordinates Units: meters
static const struct usb_device_descriptor dev
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.