Line data Source code
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 the last_letter_lib flight dynamics library 17 : 18 : last_letter_lib speaks the standard JSON backend protocol, so all the wire 19 : handling is inherited from SITL::JSON. The only thing added here is launching 20 : the simulator process, which lives outside the ArduPilot tree: 21 : 22 : sim_vehicle.py -v ArduPlane --model last_letter:<aircraft> 23 : 24 : The aircraft name after the colon is passed to the child; it defaults to 25 : "ardupilot_plane". The binary is looked up on PATH as "last_letter_ardupilot", 26 : overridable with the LAST_LETTER_SITL_BIN environment variable. 27 : 28 : Optional features are selected with the SITL --config string, which 29 : sim_vehicle.py forwards through -A: 30 : 31 : sim_vehicle.py -v ArduPlane --model last_letter:<aircraft> -A "--config log" 32 : */ 33 : 34 : #pragma once 35 : 36 : #include "SIM_config.h" 37 : 38 : #if AP_SIM_LAST_LETTER_ENABLED 39 : 40 : #include "SIM_JSON.h" 41 : 42 : namespace SITL { 43 : 44 : /* 45 : a last_letter simulator 46 : */ 47 : class last_letter : public JSON { 48 : public: 49 : last_letter(const char *frame_str); 50 : 51 : /* static object creator */ 52 0 : static Aircraft *create(const char *frame_str) { 53 0 : return NEW_NOTHROW last_letter(frame_str); 54 : } 55 : 56 : /* 57 : the UDP port is only known once this is called, so it is recorded here 58 : rather than in the constructor 59 : */ 60 : void set_interface_ports(const char* address, const int port_in, const int port_out) override; 61 : 62 : /* 63 : parse the SITL --config string 64 : */ 65 : void set_config(const char *config) override; 66 : 67 : /* 68 : fork the last_letter_ardupilot binary 69 : */ 70 : void launch_external_sim(void) override; 71 : 72 : private: 73 : char model_name[64]; 74 : 75 : // The port the child must bind, from set_interface_ports(). 76 : uint16_t sim_port; 77 : 78 : // --config log 79 : bool want_log; 80 : }; 81 : 82 : } // namespace SITL 83 : 84 : #endif // AP_SIM_LAST_LETTER_ENABLED