|
|
|
@ -50,18 +50,27 @@ void Copter::userhook_MediumLoop()
@@ -50,18 +50,27 @@ void Copter::userhook_MediumLoop()
|
|
|
|
|
if(current_loc.alt > avoid.get_zr_avd_alt()) |
|
|
|
|
do_avoid_action(); |
|
|
|
|
#else |
|
|
|
|
|
|
|
|
|
if(avoid.get_zr_mode()>0 && in_debug_mode > 0){ |
|
|
|
|
bool just_alarm = false; |
|
|
|
|
if(current_loc.alt < avoid.get_zr_avd_alt()){ |
|
|
|
|
if(home_distance() < avoid.get_zr_avd_on_dist()){ |
|
|
|
|
just_alarm = true; |
|
|
|
|
bool flag_avoid_on = true; |
|
|
|
|
static bool last_avoid_flag = true; |
|
|
|
|
if(avoid.get_zr_mode() > 0 && (control_mode == Mode::Number::AUTO || control_mode == Mode::Number::RTL || control_mode == Mode::Number::GUIDED)){ |
|
|
|
|
|
|
|
|
|
if(current_loc.alt < avoid.get_zr_avd_alt()){ // 飞行高度小于避障启用高度
|
|
|
|
|
if(home_distance() < avoid.get_zr_avd_on_dist()){ // 距离Home点小于启用距离
|
|
|
|
|
flag_avoid_on = false; //关闭避障
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(!just_alarm){ |
|
|
|
|
if(flag_avoid_on){ |
|
|
|
|
do_avoid_action(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(last_avoid_flag != flag_avoid_on){ |
|
|
|
|
avoid.set_enable_aviod(flag_avoid_on); |
|
|
|
|
if(flag_avoid_on){ |
|
|
|
|
gcs().send_text(MAV_SEVERITY_INFO,"NOTICE: 避障开启!"); |
|
|
|
|
}else{ |
|
|
|
|
gcs().send_text(MAV_SEVERITY_INFO,"NOTICE: 避障关闭!"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|