Integrator: use 32bit integer to store dt to avoid overflow

Signed-off-by: RomanBapst <bapstroman@gmail.com>
This commit is contained in:
RomanBapst
2025-01-09 20:33:42 +03:00
committed by Roman Bapst
parent af062c85eb
commit 25e76883b7
+3 -3
View File
@@ -55,7 +55,7 @@ public:
~Integrator() = default;
static constexpr float DT_MIN{1e-6f}; // 1 microsecond
static constexpr float DT_MAX{static_cast<float>(UINT16_MAX) * 1e-6f};
static constexpr float DT_MAX{static_cast<float>(UINT32_MAX) * 1e-6f};
/**
* Put an item into the integral.
@@ -111,7 +111,7 @@ public:
* @param integral_dt Get the dt in us of the current integration.
* @return true if integral valid
*/
bool reset(matrix::Vector3f &integral, uint16_t &integral_dt)
bool reset(matrix::Vector3f &integral, uint32_t &integral_dt)
{
if (integral_ready()) {
integral = _alpha;
@@ -200,7 +200,7 @@ public:
* @param integral_dt Get the dt in us of the current integration.
* @return true if integral valid
*/
bool reset(matrix::Vector3f &integral, uint16_t &integral_dt)
bool reset(matrix::Vector3f &integral, uint32_t &integral_dt)
{
if (Integrator::reset(integral, integral_dt)) {
// apply coning corrections