SIM_Gripper_EPM.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. /*
  14. simple Gripper (EPM) simulation class
  15. */
  16. #pragma once
  17. #include "stdint.h"
  18. #include <AP_Param/AP_Param.h>
  19. #include "SITL_Input.h"
  20. namespace SITL {
  21. class Gripper_EPM {
  22. public:
  23. Gripper_EPM() {
  24. AP_Param::setup_object_defaults(this, var_info);
  25. };
  26. float payload_mass() const { return 0.0f; } // kg
  27. // update field stength
  28. void update(const struct sitl_input &input);
  29. static const struct AP_Param::GroupInfo var_info[];
  30. bool is_enabled() const {return static_cast<bool>(gripper_emp_enable);}
  31. private:
  32. AP_Int8 gripper_emp_enable; // enable gripper sim
  33. AP_Int8 gripper_emp_servo_pin;
  34. const uint32_t report_interval = 100000; // microseconds
  35. uint64_t last_report_us;
  36. bool servo_based = true;
  37. float field_strength; // percentage
  38. float reported_field_strength = -1; // unlikely
  39. // I've a feeling these are probably a higher order than this:
  40. const float field_strength_slew_rate = 400; // (percentage of delta between field strength and 100)/second
  41. const float field_decay_rate = 2; // percent of field strength/second
  42. const float field_degauss_rate = 300; // percent of field strength/second
  43. uint64_t last_update_us;
  44. bool should_report();
  45. void update_from_demand();
  46. void update_servobased(int16_t gripper_pwm);
  47. float tesla();
  48. float demand;
  49. };
  50. }