Tool/software:
Hi, I’m working on integrating a fall detection algorithm directly into the IWR6843AOP MSS project. I’ve reviewed the fall_detection.py
source code and translated it into the C implementation shown below. My queries are listed below:
1. Please review the code below and share your feedback?
2. Is there any other parameter from radar (like vertical velocity) is to be included with fault detection logic?
3. Is there any calibration required for every installation of device? or is it taken care in the configuration file itself?
#define FALL_THRESHOLD_PROPORTION 0.6f
#define FALL_HISTORY_SECONDS 2.5f
#define FRAME_PERIOD_MS 50
#define MAX_TRACKED_OBJECTS 64
#define HEIGHT_HISTORY_SIZE ((int)(FALL_HISTORY_SECONDS * 1000 / FRAME_PERIOD_MS))
typedef struct {
float heightHistory[HEIGHT_HISTORY_SIZE];
uint16_t historyIndex;
bool fallDetected;
} TrackerFallInfo;
TrackerFallInfo* runFallDetection(Pcount3DDemo_MSS_MCB* gMmwMssMCB)
{
trackerProc_TargetDescrHandle* targetDescr = &gMmwMssMCB->trackerOutput;
bool current = targetDescr->currentDescr;
trackerProc_Target* tList = targetDescr->tList[current];
trackerProc_TargetIndex* tIndex = targetDescr->tIndex[current];
for (uint8_t i = 0; i < gMmwMssMCB->numTargets; i++) {
uint8_t idx = tIndex[i];
trackerProc_Target* t = &tList[idx];
uint32_t id = t->tid;
if (id >= MAX_TRACKED_OBJECTS)
continue;
TrackerFallInfo* info = &trackerFallInfos[id];
float* buffer = info->heightHistory;
uint16_t hidx = info->historyIndex;
float currentHeight = t->posZ;
//float velocityZ = t->velZ;
buffer[hidx] = currentHeight;
info->historyIndex = (hidx + 1) % HEIGHT_HISTORY_SIZE;
float oldestHeight = buffer[info->historyIndex];
bool suddenDrop = (oldestHeight > 0.0f) &&
(currentHeight < (FALL_THRESHOLD_PROPORTION * oldestHeight));
info->fallDetected = suddenDrop;
}
return trackerFallInfos;
}