LCOV - code coverage report
Current view: top level - SITL - SIM_Gripper_Servo.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 Gripper (Servo) simulation class
      17             : */
      18             : 
      19             : #pragma once
      20             : #include "stdint.h"
      21             : #include <AP_Param/AP_Param.h>
      22             : #include "SITL_Input.h"
      23             : 
      24             : namespace SITL {
      25             : 
      26             : class Gripper_Servo {
      27             : public:
      28        2096 :     Gripper_Servo() {
      29        2096 :         AP_Param::setup_object_defaults(this, var_info);
      30        2096 :     };
      31             : 
      32             :     // update Gripper state
      33             :     void update(const struct sitl_input &input);
      34             : 
      35             :     float payload_mass() const; // kg
      36             : 
      37      810128 :     void set_alt(float alt) {altitude = alt;};
      38             :     static const struct AP_Param::GroupInfo var_info[];
      39   178759942 :     bool is_enabled() const {return static_cast<bool>(gripper_enable);}
      40             :     bool is_jaw_open() const {return jaw_open;}
      41             : 
      42             : private:
      43             :     static constexpr int16_t SIM_GRIPPER_GRAB_PWM_DEFAULT = 2000;
      44             :     static constexpr int16_t SIM_GRIPPER_RELEASE_PWM_DEFAULT = 1000;
      45             :     AP_Int8  gripper_enable;  // enable gripper sim
      46             :     AP_Int8  gripper_servo_pin;
      47             :     AP_Int16 grab_pwm;              // PWM value sent to Gripper to initiate grabbing the cargo
      48             :     AP_Int16 release_pwm;           // PWM value sent to Gripper to release the cargo
      49             :     AP_Int8 reverse;                // reverse closing direction
      50             :     const uint32_t report_interval = 1000000; // microseconds
      51             :     uint64_t last_report_us;
      52             :     bool jaw_open = false;
      53             :     const float gap = 30; // mm
      54             :     float altitude;
      55             :     float position; // percentage
      56             :     float position_slew_rate = 35; // percentage
      57             :     float reported_position = -1; // unlikely
      58             : 
      59             :     uint64_t last_update_us;
      60             : 
      61             :     bool should_report() const;
      62             : 
      63             :     // dangle load from a string:
      64             :     const float string_length = 2.0f; // metres
      65             :     float load_mass = 0.0f; // kilograms
      66             : };
      67             : 
      68             : }

Generated by: LCOV version 1.14