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/AP_Gripper_Backend.h> 19 : 20 : #if AP_GRIPPER_SERVO_ENABLED 21 : 22 : #define SERVO_ACTUATION_TIME 500 // Time for servo to move to target position during grab or release in milliseconds 23 : 24 : class AP_Gripper_Servo : public AP_Gripper_Backend { 25 : public: 26 : 27 6 : AP_Gripper_Servo(struct AP_Gripper::Backend_Config &_config) : 28 6 : AP_Gripper_Backend(_config) { } 29 : 30 : // grab - move the servo to the grab position 31 : void grab() override; 32 : 33 : // release - move the servo output to the release position 34 : void release() override; 35 : 36 : // grabbed - returns true if gripper in grabbed state 37 : bool grabbed() const override; 38 : 39 : // released - returns true if gripper in released state 40 : bool released() const override; 41 : 42 : // valid - returns true if the backend should be working 43 : bool valid() const override; 44 : 45 : protected: 46 : 47 : // type-specific initializations: 48 : void init_gripper() override; 49 : 50 : // type-specific periodic updates: 51 : void update_gripper() override; 52 : 53 : private: 54 : 55 : bool has_state_pwm(const uint16_t pwm) const; 56 : }; 57 : 58 : #endif // AP_GRIPPER_SERVO_ENABLED