LCOV - code coverage report
Current view: top level - AP_Motors - AP_Motors_Thrust_Linearization.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 5 5 100.0 %
Date: 2026-09-09 11:02:08 Functions: 5 5 100.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <AP_Param/AP_Param.h>
       4             : #include <Filter/LowPassFilter.h>
       5             : 
       6             : class AP_Motors;
       7             : class Thrust_Linearization {
       8             : friend class AP_MotorsMulticopter;
       9             : friend class AP_MotorsMulticopter_test;
      10             : friend class AP_MotorsHeli_Single;
      11             : public:
      12             :     Thrust_Linearization(AP_Motors& _motors);
      13             : 
      14             :     // Apply_thrust_curve_and_volt_scaling - returns throttle in the range 0 ~ 1
      15             :     float apply_thrust_curve_and_volt_scaling(float thrust) const;
      16             : 
      17             :     // Inverse of above
      18             :     float remove_thrust_curve_and_volt_scaling(float throttle) const;
      19             : 
      20             :     // Converts desired thrust to linearized actuator output in a range of 0~1
      21             :     float thrust_to_actuator(float thrust_in) const;
      22             : 
      23             :     // Inverse of above
      24             :     float actuator_to_thrust(float actuator) const;
      25             : 
      26             :     // Update_lift_max_from_batt_voltage - used for voltage compensation
      27             :     void update_lift_max_from_batt_voltage();
      28             : 
      29             :     // return gain scheduling gain based on voltage and air density
      30             :     float get_compensation_gain() const;
      31             : 
      32             :     // Get spin min parameter value
      33     1945777 :     float get_spin_min() const { return spin_min.get(); }
      34             : 
      35             :     // Get spin max parameter value
      36      175099 :     float get_spin_max() const { return spin_max.get(); }
      37             : 
      38             :     // Get spin max parameter value
      39    19631709 :     int8_t get_battery_index() const { return batt_idx.get(); }
      40             : 
      41             :     // Get min battery voltage
      42       92945 :     float get_battery_min_voltage() const { return batt_voltage_min.get(); }
      43             : 
      44             :     // Get lift max
      45   135837927 :     float get_lift_max() const { return lift_max; }
      46             : 
      47             :     // var_info for holding Parameter information
      48             :     static const struct AP_Param::GroupInfo var_info[];
      49             : 
      50             : protected:
      51             :     AP_Float curve_expo;       // curve used to linearize pwm to thrust conversion.  set to 0 for linear and 1 for second order approximation
      52             :     AP_Float spin_min;         // throttle out ratio which produces the minimum thrust.  (i.e. 0 ~ 1 ) of the full throttle range
      53             :     AP_Float spin_max;         // throttle out ratio which produces the maximum thrust.  (i.e. 0 ~ 1 ) of the full throttle range
      54             :     AP_Int8  batt_idx;         // battery index used for compensation
      55             :     AP_Float batt_voltage_max; // maximum voltage used to scale lift
      56             :     AP_Float batt_voltage_min; // minimum voltage used to scale lift
      57             : 
      58             : private:
      59             :     float               lift_max;          // maximum lift ratio from battery voltage
      60             :     float               throttle_limit;    // ratio of throttle limit between hover and maximum
      61             :     LowPassFilterFloat  batt_voltage_filt; // filtered battery voltage expressed as a percentage (0 ~ 1.0) of batt_voltage_max
      62             : 
      63             :     AP_Motors& motors;
      64             : };

Generated by: LCOV version 1.14