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

          Line data    Source code
       1             : /*
       2             :    This program is free software: you can redistribute it and/or modify
       3             :    it under the terms of the GNU General Public License as published by
       4             :    the Free Software Foundation, either version 3 of the License, or
       5             :    (at your option) any later version.
       6             : 
       7             :    This program is distributed in the hope that it will be useful,
       8             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
       9             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      10             :    GNU General Public License for more details.
      11             : 
      12             :    You should have received a copy of the GNU General Public License
      13             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      14             :  */
      15             : /*
      16             :   simple sprayer simulation class
      17             : */
      18             : 
      19             : #pragma once
      20             : 
      21             : #include "stdint.h"
      22             : #include <AP_Param/AP_Param.h>
      23             : #include "SITL_Input.h"
      24             : 
      25             : namespace SITL {
      26             : 
      27             : class Sprayer {
      28             : public:
      29        2096 :     Sprayer() {
      30        2096 :         AP_Param::setup_object_defaults(this, var_info);
      31        2096 :     };
      32             : 
      33             :     // update sprayer state
      34             :     void update(const struct sitl_input &input);
      35             : 
      36      271619 :     float payload_mass() const { return static_cast<float>(capacity); }; // kg; water, so kg=l
      37             : 
      38             :     static const struct AP_Param::GroupInfo var_info[];
      39   178759942 :     bool is_enabled() const {return static_cast<bool>(sprayer_enable);}
      40             : 
      41             :  private:
      42             : 
      43             :     AP_Int8  sprayer_enable;  // enable sprayer sim
      44             :     AP_Int8  sprayer_pump_pin;
      45             :     AP_Int8  sprayer_spin_pin;
      46             : 
      47             :     const uint32_t report_interval = 1000000; // microseconds
      48             :     uint64_t last_report_us;
      49             : 
      50             :     const float pump_max_rate = 0.01f; // litres/second
      51             :     const float pump_slew_rate = 20.0f; // percent/second
      52             :     float last_pump_output; // percentage
      53             : 
      54             :     const float spinner_max_rate = 3600.0f; // degrees/second
      55             :     const float spinner_slew_rate = 20.0f; // percent/second
      56             :     float last_spinner_output; // percentage
      57             : 
      58             :     double capacity = 0.25; // litres
      59             : 
      60             :     uint64_t last_update_us;
      61             : 
      62             :     bool should_report();
      63             :     bool zero_report_done = false;
      64             : };
      65             : 
      66             : }

Generated by: LCOV version 1.14