LCOV - code coverage report
Current view: top level - AP_Gripper - AP_Gripper.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 1 1 100.0 %
Date: 2026-09-09 11:02:08 Functions: 1 1 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             : #pragma once
      17             : 
      18             : #include "AP_Gripper_config.h"
      19             : 
      20             : #if AP_GRIPPER_ENABLED
      21             : 
      22             : #include <AP_Param/AP_Param.h>
      23             : 
      24             : class AP_Gripper_Backend;
      25             : 
      26             : class AP_Gripper {
      27             : public:
      28             :     AP_Gripper();
      29             : 
      30             :     /* Do not allow copies */
      31             :     CLASS_NO_COPY(AP_Gripper);
      32             : 
      33             :     static AP_Gripper *get_singleton();
      34             :     static AP_Gripper *_singleton;
      35             : 
      36             :     // indicate whether this module is enabled or not
      37     1552161 :     bool enabled() const { return _enabled; }
      38             : 
      39             :     // initialise the gripper
      40             :     void init();
      41             : 
      42             :     // grab - move the servo to the grab position
      43             :     void grab();
      44             : 
      45             :     // release - move the servo output to the release position
      46             :     void release();
      47             : 
      48             :     // released - returns true if currently in released position
      49             :     bool released() const;
      50             : 
      51             :     // grabbed - returns true if currently in grabbed position
      52             :     bool grabbed() const;
      53             : 
      54             :     // update - should be called at at least 10hz
      55             :     void update();
      56             : 
      57             :     // valid - returns true if we have a gripper and it should work
      58             :     bool valid() const;
      59             : 
      60             :     static const struct AP_Param::GroupInfo        var_info[];
      61             : 
      62             :     // parameters
      63             :     AP_Int8     _enabled;               // grabber enable/disable
      64             : 
      65             :     typedef enum {
      66             :         STATE_NEUTRAL,
      67             :         STATE_GRABBING,
      68             :         STATE_RELEASING,
      69             :         STATE_GRABBED,
      70             :         STATE_RELEASED,
      71             :     }  gripper_state;
      72             : 
      73             :     struct Backend_Config {
      74             :         AP_Int8     type;                  // grabber type (e.g. EPM or servo)
      75             :         AP_Int16    grab_pwm;              // PWM value sent to Gripper to initiate grabbing the cargo
      76             :         AP_Int16    release_pwm;           // PWM value sent to Gripper to release the cargo
      77             :         AP_Int16    neutral_pwm;           // PWM value sent to gripper when not grabbing or releasing
      78             :         AP_Int8     regrab_interval;       // Time in seconds that EPM gripper will regrab the cargo to ensure grip has not weakened
      79             :         AP_Float    autoclose_time;        // Automatic close time (in seconds)
      80             :         AP_Int16    uavcan_hardpoint_id;
      81             : 
      82             :         gripper_state state = STATE_NEUTRAL;
      83             :     } config;
      84             : 
      85             : private:
      86             : 
      87             :     AP_Gripper_Backend *backend;
      88             : };
      89             : 
      90             : namespace AP {
      91             :     AP_Gripper &gripper();
      92             : };
      93             : 
      94             : #endif  // AP_GRIPPER_ENABLED

Generated by: LCOV version 1.14