AP_Gripper_Servo.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program. If not, see <http://www.gnu.org/licenses/>.
  12. */
  13. #pragma once
  14. #include <AP_Gripper/AP_Gripper_Backend.h>
  15. #include <SRV_Channel/SRV_Channel.h>
  16. class AP_Gripper_Servo : public AP_Gripper_Backend {
  17. public:
  18. AP_Gripper_Servo(struct AP_Gripper::Backend_Config &_config) :
  19. AP_Gripper_Backend(_config) { }
  20. // grab - move the servo to the grab position
  21. void grab() override;
  22. // release - move the servo output to the release position
  23. void release() override;
  24. // grabbed - returns true if gripper in grabbed state
  25. bool grabbed() const override;
  26. // released - returns true if gripper in released state
  27. bool released() const override;
  28. // valid - returns true if the backend should be working
  29. bool valid() const override;
  30. protected:
  31. // type-specific intiailisations:
  32. void init_gripper() override;
  33. // type-specific periodic updates:
  34. void update_gripper() override;
  35. private:
  36. uint32_t action_timestamp; // ms; time grab or release happened
  37. const uint16_t action_time = 3000; // ms; time to grab or release
  38. bool has_state_pwm(const uint16_t pwm) const;
  39. #if CONFIG_HAL_BOARD == HAL_BOARD_SITL
  40. bool is_releasing;
  41. bool is_released;
  42. #endif
  43. };