2012-06-29 02:06:28 -03:00
|
|
|
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
|
|
|
#ifndef __SITL_H__
|
|
|
|
#define __SITL_H__
|
|
|
|
|
|
|
|
#include <AP_Param.h>
|
|
|
|
#include <AP_Common.h>
|
|
|
|
#include <AP_Math.h>
|
|
|
|
#include <GCS_MAVLink.h>
|
2014-01-03 01:01:18 -04:00
|
|
|
#include <DataFlash.h>
|
2012-06-29 02:06:28 -03:00
|
|
|
|
2013-05-09 07:05:18 -03:00
|
|
|
struct PACKED sitl_fdm {
|
2012-06-29 02:06:28 -03:00
|
|
|
// this is the packet sent by the simulator
|
|
|
|
// to the APM executable to update the simulator state
|
|
|
|
// All values are little-endian
|
2015-05-02 07:29:16 -03:00
|
|
|
uint64_t timestamp_us;
|
2012-06-29 02:06:28 -03:00
|
|
|
double latitude, longitude; // degrees
|
|
|
|
double altitude; // MSL
|
|
|
|
double heading; // degrees
|
2013-03-27 20:28:44 -03:00
|
|
|
double speedN, speedE, speedD; // m/s
|
2012-06-29 02:06:28 -03:00
|
|
|
double xAccel, yAccel, zAccel; // m/s/s in body frame
|
|
|
|
double rollRate, pitchRate, yawRate; // degrees/s/s in earth frame
|
|
|
|
double rollDeg, pitchDeg, yawDeg; // euler angles, degrees
|
|
|
|
double airspeed; // m/s
|
2013-03-27 20:28:44 -03:00
|
|
|
uint32_t magic; // 0x4c56414f
|
2012-06-29 02:06:28 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SITL
|
|
|
|
{
|
|
|
|
public:
|
2012-12-12 17:48:38 -04:00
|
|
|
|
|
|
|
SITL() {
|
2015-04-20 19:29:27 -03:00
|
|
|
// set a default compass offset
|
|
|
|
mag_ofs.set(Vector3f(5, 13, -18));
|
2012-12-12 17:48:38 -04:00
|
|
|
AP_Param::setup_object_defaults(this, var_info);
|
|
|
|
}
|
|
|
|
|
2013-02-16 05:15:57 -04:00
|
|
|
enum GPSType {
|
2013-02-16 05:59:48 -04:00
|
|
|
GPS_TYPE_NONE = 0,
|
|
|
|
GPS_TYPE_UBLOX = 1,
|
|
|
|
GPS_TYPE_MTK = 2,
|
|
|
|
GPS_TYPE_MTK16 = 3,
|
2013-08-13 23:11:46 -03:00
|
|
|
GPS_TYPE_MTK19 = 4,
|
2014-03-31 23:12:15 -03:00
|
|
|
GPS_TYPE_NMEA = 5,
|
2014-04-03 19:48:40 -03:00
|
|
|
GPS_TYPE_SBP = 6,
|
2013-02-16 05:15:57 -04:00
|
|
|
};
|
|
|
|
|
2012-06-29 02:06:28 -03:00
|
|
|
struct sitl_fdm state;
|
|
|
|
|
|
|
|
static const struct AP_Param::GroupInfo var_info[];
|
|
|
|
|
|
|
|
// noise levels for simulated sensors
|
2013-11-24 05:16:46 -04:00
|
|
|
AP_Float baro_noise; // in metres
|
|
|
|
AP_Float baro_drift; // in metres per second
|
2014-07-28 05:40:17 -03:00
|
|
|
AP_Float baro_glitch; // glitch in meters
|
2012-06-29 02:06:28 -03:00
|
|
|
AP_Float gyro_noise; // in degrees/second
|
|
|
|
AP_Float accel_noise; // in m/s/s
|
2014-07-28 05:40:17 -03:00
|
|
|
AP_Vector3f accel_bias; // in m/s/s
|
2013-10-14 01:40:45 -03:00
|
|
|
AP_Float aspd_noise; // in m/s
|
2012-06-29 02:06:28 -03:00
|
|
|
AP_Float mag_noise; // in mag units (earth field is 818)
|
2013-05-27 00:37:18 -03:00
|
|
|
AP_Float mag_error; // in degrees
|
2014-05-12 06:44:15 -03:00
|
|
|
AP_Vector3f mag_mot; // in mag units per amp
|
2015-04-20 19:29:27 -03:00
|
|
|
AP_Vector3f mag_ofs; // in mag units
|
2013-09-15 20:16:52 -03:00
|
|
|
AP_Float servo_rate; // servo speed in degrees/second
|
2012-06-29 02:06:28 -03:00
|
|
|
|
2013-11-26 01:58:30 -04:00
|
|
|
AP_Float sonar_glitch;// probablility between 0-1 that any given sonar sample will read as max distance
|
|
|
|
AP_Float sonar_noise; // in metres
|
2014-08-10 09:36:38 -03:00
|
|
|
AP_Float sonar_scale; // meters per volt
|
2013-11-26 01:42:43 -04:00
|
|
|
|
2012-06-29 02:06:28 -03:00
|
|
|
AP_Float drift_speed; // degrees/second/minute
|
|
|
|
AP_Float drift_time; // period in minutes
|
2012-08-17 01:21:43 -03:00
|
|
|
AP_Float engine_mul; // engine multiplier
|
2012-06-29 02:06:28 -03:00
|
|
|
AP_Int8 gps_disable; // disable simulated GPS
|
2014-03-02 16:07:09 -04:00
|
|
|
AP_Int8 gps2_enable; // enable 2nd simulated GPS
|
2012-07-04 08:05:04 -03:00
|
|
|
AP_Int8 gps_delay; // delay in samples
|
2013-02-16 05:15:57 -04:00
|
|
|
AP_Int8 gps_type; // see enum GPSType
|
2013-02-16 07:00:16 -04:00
|
|
|
AP_Float gps_byteloss;// byte loss as a percent
|
2013-05-06 21:38:36 -03:00
|
|
|
AP_Int8 gps_numsats; // number of visible satellites
|
2013-09-19 03:51:03 -03:00
|
|
|
AP_Vector3f gps_glitch; // glitch offsets in lat, lon and altitude
|
2013-10-02 05:44:20 -03:00
|
|
|
AP_Int8 gps_hertz; // GPS update rate in Hz
|
|
|
|
AP_Float batt_voltage; // battery voltage base
|
2013-11-06 21:49:08 -04:00
|
|
|
AP_Float accel_fail; // accelerometer failure value
|
2013-12-19 18:40:31 -04:00
|
|
|
AP_Int8 rc_fail; // fail RC input
|
2014-04-11 03:47:26 -03:00
|
|
|
AP_Int8 baro_disable; // disable simulated barometer
|
2014-04-21 02:24:45 -03:00
|
|
|
AP_Int8 float_exception; // enable floating point exception checks
|
2015-01-02 06:49:56 -04:00
|
|
|
AP_Int8 flow_enable; // enable simulated optflow
|
2015-01-05 23:02:43 -04:00
|
|
|
AP_Int16 flow_rate; // optflow data rate (Hz)
|
2015-01-05 23:18:44 -04:00
|
|
|
AP_Int8 flow_delay; // optflow data delay
|
2015-01-03 06:47:28 -04:00
|
|
|
AP_Int8 terrain_enable; // enable using terrain for height
|
2012-06-29 02:06:28 -03:00
|
|
|
|
2012-08-24 08:22:20 -03:00
|
|
|
// wind control
|
|
|
|
AP_Float wind_speed;
|
|
|
|
AP_Float wind_direction;
|
|
|
|
AP_Float wind_turbulance;
|
2015-02-20 17:32:49 -04:00
|
|
|
AP_Float gps_drift_alt;
|
2015-04-13 03:22:57 -03:00
|
|
|
|
|
|
|
AP_Int16 baro_delay; // barometer data delay in ms
|
|
|
|
AP_Int16 mag_delay; // magnetometer data delay in ms
|
|
|
|
AP_Int16 wind_delay; // windspeed data delay in ms
|
|
|
|
|
2012-06-29 02:06:28 -03:00
|
|
|
void simstate_send(mavlink_channel_t chan);
|
|
|
|
|
2014-01-03 01:01:18 -04:00
|
|
|
void Log_Write_SIMSTATE(DataFlash_Class &dataflash);
|
|
|
|
|
2012-06-29 02:06:28 -03:00
|
|
|
// convert a set of roll rates from earth frame to body frame
|
|
|
|
static void convert_body_frame(double rollDeg, double pitchDeg,
|
|
|
|
double rollRate, double pitchRate, double yawRate,
|
|
|
|
double *p, double *q, double *r);
|
2015-05-02 07:29:16 -03:00
|
|
|
|
|
|
|
// convert a set of roll rates from body frame to earth frame
|
|
|
|
static Vector3f convert_earth_frame(const Matrix3f &dcm, const Vector3f &gyro);
|
2012-06-29 02:06:28 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __SITL_H__
|