SIM_last_letter.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. simulator connection for ardupilot version of last_letter
  15. */
  16. #pragma once
  17. #include <AP_HAL/utility/Socket.h>
  18. #include "SIM_Aircraft.h"
  19. namespace SITL {
  20. /*
  21. a last_letter simulator
  22. */
  23. class last_letter : public Aircraft {
  24. public:
  25. last_letter(const char *frame_str);
  26. /* update model by one time step */
  27. void update(const struct sitl_input &input) override;
  28. /* static object creator */
  29. static Aircraft *create(const char *frame_str) {
  30. return new last_letter(frame_str);
  31. }
  32. private:
  33. static const uint16_t fdm_port = 5002;
  34. /*
  35. packet sent to last_letter
  36. */
  37. struct servo_packet {
  38. uint16_t servos[16];
  39. };
  40. /*
  41. reply packet sent from last_letter to ArduPilot
  42. */
  43. struct fdm_packet {
  44. uint64_t timestamp_us; // simulation time in microseconds
  45. double latitude, longitude;
  46. double altitude;
  47. double heading;
  48. double speedN, speedE, speedD;
  49. double xAccel, yAccel, zAccel;
  50. double rollRate, pitchRate, yawRate;
  51. double roll, pitch, yaw;
  52. double airspeed;
  53. };
  54. void recv_fdm(const struct sitl_input &input);
  55. void send_servos(const struct sitl_input &input);
  56. void start_last_letter(void);
  57. uint64_t last_timestamp_us;
  58. SocketAPM sock;
  59. };
  60. } // namespace SITL