SIM_Frame.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. multicopter simulator class
  15. */
  16. #pragma once
  17. #include "SIM_Aircraft.h"
  18. #include "SIM_Motor.h"
  19. namespace SITL {
  20. /*
  21. class to describe a multicopter frame type
  22. */
  23. class Frame {
  24. public:
  25. const char *name;
  26. uint8_t num_motors;
  27. Motor *motors;
  28. Frame(const char *_name,
  29. uint8_t _num_motors,
  30. Motor *_motors) :
  31. name(_name),
  32. num_motors(_num_motors),
  33. motors(_motors) {}
  34. // find a frame by name
  35. static Frame *find_frame(const char *name);
  36. // initialise frame
  37. void init(float mass, float hover_throttle, float terminal_velocity, float terminal_rotation_rate);
  38. // calculate rotational and linear accelerations
  39. void calculate_forces(const Aircraft &aircraft,
  40. const struct sitl_input &input,
  41. Vector3f &rot_accel, Vector3f &body_accel);
  42. float terminal_velocity;
  43. float terminal_rotation_rate;
  44. float thrust_scale;
  45. uint8_t motor_offset;
  46. // calculate current and voltage
  47. void current_and_voltage(const struct sitl_input &input, float &voltage, float &current);
  48. };
  49. }