ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
Loading...
Searching...
No Matches
telemetry.h File Reference

Telemetry packet format (shared with 02 - Tools/00 - Matlab/Telemetry/parseTelemetry.m and 02 - Tools/01 - Python/acwing_tools/telemetry.py). More...

#include <stdint.h>
#include <stddef.h>
Include dependency graph for telemetry.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  tlm_state_t
 
struct  tlm_init_t
 
struct  tlm_status_t
 

Macros

#define TLM_SYNC0   0xA5u
 
#define TLM_SYNC1   0x5Au
 
#define TLM_TYPE_STATE   0x01u
 
#define TLM_TYPE_INIT   0x02u
 
#define TLM_TYPE_STATUS   0x03u
 10 Hz diagnostics, ALWAYS sent (also during calibration)
 
#define TLM_TYPE_REPLAY   0x04u
 trace of the filter calls + resulting state (parity)

 
#define TLM_OVERHEAD   6u
 
#define TLM_F_RUNNING   0x01u
 
#define TLM_F_MAG_NEW   0x02u
 magnetometer update performed on this sample

 
#define TLM_F_ACC_GATED   0x04u
 acc de-weighted (magnitude or NIS)

 
#define TLM_F_MAG_GATED   0x08u
 
#define TLM_F_OVERRUN   0x10u
 samples lost upstream (queue full)

 
#define TLM_F_STILL   0x20u
 stillness detector active

 
#define TLM_I_EST_BIAS   0x01u
 
#define TLM_I_ADAPTIVE   0x02u
 
#define TLM_I_TILT_COMP   0x04u
 
#define TLM_I_DECOUPLE   0x08u
 
#define TLM_I_RESET_JAC   0x10u
 
#define TLM_I_TANGENT   0x20u
 tangential vector innovation (firmware 0.6.0)
 
#define TLM_REPLAY_TAIL   60u
 
#define TLM_REPLAY_MAX   (6u + 140u + TLM_REPLAY_TAIL)
 
#define TLM_FRAME_MAX   (TLM_REPLAY_MAX + TLM_OVERHEAD)
 

Functions

uint16_t tlm_crc16 (const uint8_t *data, size_t len)
 
size_t tlm_encode (uint8_t type, const void *payload, uint8_t len, uint8_t *out, size_t cap)
 Writes the complete frame into out; returns its length, 0 if cap is too small.
 

Detailed Description

Telemetry packet format (shared with 02 - Tools/00 - Matlab/Telemetry/parseTelemetry.m and 02 - Tools/01 - Python/acwing_tools/telemetry.py).

Frame (little-endian): 0xA5 0x5A | TYPE | LEN | PAYLOAD[LEN] | CRC16 (LSB, MSB) CRC-16/CCITT-FALSE (poly 0x1021, init 0xFFFF) computed over TYPE..PAYLOAD.

TYPE 0x01 STATE : one filter sample (attitude + bias + raw sensors) TYPE 0x02 INIT : parameters used by the filter, re-sent periodically. Lets MATLAB re-run iekfAttitude.m with EXACTLY the same conditions (compareEmbeddedVsMatlab.m). TYPE 0x03 STATUS : diagnostics, always sent TYPE 0x04 REPLAY : trace of the filter calls + resulting state

The same frames go over BLE as a byte stream (tlm_ble.h): no BLE-specific packet format.

Definition in file telemetry.h.

Macro Definition Documentation

◆ TLM_SYNC0

#define TLM_SYNC0   0xA5u

Definition at line 26 of file telemetry.h.

◆ TLM_SYNC1

#define TLM_SYNC1   0x5Au

Definition at line 27 of file telemetry.h.

◆ TLM_TYPE_STATE

#define TLM_TYPE_STATE   0x01u

Definition at line 28 of file telemetry.h.

◆ TLM_TYPE_INIT

#define TLM_TYPE_INIT   0x02u

Definition at line 29 of file telemetry.h.

◆ TLM_TYPE_STATUS

#define TLM_TYPE_STATUS   0x03u

10 Hz diagnostics, ALWAYS sent (also during calibration)

Definition at line 30 of file telemetry.h.

◆ TLM_TYPE_REPLAY

#define TLM_TYPE_REPLAY   0x04u

trace of the filter calls + resulting state (parity)

Definition at line 31 of file telemetry.h.

◆ TLM_OVERHEAD

#define TLM_OVERHEAD   6u

Definition at line 32 of file telemetry.h.

◆ TLM_F_RUNNING

#define TLM_F_RUNNING   0x01u

Definition at line 35 of file telemetry.h.

◆ TLM_F_MAG_NEW

#define TLM_F_MAG_NEW   0x02u

magnetometer update performed on this sample

Definition at line 36 of file telemetry.h.

◆ TLM_F_ACC_GATED

#define TLM_F_ACC_GATED   0x04u

acc de-weighted (magnitude or NIS)

Definition at line 37 of file telemetry.h.

◆ TLM_F_MAG_GATED

#define TLM_F_MAG_GATED   0x08u

Definition at line 38 of file telemetry.h.

◆ TLM_F_OVERRUN

#define TLM_F_OVERRUN   0x10u

samples lost upstream (queue full)

Definition at line 39 of file telemetry.h.

◆ TLM_F_STILL

#define TLM_F_STILL   0x20u

stillness detector active

Definition at line 40 of file telemetry.h.

◆ TLM_I_EST_BIAS

#define TLM_I_EST_BIAS   0x01u

Definition at line 42 of file telemetry.h.

◆ TLM_I_ADAPTIVE

#define TLM_I_ADAPTIVE   0x02u

Definition at line 43 of file telemetry.h.

◆ TLM_I_TILT_COMP

#define TLM_I_TILT_COMP   0x04u

Definition at line 44 of file telemetry.h.

◆ TLM_I_DECOUPLE

#define TLM_I_DECOUPLE   0x08u

Definition at line 45 of file telemetry.h.

◆ TLM_I_RESET_JAC

#define TLM_I_RESET_JAC   0x10u

Definition at line 46 of file telemetry.h.

◆ TLM_I_TANGENT

#define TLM_I_TANGENT   0x20u

tangential vector innovation (firmware 0.6.0)

Definition at line 47 of file telemetry.h.

◆ TLM_REPLAY_TAIL

#define TLM_REPLAY_TAIL   60u

Definition at line 114 of file telemetry.h.

◆ TLM_REPLAY_MAX

#define TLM_REPLAY_MAX   (6u + 140u + TLM_REPLAY_TAIL)

Definition at line 115 of file telemetry.h.

◆ TLM_FRAME_MAX

#define TLM_FRAME_MAX   (TLM_REPLAY_MAX + TLM_OVERHEAD)

Definition at line 116 of file telemetry.h.

Function Documentation

◆ tlm_crc16()

uint16_t tlm_crc16 ( const uint8_t *  data,
size_t  len 
)

Definition at line 7 of file telemetry.c.

Referenced by frame_ready(), and tlm_encode().

Here is the caller graph for this function:

◆ tlm_encode()

size_t tlm_encode ( uint8_t  type,
const void *  payload,
uint8_t  len,
uint8_t *  out,
size_t  cap 
)

Writes the complete frame into out; returns its length, 0 if cap is too small.

Definition at line 18 of file telemetry.c.

References cap, tlm_crc16(), TLM_OVERHEAD, TLM_SYNC0, and TLM_SYNC1.

Referenced by pv2_frame(), send_status(), tlm_build_init(), tlm_build_replay(), and tlm_build_state().

Here is the call graph for this function:
Here is the caller graph for this function: