--- revised for slow and fast tracking ----

This commit is contained in:
Yunhorn 2024-08-20 11:30:55 +08:00
parent 1532f4a1f4
commit 029c3fcda3
3 changed files with 35 additions and 32 deletions

View File

@ -56,7 +56,8 @@
// SPARK FUN EXAMPLE
// GOOD --- volatile distance_measure_cfg_t distance_cfg={0.4, 3.5, 4, 63, 0, 10, 0.5, 1.3, 0.2};
// 2024-08-15 volatile distance_measure_cfg_t distance_cfg={0.8, 3.5, 2, 63, 2, 10, 0.5, 1.3, 0.2};
volatile distance_measure_cfg_t distance_cfg={0.8, 3.5, 4, 63, 2, 10, 0.5, 1.3, 0.2};
//volatile distance_measure_cfg_t distance_cfg={0.8, 3.5, 4, 63, 2, 10, 0.5, 1.3, 0.2};
volatile distance_measure_cfg_t distance_cfg={0.8, 3.5, 4, 63, 2, 10, 0.4, 1.2, 0.2};
//volatile distance_measure_cfg_t distance_cfg={1.5, 3.3, 2, 63, 4, 10, 0.8182f, 0.4, 0.2};
extern volatile uint16_t sts_distance_rss_distance, sts_sensor_install_height;
@ -113,7 +114,7 @@ int sts_distance_rss_detector_distance(void)
bool success = true;
const int iterations = 5; //5;
uint16_t number_of_peaks = 1;
uint16_t number_of_peaks = 1; // FSB first significant Bin
acc_detector_distance_result_t result[number_of_peaks];
acc_detector_distance_result_info_t result_info;
float tmp_distance = 0.0f;
@ -128,17 +129,15 @@ int sts_distance_rss_detector_distance(void)
break;
}
for(uint8_t j=0; j< result_info.number_of_peaks; j++)
tmp_distance += result[j].distance_m; //KalmanFilter(result[j].distance_m);
tmp_distance = tmp_distance + (result[j].distance_m); //KalmanFilter(result[j].distance_m);
print_distances(result, result_info.number_of_peaks);
}
sts_distance_rss_distance = (uint16_t)(1000*(tmp_distance/result_info.number_of_peaks)/iterations);
APP_LOG(TS_OFF, VLEVEL_M, "\r\nAverage Distance= %u mm\r\n", (uint16_t)sts_distance_rss_distance);
sts_distance_rss_distance = (uint16_t)(1000*tmp_distance)/(number_of_peaks*iterations);
// ensure it's a valid installation height
//sts_sensor_install_height = (uint16_t)MAX(sts_distance_rss_distance,2000);
sts_sensor_install_height = (uint16_t)sts_distance_rss_distance;
APP_LOG(TS_OFF, VLEVEL_M, "\r\nAssume Sensor Install Height = %u mm\r\n", (uint16_t)sts_sensor_install_height);
APP_LOG(TS_OFF, VLEVEL_M, "\r\nAverage Distance =%u mm --- Assume Sensor Install Height = %u mm\r\n", (uint16_t)sts_distance_rss_distance, (uint16_t)sts_sensor_install_height);
bool deactivated = acc_detector_distance_deactivate(distance_handle);

View File

@ -58,7 +58,7 @@
#define DEFAULT_SENSOR_ID (1)
#define DEFAULT_START_M (0.8f) //(0.80f) //default 0.2 unit(meter) [1]
#define DEFAULT_LENGTH_M (2.5f) // (2.0f)) //default 1.0 unit(meter) [2]
#define DEFAULT_LENGTH_M (3.5f) // (2.0f)) //default 1.0 unit(meter) [2]
#define DEFAULT_ZONE_LENGTH (0.4f) //default 0.4 unit(meter)
#define DEFAULT_UPDATE_RATE_WAKEUP (2.0f) //default 80 unit(hz)
#define DEFAULT_UPDATE_RATE_TRACKING (10.0f) //default 80 unit(hz) [7]
@ -67,14 +67,14 @@
//#define DEFAULT_UPDATE_RATE_PRESENCE (80.0F) //(65.0f) //default 80 unit(hz)
#define DEFAULT_HWAAS (63) //default 10 unit(hz)
#define DEFAULT_THRESHOLD (1.2f) //default 1.5 level float [3]
#define DEFAULT_THRESHOLD (1.5f) //default 1.5 level float [3]
//acc_detector_presence_configuration_filter_parameters_t
#define DEFAULT_INTER_FRAME_DEVIATION_TIME_CONST (0.5f) //default 0.5 unit(seconds) [6]
#define DEFAULT_INTER_FRAME_FAST_CUTOFF (10.0f) //default 20.0 unit(hz) [8]
#define DEFAULT_INTER_FRAME_SLOW_CUTOFF (0.01f) //(0.01f) 0.2 hz unit(hz) [9]
#define DEFAULT_INTRA_FRAME_TIME_CONST (0) //default 0.0 unit(seconds)
#define DEFAULT_INTRA_FRAME_WEIGHT (0) //default 0.6
#define DEFAULT_INTRA_FRAME_WEIGHT (0) //default 0.6 for normal slow tracking 1.0 for fast tracking
#define DEFAULT_OUTPUT_TIME_CONST (0.5f) //default 0.5 unit(seconds) [5]
//#define DEFAULT_OUTPUT_TIME_CONST (0.4f) //default 0.5 unit(seconds) [5]
@ -517,7 +517,7 @@ int sts_presence_rss_fall_rise_detection(void)
{
//APP_LOG(TS_OFF, VLEVEL_H,"\n%u ", i);
//print_result(result);
if (result.presence_detected)
if ((result.presence_detected) && (result.presence_score > DEFAULT_THRESHOLD))
{
//print_result(result);
average_result++;
@ -533,7 +533,8 @@ int sts_presence_rss_fall_rise_detection(void)
//if (detected_hs_zone == 0)
//APP_LOG(TS_OFF, VLEVEL_L, "\r\nPresence_Distance=%u \r\n", (int)result.presence_distance*1000.0);
//APP_LOG(TS_OFF, VLEVEL_L, "\r\nHS_ZONE=%u", detected_hs_zone);
detected_hs_zone = 10 - detected_zone;
//(sts_sensor_install_height/1000)/(DEFAULT_ZONE_LENGTH)
detected_hs_zone = (sts_sensor_install_height/1000)/(DEFAULT_ZONE_LENGTH) - detected_zone;
motion_in_hs_zone[detected_hs_zone][(motion_detected_count)]++;
sts_motion_dataset[motion_count].presence_distance = 1000*result.presence_distance;
@ -575,7 +576,7 @@ int sts_presence_rss_fall_rise_detection(void)
sts_presence_rss_distance = average_distance;
sts_presence_rss_score = average_score;
sts_rss_result = (average_result > (DEFAULT_UPDATE_RATE_PRESENCE/2))? 1: 0;
sts_rss_result = (average_result > (DEFAULT_UPDATE_RATE_PRESENCE/5))? 1: 0;
//if (average_result) //if (average_score !=0) //if (sts_rss_result)
{
@ -619,6 +620,8 @@ int sts_presence_rss_fall_rise_detection(void)
}
//#ifdef LOG_RSS
if (sts_work_mode == STS_UNI_MODE)
{
APP_LOG(TS_OFF, VLEVEL_M,"\r\nSensor at Ceiling Height: %u cm\r\n",(uint16_t)sts_sensor_install_height/10);
APP_LOG(TS_OFF, VLEVEL_M,"\r\n|Motion Distance Zone| ##### |Height cm|\r\n");
uint8_t kk = (uint8_t)((uint16_t)(sts_sensor_install_height/1000)/(DEFAULT_ZONE_LENGTH));
@ -634,6 +637,7 @@ int sts_presence_rss_fall_rise_detection(void)
}
}
APP_LOG(TS_OFF, VLEVEL_M,"\r\n|-----------Floor Ground-----------^-----|\r\n");
}
//#endif

View File

@ -112,8 +112,8 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = {
0x05, //inter frame deviation time const 0x05=[5]*0.1=0.5f
0x0A, //inter frame fast cutoff 0x0A=[10] = 10U
0x01, //inter frame slow cutoff,0x01=1[1]*0.01=0.01f
0x00, //intra frame time const [0]=0
0x00, //intra frame weight, 0x00=[0]*0.1=0.0F
0x00, //intra frame time const [0]=0 Lower to reduce sensitivity, higher to increase sensitivity
0x0A, //intra frame weight, 0x00=[0]*0.1=0.0F 0x0A=10, 10*0.1=1 FOR FAST MOVEMENT TRACKING FALL DETECTION
0x05, //output time const 0x05=[5]*0.1=0.5
0x02, //downsampling factor [2]=2
0x03, //power saving mode ACTIVE [3] = 3U
@ -2377,7 +2377,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, uint8_t tlv_buf_size)
UTIL_MEM_set_8((void*)outbuf, 0x0, sizeof(outbuf));
UTIL_MEM_cpy_8((void*)outbuf,(void*)tlv_buf, tlv_buf_size);
i = tlv_buf_size;
APP_LOG(TS_OFF, VLEVEL_L, "###### Fall detection CFG = %s\r\n",(char*)outbuf);
APP_LOG(TS_OFF, VLEVEL_M, "###### Fall detection CFG = %s\r\n",(char*)outbuf);
STS_Combined_Status_Processing();
}
@ -2406,7 +2406,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, uint8_t tlv_buf_size)
UTIL_MEM_set_8((void*)outbuf, 0x0, sizeof(outbuf));
UTIL_MEM_cpy_8((void*)outbuf,(void*)tlv_buf, tlv_buf_size);
i = tlv_buf_size;
APP_LOG(TS_OFF, VLEVEL_L, "###### Occupancy/Overstay/unconscious config changed =%s\r\n",(char *)outbuf);
APP_LOG(TS_OFF, VLEVEL_M, "###### Occupancy/Overstay/unconscious config changed =%s\r\n",(char *)outbuf);
STS_Combined_Status_Processing();
}
}