|
|
|
@ -460,19 +460,19 @@ void AC_PosControl::init_takeoff()
@@ -460,19 +460,19 @@ void AC_PosControl::init_takeoff()
|
|
|
|
|
// is_active_z - returns true if the z-axis position controller has been run very recently
|
|
|
|
|
bool AC_PosControl::is_active_z() const |
|
|
|
|
{ |
|
|
|
|
return ((AP_HAL::millis() - _last_update_z_ms) <= POSCONTROL_ACTIVE_TIMEOUT_MS); |
|
|
|
|
return ((AP_HAL::micros64() - _last_update_z_us) <= POSCONTROL_ACTIVE_TIMEOUT_US); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// update_z_controller - fly to altitude in cm above home
|
|
|
|
|
void AC_PosControl::update_z_controller() |
|
|
|
|
{ |
|
|
|
|
// check time since last cast
|
|
|
|
|
uint32_t now = AP_HAL::millis(); |
|
|
|
|
if (now - _last_update_z_ms > POSCONTROL_ACTIVE_TIMEOUT_MS) { |
|
|
|
|
uint64_t now_us = AP_HAL::micros64(); |
|
|
|
|
if (now_us - _last_update_z_us > POSCONTROL_ACTIVE_TIMEOUT_US) { |
|
|
|
|
_flags.reset_rate_to_accel_z = true; |
|
|
|
|
_flags.reset_accel_to_throttle = true; |
|
|
|
|
} |
|
|
|
|
_last_update_z_ms = now; |
|
|
|
|
_last_update_z_us = now_us; |
|
|
|
|
|
|
|
|
|
// check for ekf altitude reset
|
|
|
|
|
check_for_ekf_z_reset(); |
|
|
|
@ -756,7 +756,7 @@ int32_t AC_PosControl::get_bearing_to_target() const
@@ -756,7 +756,7 @@ int32_t AC_PosControl::get_bearing_to_target() const
|
|
|
|
|
// is_active_xy - returns true if the xy position controller has been run very recently
|
|
|
|
|
bool AC_PosControl::is_active_xy() const |
|
|
|
|
{ |
|
|
|
|
return ((AP_HAL::millis() - _last_update_xy_ms) <= POSCONTROL_ACTIVE_TIMEOUT_MS); |
|
|
|
|
return ((AP_HAL::micros64() - _last_update_xy_us) <= POSCONTROL_ACTIVE_TIMEOUT_US); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// get_lean_angle_max_cd - returns the maximum lean angle the autopilot may request
|
|
|
|
@ -797,11 +797,11 @@ void AC_PosControl::init_xy_controller()
@@ -797,11 +797,11 @@ void AC_PosControl::init_xy_controller()
|
|
|
|
|
void AC_PosControl::update_xy_controller() |
|
|
|
|
{ |
|
|
|
|
// compute dt
|
|
|
|
|
uint32_t now = AP_HAL::millis(); |
|
|
|
|
float dt = (now - _last_update_xy_ms)*0.001f; |
|
|
|
|
uint64_t now_us = AP_HAL::micros64(); |
|
|
|
|
float dt = (now_us - _last_update_xy_us) * 1.0e-6f; |
|
|
|
|
|
|
|
|
|
// sanity check dt
|
|
|
|
|
if (dt >= POSCONTROL_ACTIVE_TIMEOUT_MS*1.0e-3f) { |
|
|
|
|
if (dt >= POSCONTROL_ACTIVE_TIMEOUT_US * 1.0e-6f) { |
|
|
|
|
dt = 0.0f; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -818,13 +818,13 @@ void AC_PosControl::update_xy_controller()
@@ -818,13 +818,13 @@ void AC_PosControl::update_xy_controller()
|
|
|
|
|
run_xy_controller(dt); |
|
|
|
|
|
|
|
|
|
// update xy update time
|
|
|
|
|
_last_update_xy_ms = now; |
|
|
|
|
_last_update_xy_us = now_us; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
float AC_PosControl::time_since_last_xy_update() const |
|
|
|
|
{ |
|
|
|
|
uint32_t now = AP_HAL::millis(); |
|
|
|
|
return (now - _last_update_xy_ms)*0.001f; |
|
|
|
|
uint64_t now_us = AP_HAL::micros64(); |
|
|
|
|
return (now_us - _last_update_xy_us) * 1.0e-6f; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// write log to dataflash
|
|
|
|
@ -894,8 +894,8 @@ void AC_PosControl::init_vel_controller_xyz()
@@ -894,8 +894,8 @@ void AC_PosControl::init_vel_controller_xyz()
|
|
|
|
|
void AC_PosControl::update_vel_controller_xy() |
|
|
|
|
{ |
|
|
|
|
// capture time since last iteration
|
|
|
|
|
uint32_t now = AP_HAL::millis(); |
|
|
|
|
float dt = (now - _last_update_xy_ms)*0.001f; |
|
|
|
|
uint64_t now_us = AP_HAL::micros64(); |
|
|
|
|
float dt = (now_us - _last_update_xy_us) * 1.0e-6f; |
|
|
|
|
|
|
|
|
|
// sanity check dt
|
|
|
|
|
if (dt >= 0.2f) { |
|
|
|
@ -916,7 +916,7 @@ void AC_PosControl::update_vel_controller_xy()
@@ -916,7 +916,7 @@ void AC_PosControl::update_vel_controller_xy()
|
|
|
|
|
run_xy_controller(dt); |
|
|
|
|
|
|
|
|
|
// update xy update time
|
|
|
|
|
_last_update_xy_ms = now; |
|
|
|
|
_last_update_xy_us = now_us; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|