forked from ArduPilot/ardupilot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSIMState.h
236 lines (187 loc) · 6.15 KB
/
SIMState.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
#pragma once
#include <SITL/SITL.h>
#if AP_SIM_ENABLED
#include <AP_HAL/AP_HAL.h>
#include <SITL/SITL_Input.h>
#include <SITL/SIM_SoloGimbal.h>
#include <SITL/SIM_ADSB.h>
#include <SITL/SIM_Vicon.h>
#include <SITL/SIM_RF_Benewake_TF02.h>
#include <SITL/SIM_RF_Benewake_TF03.h>
#include <SITL/SIM_RF_Benewake_TFmini.h>
#include <SITL/SIM_RF_NoopLoop.h>
#include <SITL/SIM_RF_TeraRanger_Serial.h>
#include <SITL/SIM_RF_LightWareSerial.h>
#include <SITL/SIM_RF_LightWareSerialBinary.h>
#include <SITL/SIM_RF_Lanbao.h>
#include <SITL/SIM_RF_BLping.h>
#include <SITL/SIM_RF_LeddarOne.h>
#include <SITL/SIM_RF_RDS02UF.h>
#include <SITL/SIM_RF_USD1_v0.h>
#include <SITL/SIM_RF_USD1_v1.h>
#include <SITL/SIM_RF_MaxsonarSerialLV.h>
#include <SITL/SIM_RF_Wasp.h>
#include <SITL/SIM_RF_NMEA.h>
#include <SITL/SIM_RF_MAVLink.h>
#include <SITL/SIM_RF_GYUS42v2.h>
#include <SITL/SIM_VectorNav.h>
#include <SITL/SIM_MicroStrain.h>
#include <SITL/SIM_InertialLabs.h>
#include <SITL/SIM_AIS.h>
#include <SITL/SIM_GPS.h>
#include <SITL/SIM_EFI_Hirth.h>
#include <SITL/SIM_Frsky_D.h>
#include <SITL/SIM_CRSF.h>
#include <SITL/SIM_PS_RPLidarA2.h>
#include <SITL/SIM_PS_TeraRangerTower.h>
#include <SITL/SIM_PS_LightWare_SF45B.h>
#include <SITL/SIM_RichenPower.h>
#include <SITL/SIM_Loweheiser.h>
#include <SITL/SIM_FETtecOneWireESC.h>
#include <AP_HAL/utility/Socket_native.h>
#include <AP_HAL/AP_HAL_Namespace.h>
class AP_HAL::SIMState {
public:
// simulated airspeed, sonar and battery monitor
uint16_t sonar_pin_value; // pin 0
uint16_t airspeed_pin_value[2]; // pin 1
uint16_t voltage_pin_value; // pin 13
uint16_t current_pin_value; // pin 12
uint16_t voltage2_pin_value; // pin 15
uint16_t current2_pin_value; // pin 14
void update();
#if HAL_SIM_GPS_ENABLED
void set_gps0(SITL::GPS *_gps) { gps[0] = _gps; }
#endif
uint16_t pwm_output[32]; // was SITL_NUM_CHANNELS
private:
void _set_param_default(const char *parm);
void _sitl_setup(const char *home_str);
void _setup_timer(void);
void _setup_adc(void);
void set_height_agl(void);
void _set_signal_handlers(void) const;
void _update_airspeed(float airspeed);
void _simulator_servos(struct sitl_input &input);
void _fdm_input_step(void);
void fdm_input_local(void);
void wait_clock(uint64_t wait_time_usec);
uint16_t pwm_input[16]; // was SITL_RC_INPUT_CHANNELS
// internal state
// enum vehicle_type _vehicle;
uint8_t _instance;
uint16_t _base_port;
pid_t _parent_pid;
uint32_t _update_count;
SITL::SIM *_sitl;
uint16_t _rcin_port;
uint16_t _fg_view_port;
uint16_t _irlock_port;
float _current;
bool _synthetic_clock_mode;
bool _use_rtscts;
bool _use_fg_view;
const char *_fg_address;
// internal SITL model
SITL::Aircraft *sitl_model;
#if AP_SIM_SOLOGIMBAL_ENABLED
// simulated gimbal
bool enable_gimbal;
SITL::SoloGimbal *gimbal;
#endif
#if HAL_SIM_ADSB_ENABLED
// simulated ADSb
SITL::ADSB *adsb;
#endif
// simulated vicon system:
SITL::Vicon *vicon;
// simulated Benewake tf02 rangefinder:
SITL::RF_Benewake_TF02 *benewake_tf02;
// simulated Benewake tf03 rangefinder:
SITL::RF_Benewake_TF03 *benewake_tf03;
// simulated Benewake tfmini rangefinder:
SITL::RF_Benewake_TFmini *benewake_tfmini;
//simulated NoopLoop TOFSense rangefinder:
SITL::RF_Nooploop *nooploop;
// simulated TeraRangerSerial rangefinder:
SITL::RF_TeraRanger_Serial *teraranger_serial;
// simulated LightWareSerial rangefinder - legacy protocol::
SITL::RF_LightWareSerial *lightwareserial;
// simulated LightWareSerial rangefinder - binary protocol:
SITL::RF_LightWareSerialBinary *lightwareserial_binary;
// simulated Lanbao rangefinder:
SITL::RF_Lanbao *lanbao;
// simulated BLping rangefinder:
SITL::RF_BLping *blping;
// simulated LeddarOne rangefinder:
SITL::RF_LeddarOne *leddarone;
// simulated RDS02UF rangefinder:
SITL::RF_RDS02UF *rds02uf;
// simulated USD1 v0 rangefinder:
SITL::RF_USD1_v0 *USD1_v0;
// simulated USD1 v1 rangefinder:
SITL::RF_USD1_v1 *USD1_v1;
// simulated MaxsonarSerialLV rangefinder:
SITL::RF_MaxsonarSerialLV *maxsonarseriallv;
// simulated Wasp rangefinder:
SITL::RF_Wasp *wasp;
// simulated NMEA rangefinder:
SITL::RF_NMEA *nmea;
// simulated MAVLink rangefinder:
SITL::RF_MAVLink *rf_mavlink;
// simulated GYUS42v2 rangefinder:
SITL::RF_GYUS42v2 *gyus42v2;
// simulated Frsky devices
SITL::Frsky_D *frsky_d;
// SITL::Frsky_SPort *frsky_sport;
// SITL::Frsky_SPortPassthrough *frsky_sportpassthrough;
#if HAL_SIM_PS_RPLIDARA2_ENABLED
// simulated RPLidarA2:
SITL::PS_RPLidarA2 *rplidara2;
#endif
// simulated FETtec OneWire ESCs:
SITL::FETtecOneWireESC *fetteconewireesc;
#if HAL_SIM_PS_LIGHTWARE_SF45B_ENABLED
// simulated SF45B proximity sensor:
SITL::PS_LightWare_SF45B *sf45b;
#endif
#if HAL_SIM_PS_TERARANGERTOWER_ENABLED
SITL::PS_TeraRangerTower *terarangertower;
#endif
#if AP_SIM_CRSF_ENABLED
// simulated CRSF devices
SITL::CRSF *crsf;
#endif
// simulated VectorNav system:
SITL::VectorNav *vectornav;
// simulated MicroStrain Series 5 system
SITL::MicroStrain5 *microstrain5;
// simulated MicroStrain Series 7 system
SITL::MicroStrain7 *microstrain7;
// simulated InertialLabs INS-U
SITL::InertialLabs *inertiallabs;
#if HAL_SIM_JSON_MASTER_ENABLED
// Ride along instances via JSON SITL backend
SITL::JSON_Master ride_along;
#endif
#if HAL_SIM_AIS_ENABLED
// simulated AIS stream
SITL::AIS *ais;
#endif
// simulated EFI MegaSquirt device:
SITL::EFI_MegaSquirt *efi_ms;
// simulated EFI Hirth device:
SITL::EFI_Hirth *efi_hirth;
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
// output socket for flightgear viewing
SocketAPM_native fg_socket{true};
#endif
const char *defaults_path = HAL_PARAM_DEFAULTS_PATH;
const char *_home_str;
uint32_t wind_start_delay_micros;
#if HAL_SIM_GPS_ENABLED
// simulated GPS devices
SITL::GPS *gps[2]; // constrained by # of parameter sets
#endif
};
#endif // AP_SIM_ENABLED