Loading files
d497d8f64This file is pinned to the selected release. Download the original to open it in your design tool.
// Copyright 2026 Filip Dymczyk and Konrad Grucel
#pragma once
#include <stdint.h>
class Model_Identification
{
static constexpr uint8_t MAX_INPUT_DATA_SAMPLES = 10u;
public:
struct Identification_Data
{
float dt {};
float pwm {};
float angle {};
float angle_dt {};
float position {};
float position_dt {};
};
static Model_Identification&
instance()
{
static Model_Identification s_model_identification {};
return s_model_identification;
}
void
update(float dt);
void
activate_identification();
bool
identification_active();
void
acknowledge_identification_stop();
float
get_pwm_sample();
bool
set_identification_profile(uint8_t const* payload, uint16_t payload_length);
void
set_current_dt(float dt);
Identification_Data const&
get_identification_data() const;
private:
Model_Identification() = default;
Model_Identification(Model_Identification const&) = delete;
Model_Identification&
operator=(Model_Identification const&) = delete;
struct Input_Data
{
float pwm_values[MAX_INPUT_DATA_SAMPLES];
float pwm_durations_s[MAX_INPUT_DATA_SAMPLES];
};
Input_Data m_input_data {};
bool m_identification_active = false;
uint32_t m_current_pwm_sample = 0u;
float m_pwm_timer = 0.0f;
};