|
|
|
@ -65,6 +65,13 @@ Flow_Measure::Flow_Measure(void):
@@ -65,6 +65,13 @@ Flow_Measure::Flow_Measure(void):
|
|
|
|
|
*/ |
|
|
|
|
bool Flow_Measure::init(const AP_SerialManager& serial_manager) |
|
|
|
|
{ |
|
|
|
|
// protect against repeated call to init
|
|
|
|
|
if (_flow_wp != nullptr) { |
|
|
|
|
_flow_wp = nullptr; |
|
|
|
|
} |
|
|
|
|
// allocate arrays
|
|
|
|
|
_flow_wp = (Vector2f*)calloc(60, sizeof(Vector2f)); |
|
|
|
|
|
|
|
|
|
_uart = serial_manager.find_serial(AP_SerialManager::SerialProtocol_Flow_Measure,0); |
|
|
|
|
if (_uart != nullptr) { |
|
|
|
|
_uart->begin(9600U); |
|
|
|
@ -487,11 +494,9 @@ void Flow_Measure::my_endianswap(uint8_t * pData,uint8_t startIndex,uint8_t leng
@@ -487,11 +494,9 @@ void Flow_Measure::my_endianswap(uint8_t * pData,uint8_t startIndex,uint8_t leng
|
|
|
|
|
* @param alt 传入海拔高度 |
|
|
|
|
* @param time 测流历时 |
|
|
|
|
*/ |
|
|
|
|
void Flow_Measure::flow_auto_measure(bool start_sw,bool index_sw,int32_t alt,uint8_t time) |
|
|
|
|
void Flow_Measure::flow_auto_measure(bool start_sw,int32_t alt,uint8_t time) |
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static uint8_t manual_cnt = 0; // 手动测流计数
|
|
|
|
|
measure_time = time; |
|
|
|
|
// #if USE_SITL
|
|
|
|
|
|
|
|
|
@ -618,10 +623,7 @@ void Flow_Measure::flow_auto_measure(bool start_sw,bool index_sw,int32_t alt,uin
@@ -618,10 +623,7 @@ void Flow_Measure::flow_auto_measure(bool start_sw,bool index_sw,int32_t alt,uin
|
|
|
|
|
// send_cmd(GET_DATA);
|
|
|
|
|
if(get_radar_data()) |
|
|
|
|
{ |
|
|
|
|
if(index_sw){ |
|
|
|
|
manual_cnt++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(last_measure_sens != radar_sens){ |
|
|
|
|
flow_update_state = CHANGE_SENSITY; |
|
|
|
|
}else if(last_measure_time != measure_time){ |
|
|
|
@ -629,11 +631,9 @@ void Flow_Measure::flow_auto_measure(bool start_sw,bool index_sw,int32_t alt,uin
@@ -629,11 +631,9 @@ void Flow_Measure::flow_auto_measure(bool start_sw,bool index_sw,int32_t alt,uin
|
|
|
|
|
}else{ |
|
|
|
|
flow_update_state = GET_ANGLE; |
|
|
|
|
} |
|
|
|
|
if(!start_sw && !index_sw){ |
|
|
|
|
data_to_mp.index = auto_index; |
|
|
|
|
}else{ |
|
|
|
|
data_to_mp.index = manual_cnt; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
data_to_mp.index = auto_index; |
|
|
|
|
|
|
|
|
|
get_gps_alt(alt + delt_alt); |
|
|
|
|
if(radar_mode != 1){ // 非单测流雷达
|
|
|
|
|
data_package();
|
|
|
|
@ -651,16 +651,16 @@ void Flow_Measure::flow_auto_measure(bool start_sw,bool index_sw,int32_t alt,uin
@@ -651,16 +651,16 @@ void Flow_Measure::flow_auto_measure(bool start_sw,bool index_sw,int32_t alt,uin
|
|
|
|
|
|
|
|
|
|
is_data_flag = 1; |
|
|
|
|
if(radar_mode == 1){ // 单测流
|
|
|
|
|
if(manual_cnt == 1) |
|
|
|
|
if(data_to_mp.index == 1) |
|
|
|
|
gcs().send_text(MAV_SEVERITY_CRITICAL, "[格式] 序号, 历时, 角度, 流速, 数组"); |
|
|
|
|
gcs().send_text(MAV_SEVERITY_CRITICAL, "%2d, %2ds, %2.1f, %2.2f, 0x%02x%02x%02x%02x",get_wp_index(),measure_time,pitch.d/10.0,data_to_mp.flow_velocity/100.0, \
|
|
|
|
|
data_to_mp.radar_value[3],data_to_mp.radar_value[4],data_to_mp.radar_value[5],data_to_mp.radar_value[6]);
|
|
|
|
|
}else if(radar_mode == 2){ // 指定空高 单测流
|
|
|
|
|
if(manual_cnt == 1) |
|
|
|
|
if(data_to_mp.index == 1) |
|
|
|
|
gcs().send_text(MAV_SEVERITY_CRITICAL, "[格式]序号,历时,角度,水位,流速"); |
|
|
|
|
gcs().send_text(MAV_SEVERITY_CRITICAL, "[数据] %2d, %2ds, %2.1f, %4.2fm, %2.2fm/s",get_wp_index(),measure_time,pitch.d/10.0,alt/100.0,data_to_mp.flow_velocity/100.0); |
|
|
|
|
}else{ // 三合一
|
|
|
|
|
if(manual_cnt == 1) |
|
|
|
|
if(data_to_mp.index == 1) |
|
|
|
|
gcs().send_text(MAV_SEVERITY_CRITICAL, "[格式]序号,历时,角度,海拔,空高,流速"); |
|
|
|
|
gcs().send_text(MAV_SEVERITY_CRITICAL, "[数据] %2d, %2ds, %2.1f, %4.2fm, %2.2fm, %2.2fm/s",get_wp_index(),measure_time,pitch.d/10.0,alt/100.0,radar_alt/1000.0,data_to_mp.flow_velocity/100.0); |
|
|
|
|
|
|
|
|
@ -684,10 +684,6 @@ void Flow_Measure::flow_auto_measure(bool start_sw,bool index_sw,int32_t alt,uin
@@ -684,10 +684,6 @@ void Flow_Measure::flow_auto_measure(bool start_sw,bool index_sw,int32_t alt,uin
|
|
|
|
|
|
|
|
|
|
}else if(!get_reach_flow_wp() && !start_sw ){ |
|
|
|
|
flow_update_state = START_MEASURE; |
|
|
|
|
|
|
|
|
|
if(!index_sw){ |
|
|
|
|
manual_cnt = 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|