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