2015-12-31 21:26:32 -04:00
|
|
|
/*
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
simple plane simulator class
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "SIM_Aircraft.h"
|
2016-07-15 05:29:12 -03:00
|
|
|
#include "SIM_ICEngine.h"
|
2016-10-25 05:54:56 -03:00
|
|
|
#include <Filter/LowPassFilter.h>
|
2015-12-31 21:26:32 -04:00
|
|
|
|
|
|
|
namespace SITL {
|
|
|
|
|
|
|
|
/*
|
|
|
|
a very simple plane simulator
|
|
|
|
*/
|
|
|
|
class Plane : public Aircraft {
|
|
|
|
public:
|
2019-08-15 01:01:24 -03:00
|
|
|
Plane(const char *frame_str);
|
2015-12-31 21:26:32 -04:00
|
|
|
|
|
|
|
/* update model by one time step */
|
2019-02-21 19:12:05 -04:00
|
|
|
virtual void update(const struct sitl_input &input) override;
|
2015-12-31 21:26:32 -04:00
|
|
|
|
|
|
|
/* static object creator */
|
2019-08-15 01:01:24 -03:00
|
|
|
static Aircraft *create(const char *frame_str) {
|
|
|
|
return new Plane(frame_str);
|
2015-12-31 21:26:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2016-01-20 01:38:35 -04:00
|
|
|
const float hover_throttle = 0.7f;
|
2015-12-31 21:26:32 -04:00
|
|
|
const float air_density = 1.225; // kg/m^3 at sea level, ISA conditions
|
|
|
|
float angle_of_attack;
|
2016-01-02 21:30:51 -04:00
|
|
|
float beta;
|
2015-12-31 21:26:32 -04:00
|
|
|
|
|
|
|
struct {
|
2016-01-20 01:38:35 -04:00
|
|
|
// from last_letter skywalker_2013/aerodynamics.yaml
|
|
|
|
// thanks to Georacer!
|
|
|
|
float s = 0.45;
|
|
|
|
float b = 1.88;
|
|
|
|
float c = 0.24;
|
|
|
|
float c_lift_0 = 0.56;
|
|
|
|
float c_lift_deltae = 0;
|
|
|
|
float c_lift_a = 6.9;
|
|
|
|
float c_lift_q = 0;
|
|
|
|
float mcoeff = 50;
|
|
|
|
float oswald = 0.9;
|
|
|
|
float alpha_stall = 0.4712;
|
|
|
|
float c_drag_q = 0;
|
|
|
|
float c_drag_deltae = 0.0;
|
|
|
|
float c_drag_p = 0.1;
|
|
|
|
float c_y_0 = 0;
|
|
|
|
float c_y_b = -0.98;
|
|
|
|
float c_y_p = 0;
|
|
|
|
float c_y_r = 0;
|
|
|
|
float c_y_deltaa = 0;
|
|
|
|
float c_y_deltar = -0.2;
|
|
|
|
float c_l_0 = 0;
|
|
|
|
float c_l_p = -1.0;
|
|
|
|
float c_l_b = -0.12;
|
|
|
|
float c_l_r = 0.14;
|
|
|
|
float c_l_deltaa = 0.25;
|
|
|
|
float c_l_deltar = -0.037;
|
|
|
|
float c_m_0 = 0.045;
|
|
|
|
float c_m_a = -0.7;
|
|
|
|
float c_m_q = -20;
|
|
|
|
float c_m_deltae = 1.0;
|
|
|
|
float c_n_0 = 0;
|
|
|
|
float c_n_b = 0.25;
|
|
|
|
float c_n_p = 0.022;
|
|
|
|
float c_n_r = -1;
|
|
|
|
float c_n_deltaa = 0.00;
|
|
|
|
float c_n_deltar = 0.1;
|
|
|
|
float deltaa_max = 0.3491;
|
|
|
|
float deltae_max = 0.3491;
|
|
|
|
float deltar_max = 0.3491;
|
|
|
|
// the X CoG offset should be -0.02, but that makes the plane too tail heavy
|
|
|
|
// in manual flight. Adjusted to -0.15 gives reasonable flight
|
|
|
|
Vector3f CGOffset{-0.15, 0, -0.05};
|
2015-12-31 21:26:32 -04:00
|
|
|
} coefficient;
|
|
|
|
|
|
|
|
float thrust_scale;
|
2016-01-30 04:40:45 -04:00
|
|
|
bool reverse_thrust;
|
2016-04-21 21:08:00 -03:00
|
|
|
bool elevons;
|
|
|
|
bool vtail;
|
2017-07-01 03:01:11 -03:00
|
|
|
bool dspoilers;
|
2016-07-22 03:42:23 -03:00
|
|
|
bool reverse_elevator_rudder;
|
2016-07-15 05:29:12 -03:00
|
|
|
bool ice_engine;
|
2017-02-11 07:30:42 -04:00
|
|
|
bool tailsitter;
|
2019-04-05 15:28:09 -03:00
|
|
|
bool copter_tailsitter;
|
2017-08-28 04:50:21 -03:00
|
|
|
bool have_launcher;
|
|
|
|
float launch_accel;
|
|
|
|
float launch_time;
|
|
|
|
uint64_t launch_start_ms;
|
2016-07-15 05:29:12 -03:00
|
|
|
|
2019-02-08 03:39:30 -04:00
|
|
|
const uint8_t throttle_servo = 2;
|
|
|
|
const int8_t choke_servo = 14;
|
|
|
|
const int8_t ignition_servo = 12;
|
|
|
|
const int8_t starter_servo = 13;
|
|
|
|
const float slewrate = 100;
|
|
|
|
ICEngine icengine{
|
|
|
|
throttle_servo,
|
|
|
|
choke_servo,
|
|
|
|
ignition_servo,
|
|
|
|
starter_servo,
|
2022-01-30 05:52:37 -04:00
|
|
|
slewrate,
|
|
|
|
true
|
2019-02-08 03:39:30 -04:00
|
|
|
};
|
2015-12-31 21:26:32 -04:00
|
|
|
|
2016-01-20 01:38:35 -04:00
|
|
|
float liftCoeff(float alpha) const;
|
|
|
|
float dragCoeff(float alpha) const;
|
|
|
|
Vector3f getForce(float inputAileron, float inputElevator, float inputRudder) const;
|
2017-04-17 01:23:15 -03:00
|
|
|
Vector3f getTorque(float inputAileron, float inputElevator, float inputRudder, float inputThrust, const Vector3f &force) const;
|
2020-12-22 10:35:23 -04:00
|
|
|
void calculate_forces(const struct sitl_input &input, Vector3f &rot_accel);
|
2015-12-31 21:26:32 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace SITL
|