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

          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 Gripper (EPM) 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 Gripper_EPM {
      28             : public:
      29        2096 :     Gripper_EPM() {
      30        2096 :         AP_Param::setup_object_defaults(this, var_info);
      31        2096 :     };
      32             : 
      33           0 :     float payload_mass() const { return 0.0f; } // kg
      34             : 
      35             :     // update field stength
      36             :     void update(const struct sitl_input &input);
      37             : 
      38             :     static const struct AP_Param::GroupInfo var_info[];
      39   178759942 :     bool is_enabled() const {return static_cast<bool>(gripper_emp_enable);}
      40             : 
      41             : private:
      42             : 
      43             :     AP_Int8  gripper_emp_enable;  // enable gripper sim
      44             :     AP_Int8  gripper_emp_servo_pin;
      45             : 
      46             :     const uint32_t report_interval = 100000; // microseconds
      47             :     uint64_t last_report_us;
      48             : 
      49             :     bool servo_based = true;
      50             : 
      51             :     float field_strength;   // percentage
      52             :     float reported_field_strength = -1; // unlikely
      53             : 
      54             :     // I've a feeling these are probably a higher order than this:
      55             :     const float field_strength_slew_rate = 400; // (percentage of delta between field strength and 100)/second
      56             :     const float field_decay_rate = 2; // percent of field strength/second
      57             :     const float field_degauss_rate = 300; // percent of field strength/second
      58             : 
      59             :     uint64_t last_update_us;
      60             : 
      61             :     bool should_report() const;
      62             : 
      63             :     void update_from_demand();
      64             :     void update_servobased(int16_t gripper_pwm);
      65             : 
      66             :     float tesla() const;
      67             : 
      68             :     float demand;
      69             : };
      70             : 
      71             : }

Generated by: LCOV version 1.14