From dbc9b0c2f9aa43ffa93964406761968323905107 Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Wed, 9 Jun 2021 13:07:02 +0900 Subject: [PATCH] AC_Loiter: init brake_accel and fix brake timer type --- libraries/AC_WPNav/AC_Loiter.cpp | 2 ++ libraries/AC_WPNav/AC_Loiter.h | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/AC_WPNav/AC_Loiter.cpp b/libraries/AC_WPNav/AC_Loiter.cpp index 7a8c8b22bc..b05c229642 100644 --- a/libraries/AC_WPNav/AC_Loiter.cpp +++ b/libraries/AC_WPNav/AC_Loiter.cpp @@ -99,6 +99,7 @@ void AC_Loiter::init_target(const Vector3f& position) _predicted_accel.zero(); _desired_accel.zero(); _predicted_euler_angle.zero(); + _brake_accel = 0.0f; // set target position _pos_control.set_pos_target_xy_cm(position.x, position.y); @@ -121,6 +122,7 @@ void AC_Loiter::init_target() _predicted_accel.y = _pos_control.get_accel_target_cmss().y; _predicted_euler_angle.x = radians(_pos_control.get_roll_cd()*0.01f); _predicted_euler_angle.y = radians(_pos_control.get_pitch_cd()*0.01f); + _brake_accel = 0.0f; } /// reduce response for landing diff --git a/libraries/AC_WPNav/AC_Loiter.h b/libraries/AC_WPNav/AC_Loiter.h index e256047673..5d5861d58d 100644 --- a/libraries/AC_WPNav/AC_Loiter.h +++ b/libraries/AC_WPNav/AC_Loiter.h @@ -85,6 +85,6 @@ protected: Vector2f _predicted_accel; Vector2f _predicted_euler_angle; Vector2f _predicted_euler_rate; - float _brake_timer; - float _brake_accel; + uint32_t _brake_timer; // system time that brake was initiated + float _brake_accel; // acceleration due to braking from previous iteration (used for jerk limiting) };