|
|
|
@ -28,9 +28,11 @@ struct mr72_c{
@@ -28,9 +28,11 @@ struct mr72_c{
|
|
|
|
|
|
|
|
|
|
typedef struct dist_area_s |
|
|
|
|
{ |
|
|
|
|
uint32_t time_tick; |
|
|
|
|
uint16_t mid; |
|
|
|
|
uint16_t left; |
|
|
|
|
uint16_t right; |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
struct dist_area_s min_dist; |
|
|
|
@ -197,26 +199,29 @@ bool decode_mr72(int16_t c)
@@ -197,26 +199,29 @@ bool decode_mr72(int16_t c)
|
|
|
|
|
|
|
|
|
|
// if((last_range - mr72_c_data.range_f > 0.5) || (last_range - mr72_c_data.range_f < -0.5)){
|
|
|
|
|
|
|
|
|
|
// if(mr72_c_data.azimuth < -30.0){ // 左边区域
|
|
|
|
|
// if((abs(new_dist.left - mr72_c_data.range) > 10)){
|
|
|
|
|
// new_dist.left = mr72_c_data.range;
|
|
|
|
|
// }
|
|
|
|
|
// }else if(mr72_c_data.azimuth < 30.0){ // 中间区域
|
|
|
|
|
if(mr72_c_data.azimuth < -30.0){ // 左边区域
|
|
|
|
|
if((mr72_c_data.time_ms - new_dist.time_tick < 500)){ |
|
|
|
|
new_dist.left = mr72_c_data.range; |
|
|
|
|
new_dist.time_tick = mr72_c_data.time_ms; |
|
|
|
|
} |
|
|
|
|
}else if(mr72_c_data.azimuth < 30.0){ // 中间区域
|
|
|
|
|
if((mr72_c_data.time_ms - new_dist.time_tick < 500)){ |
|
|
|
|
new_dist.mid = mr72_c_data.range; |
|
|
|
|
new_dist.time_tick = mr72_c_data.time_ms; |
|
|
|
|
} |
|
|
|
|
}else{ // 右边区域
|
|
|
|
|
if((mr72_c_data.time_ms - new_dist.time_tick < 500)){ |
|
|
|
|
new_dist.right = mr72_c_data.range; |
|
|
|
|
new_dist.time_tick = mr72_c_data.time_ms; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// last_range = mr72_c_data.range_f;
|
|
|
|
|
// if(fabs(mr72_c_data.azimuth) < 30.0 ){ // 中间区域
|
|
|
|
|
// if((abs(new_dist.mid - mr72_c_data.range) > 10)){
|
|
|
|
|
// new_dist.mid = mr72_c_data.range;
|
|
|
|
|
// }
|
|
|
|
|
// }else{ // 右边区域
|
|
|
|
|
// if((abs(new_dist.right - mr72_c_data.range) > 10)){
|
|
|
|
|
// new_dist.right = mr72_c_data.range;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// last_range = mr72_c_data.range_f;
|
|
|
|
|
if(fabs(mr72_c_data.azimuth) < 30.0 ){ // 中间区域
|
|
|
|
|
if((abs(new_dist.mid - mr72_c_data.range) > 10)){ |
|
|
|
|
new_dist.mid = mr72_c_data.range; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
decode_state = 0; |
|
|
|
@ -231,42 +236,40 @@ bool decode_mr72(int16_t c)
@@ -231,42 +236,40 @@ bool decode_mr72(int16_t c)
|
|
|
|
|
|
|
|
|
|
void data_process(void){ |
|
|
|
|
// 其中一个区块数据更新
|
|
|
|
|
if (abs(new_dist.mid - last_dist.mid)>10 || abs(new_dist.left - last_dist.left)>10 || abs(new_dist.right - last_dist.right)>10) |
|
|
|
|
if (new_dist.time_tick - min_dist.time_tick < 500) |
|
|
|
|
{ |
|
|
|
|
// 更新最后的数据
|
|
|
|
|
last_dist.mid = new_dist.mid; |
|
|
|
|
last_dist.left = new_dist.left; |
|
|
|
|
last_dist.right = new_dist.right; |
|
|
|
|
min_dist.time_tick = new_dist.time_tick; |
|
|
|
|
|
|
|
|
|
if(min_dist.mid < 10){ // 如果最小值是0,则直接赋值
|
|
|
|
|
min_dist.mid = last_dist.mid; |
|
|
|
|
min_dist.mid = new_dist.mid; |
|
|
|
|
}else{ |
|
|
|
|
min_dist.mid = min_dist.mid < last_dist.mid?min_dist.mid : last_dist.mid; |
|
|
|
|
min_dist.mid = min_dist.mid < new_dist.mid?min_dist.mid : new_dist.mid; |
|
|
|
|
} |
|
|
|
|
if(min_dist.left < 10){ |
|
|
|
|
min_dist.left = last_dist.left; |
|
|
|
|
min_dist.left = new_dist.left; |
|
|
|
|
}else{ |
|
|
|
|
min_dist.left = min_dist.left < last_dist.left?min_dist.left : last_dist.left; |
|
|
|
|
min_dist.left = min_dist.left < new_dist.left?min_dist.left : new_dist.left; |
|
|
|
|
} |
|
|
|
|
if(min_dist.right < 10){ |
|
|
|
|
min_dist.right = last_dist.right; |
|
|
|
|
min_dist.right = new_dist.right; |
|
|
|
|
}else{ |
|
|
|
|
min_dist.right = min_dist.right < last_dist.right?min_dist.right : last_dist.right; |
|
|
|
|
min_dist.right = min_dist.right < new_dist.right?min_dist.right : new_dist.right; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
last_data_tick = HAL_GetTick(); |
|
|
|
|
}else{ |
|
|
|
|
if (HAL_GetTick() - last_data_tick > 500) // 数据0.5s没有更新,最小值赋值个大的值
|
|
|
|
|
{ |
|
|
|
|
min_dist.mid = 3900; |
|
|
|
|
min_dist.left = 3900; |
|
|
|
|
min_dist.right = 3900; |
|
|
|
|
min_dist.mid = 4500; |
|
|
|
|
min_dist.left = 4500; |
|
|
|
|
min_dist.right = 4500; |
|
|
|
|
last_data_tick = HAL_GetTick(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (proximity1_queueHandle != NULL && HAL_GetTick() - uavcan_data_tick > 50) // uavcan发送,50ms间隔
|
|
|
|
|
if (proximity1_queueHandle != NULL && HAL_GetTick() - uavcan_data_tick > 100) // uavcan发送,50ms间隔
|
|
|
|
|
{
|
|
|
|
|
proximity_t data; |
|
|
|
|
data.d0 = min_dist.mid; |
|
|
|
@ -279,6 +282,10 @@ void data_process(void){
@@ -279,6 +282,10 @@ void data_process(void){
|
|
|
|
|
data.d315 = 4500; |
|
|
|
|
myOsMessageQueuePut(proximity1_queueHandle, &data, 0, 10); |
|
|
|
|
uavcan_data_tick = HAL_GetTick(); |
|
|
|
|
min_dist.mid = 4500; |
|
|
|
|
min_dist.left = 4500; |
|
|
|
|
min_dist.right = 4500; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|