SITL: improved realism of fixed wing sim somewhat

still not good, but a bit better for manual flight
This commit is contained in:
Andrew Tridgell 2016-01-03 12:30:51 +11:00
parent 83c8505b3c
commit 0966398d8d
3 changed files with 18 additions and 15 deletions

View File

@ -71,7 +71,7 @@ float Plane::calculate_drag_induced(void) const
if (airspeed < 0.1) {
return 0;
}
float drag_i = sq(lift) / (0.25 * sq(air_density) * sq(airspeed) * wing_area * M_PI_F * wing_efficiency * aspect_ratio);
float drag_i = coefficient.lift_drag * sq(lift) / (0.25 * sq(air_density) * sq(airspeed) * wing_area * M_PI_F * wing_efficiency * aspect_ratio);
return drag_i;
}
@ -124,25 +124,25 @@ void Plane::calculate_forces(const struct sitl_input &input, Vector3f &rot_accel
// add torque of stabilisers
rot_accel.z += velocity_bf.y * speed_scaling * coefficient.vertical_stabiliser;
rot_accel.y -= velocity_bf.z * speed_scaling * coefficient.horizontal_stabiliser;
// calculate angle of attack
angle_of_attack = atan2f(velocity_bf.z, velocity_bf.x);
beta = atan2f(velocity_bf.y,velocity_bf.x);
// add dihedral
rot_accel.x -= beta * airspeed * coefficient.dihedral;
// velocity in body frame
velocity_bf = dcm.transposed() * velocity_ef;
// calculate angle of attack
angle_of_attack = atan2f(velocity_bf.z, velocity_bf.x);
// get lift and drag in body frame, in neutons
Vector3f lift_drag = calculate_lift_drag();
// air resistance
Vector3f air_resistance = -velocity_ef * (GRAVITY_MSS/terminal_velocity);
// scale thrust to newtons
thrust *= thrust_scale;
accel_body = Vector3f(thrust/mass, 0, 0);
accel_body += lift_drag/mass;
accel_body += dcm.transposed() * air_resistance;
// add some noise
add_noise(thrust / thrust_scale);

View File

@ -39,10 +39,9 @@ public:
}
protected:
const float hover_throttle = 0.5f;
const float hover_throttle = 1.2f;
const float cruise_airspeed = 20;
const float cruise_pitch = radians(4);
const float terminal_velocity = 55;
const float wing_efficiency = 0.9;
const float wing_span = 2.0;
const float wing_chord = 0.15;
@ -50,18 +49,21 @@ protected:
const float wing_area = wing_span * wing_chord;
const float air_density = 1.225; // kg/m^3 at sea level, ISA conditions
float angle_of_attack;
float beta;
Vector3f velocity_bf;
// manually tweaked coefficients. Not even close to reality
struct {
float drag = 0.001;
float lift = 3.0;
float drag = 0.005;
float lift = 2.0;
float lift_drag = 0.5;
float vertical_stabiliser = 0.1;
float horizontal_stabiliser = 0.001;
float horizontal_stabiliser = 2;
float dihedral = 0.1;
} coefficient;
float thrust_scale;
Vector3f terminal_rotation_rate{radians(360), radians(360), radians(180)};
Vector3f terminal_rotation_rate{radians(170), radians(200), radians(180)};
Vector3f max_rates{radians(350), radians(250), radians(100)};
float calculate_lift(void) const;

View File

@ -37,7 +37,8 @@ QuadPlane::QuadPlane(const char *home_str, const char *frame_str) :
Plane(home_str, frame_str)
{
frame = &quad_frame;
frame->init(mass, 0.51, 50, 20*radians(360));
// we use a very high terminal velocity to let the plane model handle the drag
frame->init(mass, 0.51, 100, 20*radians(360));
}
/*