Browse Source

Sub: add support for visual odometry

zr-v5.1
Randy Mackay 5 years ago
parent
commit
ac3f99d8dd
  1. 24
      ArduSub/system.cpp

24
ArduSub/system.cpp

@ -247,11 +247,24 @@ bool Sub::ekf_position_ok() @@ -247,11 +247,24 @@ bool Sub::ekf_position_ok()
// optflow_position_ok - returns true if optical flow based position estimate is ok
bool Sub::optflow_position_ok()
{
#if OPTFLOW != ENABLED
return false;
#else
// return immediately if optflow is not enabled or EKF not used
if (!optflow.enabled() || !ahrs.have_inertial_nav()) {
// return immediately if EKF not used
if (!ahrs.have_inertial_nav()) {
return false;
}
// return immediately if neither optflow nor visual odometry is enabled
bool enabled = false;
#if OPTFLOW == ENABLED
if (optflow.enabled()) {
enabled = true;
}
#endif
#if HAL_VISUALODOM_ENABLED
if (visual_odom.enabled()) {
enabled = true;
}
#endif
if (!enabled) {
return false;
}
@ -263,7 +276,6 @@ bool Sub::optflow_position_ok() @@ -263,7 +276,6 @@ bool Sub::optflow_position_ok()
return (filt_status.flags.pred_horiz_pos_rel);
}
return (filt_status.flags.horiz_pos_rel && !filt_status.flags.const_pos_mode);
#endif
}
/*

Loading…
Cancel
Save