#pragma once #include #if CONFIG_HAL_BOARD == HAL_BOARD_SITL #include #include #include #include #include #include #include "SIM_Buzzer.h" #include "SIM_Gripper_EPM.h" #include "SIM_Gripper_Servo.h" #include "SIM_I2C.h" #include "SIM_SPI.h" #include "SIM_Parachute.h" #include "SIM_Precland.h" #include "SIM_Sprayer.h" #include "SIM_ToneAlarm.h" #include "SIM_EFI_MegaSquirt.h" #include "SIM_RichenPower.h" #include "SIM_FETtecOneWireESC.h" #include "SIM_IntelligentEnergy24.h" #include "SIM_Ship.h" #include "SIM_GPS.h" #include namespace SITL { enum class LedLayout { ROWS=0, LUMINOUSBEE=1, }; struct vector3f_array { uint16_t length; Vector3f *data; }; struct float_array { uint16_t length; float *data; }; struct sitl_fdm { // this is the structure passed between FDM models and the main SITL code uint64_t timestamp_us; Location home; double latitude, longitude; // degrees double altitude; // MSL double heading; // degrees double speedN, speedE, speedD; // m/s double xAccel, yAccel, zAccel; // m/s/s in body frame double rollRate, pitchRate, yawRate; // degrees/s in body frame double rollDeg, pitchDeg, yawDeg; // euler angles, degrees Quaternion quaternion; double airspeed; // m/s Vector3f velocity_air_bf; // velocity relative to airmass, body frame double battery_voltage; // Volts double battery_current; // Amps double battery_remaining; // Ah, if non-zero capacity uint8_t num_motors; uint8_t vtol_motor_start; float rpm[12]; // RPM of all motors uint8_t rcin_chan_count; float rcin[12]; // RC input 0..1 double range; // rangefinder value Vector3f bodyMagField; // Truth XYZ magnetic field vector in body-frame. Includes motor interference. Units are milli-Gauss. Vector3f angAccel; // Angular acceleration in degrees/s/s about the XYZ body axes struct { // data from simulated laser scanner, if available struct vector3f_array points; struct float_array ranges; } scanner; float rangefinder_m[RANGEFINDER_MAX_INSTANCES]; float airspeed_raw_pressure[2]; struct { float speed; float direction; } wind_vane_apparent; bool is_lock_step_scheduled; }; // number of rc output channels #define SITL_NUM_CHANNELS 16 class SIM { public: SIM() { // set a default compass offset for (uint8_t i = 0; i < HAL_COMPASS_MAX_SENSORS; i++) { mag_ofs[i].set(Vector3f(5, 13, -18)); } AP_Param::setup_object_defaults(this, var_info); AP_Param::setup_object_defaults(this, var_info2); AP_Param::setup_object_defaults(this, var_info3); #if HAL_SIM_GPS_ENABLED AP_Param::setup_object_defaults(this, var_gps); #endif AP_Param::setup_object_defaults(this, var_mag); AP_Param::setup_object_defaults(this, var_ins); #ifdef SFML_JOYSTICK AP_Param::setup_object_defaults(this, var_sfml_joystick); #endif // SFML_JOYSTICK for (uint8_t i=0; i