1. Algorithm description
NeuraSafe (Man Down) library allows to track man down alert events within different activities performed by the used. NeuraSafe is an IMU-based solution that exploits only linear accelerations and angular velocity readings, measured in mg and dps respectively, and sampled @50Hz. NeuraSafe requires a single inertial sensor, that has to be installed on the user chest. Other placements such as user belt, upper arm and shoulder have been tested with good results but chest positioning is suggested to maximize algorithm performances.
Library configuration can be done with the following operations:
-
MAD_ResetParameters has to be called during initialization of the library to reset all the alogrithm parameters
at pre-defined and documented values; -
MAD_SetParameters can be called in order to modify algorithm parameters: run this command at user’s own
risk; - MAD_GetParameters can be called in order to get parameter values.
-
MAD_Set_Device_Position can be called in order to set device orientation axis.
- Option 1: if MAD_Set_Device_Position is called, approximative device axis direction can be set, following
AxisDirection. Man down logic will be armed by the first sample. - Option 2: if MAD_Set_Device_Position is not called, the first minute is spent to detect device
orientation: therefore it is mandatory wear the device before running the library and suggested to adopt
an upright position, varying the inclination of the luminaire as little as possible. In this case, during this
period the whole man down logic is disabled. For better results, this second option is suggested.
- Option 1: if MAD_Set_Device_Position is called, approximative device axis direction can be set, following
MAD integration requires only 4 lines of code, which implement the following functionalities:
-
MAD_Init. It must be invoked before running the logic. It allows to set all the configuration parameters and
internal variables. This funtion has to be called also at higher level, when a man down event has been
detected and the detection has to start again. In fact, when a man down event is detected by the algorithm,
the algorithm is stuck at the MAD_ALERT_CHARLIE alert condition untill a MAD_Init is called. -
MAD_Update. It runs the core functions of the logic, as depicted in the AlgorithmFlowchart, necessary to
track a man down event. - MAD_Get_Arming_Status. It returns the current man down arming status.
- MAD_Get_Alert_Level. It returns the current man down alarm value.
- MAD_Lying_Down. It returns if the current user position is standing or lying.
2. Flowchart
The following block diagram describes the flow of operations that implement the NeuraSafe logic.
Figure 2.1 Block diagram showing the algorithm functioning.
3. References
The following lines contain general information about the library, such as version and date of publication, together with the contact details of the 221e internal staff responsible for maintaining and managing the library.
-
Authors and Referents
Giorgio Barzon
Luigi Mattiello
Roberto Bortoletto -
Library Version
v1.0.0 -
Date
July 2022 -
Copyright
Copyright (c) 2020 All Rights Reserved by 221e srl. [email protected]
4. Requirements
The following lines contain information about the library size occupation and time execution. Tests and measurements have been perfomed with a NUCLEO-L476RG board, clocked @64MHz, and including within Atollic TrueSTUDIO project the NeuraSafe static library compiled for NUCLEO-L476RG as well as library header files. Results are reported in the following tables.
FLASH Occupation [kB] | RAM Occupation [kB] |
---|---|
42.1 | 4.50 |
TABLE 4.1 NEURASAFE MEMORY OCCUPATION
Timing [clock hits] | Timing @64MHz [ms] | |
---|---|---|
MAD_Update + MAD_Get_Alert_Level |
Average: 18202, Maximum: 22644 | Average: 0.284, Maximum: 0.354 |
MAD_Lying_Down | Average: 2780, Maximum: 3075 | Average: 0.043, Maximum: 0.048 |
MAD_Init |
Average: 12140, Maximum: 12199 | Average: 0.190, Maximum: 0.191 |
MAD_Set_Device_Position | Average: 205, Maximum: 279 | Average: 0.003, Maximum: 0.004 |
TABLE 4.2 NEURASAFE EXECUTION TIMINGS
5. Example Documentation
8.1 MAD_Example.c
This is an example of library usage for NeuraSafe logic with accelerometer and gyroscope data. The data were acquired with the 221e Muse device, installed on the user’s chest, at heart height. The test was performed wearing the sensor all day while the following activities have been done: walking, running, sitting and standing. Within the acquisition different man down events were simulated on a mattress. Results of the logic was saved to file. In the followingExampleFigure one of detected MAD_ALERT_CHARLIE event is depicted. The following lines show how the library was executed on the collected data.
FIGURE 8.1 OUTPUT EXAMPLE
#include<stdio.h> // Include C standard libraries #include <math.h> #include "MAD_Tracker.h" // Include MAD_Tracker.h library #define inputDataLength 6 // Define input data length float inputData[inputDataLength] = {0,0,0,0,0,0}; // Initialize input data array MAD_ALERT_LEVEL MAD_LEVEL_output; // Define output bool user_is_down = false; // Initialize user down boolean variable bool set_device_orientation = true; // boolean to manage automatic device orientaton detection AxisDirection DeviceAxis[3]; // Define Device Axis array int main(void) { uint8_t i; // Support variable FILE *fIn = fopen("input_file.txt", "r"); // Open input file FILE *fOut = fopen("output_file.txt", "w"); // Open output file MAD_ResetParameters(); // Initialize algorithm parameters if (set_device_orientation){ DeviceAxis[0] = Down; // X axis direction DeviceAxis[1] = Lateral; // Y axis direction DeviceAxis[2] = Forward; // Z axis direction MAD_Set_Device_Position(DeviceAxis); // Set device axis orientation } MAD_Init(); // MAD_Init call // Main loop while (feof(fIn) == 0) { // Read current data for (i = 0; i < inputDataLength; i++) fscanf(fIn, "%f", &inputData[i]); // Read data: Gyr.X Gyr.Y Gyr.Z Acc.X Acc.Y Acc.Z float inGyr[3] = { inputData[0], inputData[1], inputData[2] }; float inAxl[3] = { inputData[3], inputData[4], inputData[5] }; MAD_Update(inGyr,inAxl); // MAD_Update call bool MAD_is_Armed = MAD_Get_Arming_Status(); // Get MAD arming status MAD_LEVEL_output = MAD_Get_Alert_Level(); // MAD_Get_Alert_Level call user_is_down = MAD_Lying_Down(); // MAD_Lying_Down call fprintf(fOut,"%dnt%dnt%dnn", MAD_LEVEL_output,user_is_down);// Print output on file } // Close I/O files fclose(fIn); fclose(fOut); return 0; }