15static int16_t
i16(
float v) {
return (int16_t)(v > 32767.0f ? 32767 : (v < -32768.0f ? -32768 : lrintf(v))); }
16static uint16_t
u16(
float v) {
return (uint16_t)(v > 65535.0f ? 65535 : (v < 0.0f ? 0 : lrintf(v))); }
17static int32_t
i32(
float v) {
return (int32_t)(v > 2.0e9f ? 2000000000 : (v < -2.0e9f ? -2000000000 : lrintf(v))); }
18static int8_t
i8(
float v) {
return (int8_t)(v > 127.0f ? 127 : (v < -128.0f ? -128 : lrintf(v))); }
20void logf_att(uint32_t t,
const float q[4],
const float w[3],
const float a[3])
25 for (
int i = 0; i < 4; ++i) r.
q[i] =
i16(q[i] * 32767.0f);
26 for (
int i = 0; i < 3; ++i) { r.
gyro[i] =
i16(w[i] * 1000.0f); r.
acc[i] =
i16(a[i] * 1000.0f); }
34 memset(&r, 0,
sizeof r);
40 const float th =
sp->thrust * 255.0f;
41 r.
thrust = (uint8_t)(th > 255.0f ? 255 : (th < 0.0f ? 0 : lrintf(th)));
56 r.
flags = (uint8_t)((
s->in_air ? 1u : 0u) | (
s->landed ? 2u : 0u) | (
s->rc_stale ? 4u : 0u) |
57 (
s->geofence ? 8u : 0u));
58 for (
int i = 0; i < 4; ++i) r.
stick[i] =
i8(
s->stick[i] * 100.0f);
59 r.
silence_ms = (uint16_t)(
s->silence_ms > 65535u ? 65535u :
s->silence_ms);
63void logf_est(uint32_t t,
const float b[3],
float unc,
float vib,
float hz,
float jit,
float cpu,
float mi)
68 for (
int i = 0; i < 3; ++i) r.
gyro_bias[i] =
i16(
b[i] * 10000.0f);
73 r.
cpu_pct = (uint8_t)
u16(cpu > 255.0f ? 255.0f : cpu);
100 r.
cells = (uint8_t)((
b->cells & 0x7Fu) | (
b->present ? 0x80u : 0u));
void logf_vert(uint32_t t, const fc_vert_t *v, const fc_setpoint_t *sp, uint16_t tof_mm, uint32_t baro_pa)
void logf_est(uint32_t t, const float b[3], float unc, float vib, float hz, float jit, float cpu, float mi)
void logf_power(uint32_t t, const batt_state_t *b)
static int16_t i16(float v)
static int8_t i8(float v)
void logf_att(uint32_t t, const float q[4], const float w[3], const float a[3])
void logf_set_clock(uint32_t(*now_ms)(void))
clock for the event records (ms)
static uint16_t u16(float v)
static int32_t i32(float v)
static uint32_t(* s_clock)(void)
void logf_event(const fc_event_t *e)
fc_config_t.on_event
void logf_flight(uint32_t t, const fc_state_t *s)
Producers' side of the flight log: build a record from the values the task already has and queue it (...
int log_q_put(uint8_t src, uint8_t type, const void *p, uint8_t len)
0 = queued
uint8_t log_q_active(void)
Record queues from the producing tasks to the LogTask.
setpoints for the attitude / rate loops (phase 3) and the motor mixer
published state (AppTask builds FLIGHT / MOTORS from it)
vertical state from the estimator (flight-control context)
uint8_t valid
an altitude source is running (baro and/or ToF)
float vz
m, m/s, + up (alt_est)
uint8_t tof_ground
ToF used / ToF below its minimum range
uint8_t flow_q
0..100, 0xFF n/a
int16_t gyro[3]
mrad/s, body (calibrated)
int16_t q[4]
×32767, body -> world NWU [w x y z]
int16_t acc[3]
mg, body (calibrated)
int16_t gyro_bias[3]
0.1 mrad/s
uint8_t flags
bit0 in air, 1 landed, 2 RC stale, 3 geofence
int8_t stick[4]
×100: thr, yaw, pitch, roll
uint16_t silence_ms
app link
uint8_t cells
bit7 = battery present
uint16_t cell_mv
sagged, filtered
uint8_t thrust
collective ×255
uint8_t flags
bit0 alt valid, 1 ToF valid, 2 ToF ground, 3 flow usable, 4 alt loop
int32_t h_mm
altitude estimate
uint16_t tof_mm
0xFFFF n/a
int32_t h_sp_mm
height set point (when the altitude loop runs)