From 8bfd6404515edeefe38e792b5b668f2dcf1e8394 Mon Sep 17 00:00:00 2001 From: Andy Piper Date: Wed, 4 Sep 2024 11:01:56 +0100 Subject: [PATCH] AC_AttitudeControl: record sample time in attitude controller --- libraries/AC_AttitudeControl/AC_AttitudeControl.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libraries/AC_AttitudeControl/AC_AttitudeControl.h b/libraries/AC_AttitudeControl/AC_AttitudeControl.h index b3968282580d51..7427649225d285 100644 --- a/libraries/AC_AttitudeControl/AC_AttitudeControl.h +++ b/libraries/AC_AttitudeControl/AC_AttitudeControl.h @@ -73,9 +73,14 @@ class AC_AttitudeControl { // set_dt / get_dt - dt is the time since the last time the attitude controllers were updated // _dt should be set based on the time of the last IMU read used by these controllers + // sample_time_us is the time of the last IMU read used by these controllers // the attitude controller should run updates for active controllers on each loop to ensure normal operation - void set_dt(float dt) { _dt = dt; } + void set_dt(float dt, uint64_t sample_time_us) { + _dt = dt; + _sample_time_us = sample_time_us; + } float get_dt() const { return _dt; } + uint64_t get_sample_time_us() const { return _sample_time_us; } // pid accessors AC_P& get_angle_roll_p() { return _p_angle_roll; } @@ -489,6 +494,8 @@ class AC_AttitudeControl { // Intersampling period in seconds float _dt; + // scheduler sample time in microseconds (could be different to rate loop) + uint64_t _sample_time_us; // This represents a 321-intrinsic rotation in NED frame to the target (setpoint) // attitude used in the attitude controller, in radians.