uavsim.flightdynamicsmodel
Class AircraftModel

java.lang.Object
  extended by uavsim.flightdynamicsmodel.AircraftModel

public class AircraftModel
extends java.lang.Object

Defines a fixed-wing aircraft as a finite-element model consisting of ailerons, flaps, an elevator, a rudder, and a fuselage. It is derived from Physics for Game Developers by David Bourg.

Author:
Dan Tappan [18.08.11]

Field Summary
(package private)  AircraftRigidBody _airplane
          the rigid-body model of the aircraft
private  double _airspeedPrevious
          zzz
private  Vector _attitudeEulerPrevious
          the attitude velocity in Euler angles zzz
private  AircraftModelController _controller
          the controller interface that provides input to the flight-control surfaces
(package private)  AircraftRigidBodyElement[] _elements
          the mass, inertia, and lifting-surface properties of the rigid body
(package private)  boolean _isStalled
          whether any part of the wing is stalled
(package private)  boolean _isStalling
          whether any part of the wing is nearing a stall
(package private)  double _liftCoefficient
          the average coefficient of lift of the wing based on the flaps and ailerons
(package private)  int _stepNumber
          the current simulation step number
(package private)  double _thrust
          the thrust force in RPM, ranging from THRUST_MIN to THRUST_MAX, inclusively.
(package private)  Vector _thrustVector
          the thrust vector, which is assumed to act through the center of gravity of the plane
(package private)  Time _timeAbsolute
          the absolute running time in seconds
(package private)  Time _timeRelative
          the relative time in seconds from the previous simulation update
private  Vector _velocityPrevious
          the attitude velocity in Euler angles zzz
(package private) static int ELEMENT_AILERON_PORT
          the index of the finite element for the port aileron
(package private) static int ELEMENT_AILERON_STARBOARD
          the index of the finite element for the starboard aileron
(package private) static int ELEMENT_ELEVATOR_PORT
          the index of the finite element for the port elevator.
(package private) static int ELEMENT_ELEVATOR_STARBOARD
          the index of the finite element for the starboard elevator.
(package private) static int ELEMENT_FLAP_PORT
          the index of the finite element for the port flap.
(package private) static int ELEMENT_FLAP_STARBOARD
          the index of the finite element for the starboard flap.
(package private) static int ELEMENT_FUSELAGE
          the index of the finite element for the fuselage
(package private) static int ELEMENT_RUDDER
          the index of the finite element for the combined vertical stabilizer and rudder
static double ENCODED_UTM_TO_INTERNAL_SCALE
          the conversion factor between the UTM (Universal Transverse Mercator latitude/longitude) system of the world coordinates and the internal system for the flight-dynamics model zzz??? not quite; it's a scale on the UTM __encoding__
private static double G
          the gravitational acceleration constant is feet per second squared
static double IMMINENT_STALL_LIFT_COEFFICIENT
          the coefficient of lift corresponding to an imminent stall
private static double RHO
          the air density (units to be determined zzz???; see page 130)
 
Constructor Summary
AircraftModel(CoordinateWorld3D position, AttitudeYaw heading, Airspeed airspeed, RevolutionsPerMinute rpm)
          Creates an aircraft model.
 
Method Summary
private  void calculateAirspeedAcceleration()
          Calculates the instantaneous change in position per second squared.
private  void calculateAttitudeVelocityAndAcceleration()
          Calculates the instantaneous change in attitude in degrees per second.
private  double calculateCoefficientOfDragGeneral(double angleOfAttack, int controlSurfacePosition)
          Calculates the coefficient of drag on a horizontal control surface (flap, aileron, or elevator).
private  double calculateCoefficientOfDragRudder(double angleOfAttack)
          Calculates the coefficient of drag on a combined vertical stabilizer and rudder.
private  double calculateCoefficientOfLiftGeneral(double angleOfAttack, int controlSurfacePosition)
          Calculates the coefficient of lift on a horizontal control surface (flap, aileron, or elevator).
private  double calculateCoefficientOfLiftRudder(double angleOfAttack)
          Calculates the coefficient of lift on a combined vertical stabilizer and rudder.
private  void calculateLoads()
          Calculates all the forces and moments acting on the plane based on its current state.
private  void calculatePositionAcceleration()
          Calculates the instantaneous change in position per second squared.
private  double clamp(double value)
          Clamps a value to the interval [-1,+1].
private  void defineFiniteElements()
          Defines the discrete finite elements that together form the rigid-body model of the aircraft.
 AircraftModelController getController()
          Returns the controller interface that provides input to the flight-control surfaces.
private  void initialize(Vector position, double angleYaw, double airspeed, double rpm)
          Initializes the state of the airplane as indicated and configures its finite-element model.
private  double interpolate(double domainValue, double[] domain, double[] range, double offDomainValue)
          Interpolates a value in a two-dimensional table.
 void update(double deltaTime)
          Updates the simulation as a discrete-event time step by using Euler's method of approximation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_airplane

final AircraftRigidBody _airplane
the rigid-body model of the aircraft


_airspeedPrevious

private double _airspeedPrevious
zzz


_attitudeEulerPrevious

private Vector _attitudeEulerPrevious
the attitude velocity in Euler angles zzz


_controller

private final AircraftModelController _controller
the controller interface that provides input to the flight-control surfaces


_elements

final AircraftRigidBodyElement[] _elements
the mass, inertia, and lifting-surface properties of the rigid body


_isStalled

boolean _isStalled
whether any part of the wing is stalled


_isStalling

boolean _isStalling
whether any part of the wing is nearing a stall


_liftCoefficient

double _liftCoefficient
the average coefficient of lift of the wing based on the flaps and ailerons


_stepNumber

int _stepNumber
the current simulation step number


_thrust

double _thrust
the thrust force in RPM, ranging from THRUST_MIN to THRUST_MAX, inclusively. Technically, thrust is a function of RPM, but for simplicity, they are considered equivalent for this model because the thrust range in pounds conveniently corresponds to the RPM range


_thrustVector

Vector _thrustVector
the thrust vector, which is assumed to act through the center of gravity of the plane


_timeAbsolute

Time _timeAbsolute
the absolute running time in seconds


_timeRelative

Time _timeRelative
the relative time in seconds from the previous simulation update


_velocityPrevious

private Vector _velocityPrevious
the attitude velocity in Euler angles zzz


ELEMENT_AILERON_PORT

static final int ELEMENT_AILERON_PORT
the index of the finite element for the port aileron

See Also:
Constant Field Values

ELEMENT_AILERON_STARBOARD

static final int ELEMENT_AILERON_STARBOARD
the index of the finite element for the starboard aileron

See Also:
Constant Field Values

ELEMENT_ELEVATOR_PORT

static final int ELEMENT_ELEVATOR_PORT
the index of the finite element for the port elevator. Both elevators are always synchronized

See Also:
Constant Field Values

ELEMENT_ELEVATOR_STARBOARD

static final int ELEMENT_ELEVATOR_STARBOARD
the index of the finite element for the starboard elevator. Both elevators are always synchronized

See Also:
Constant Field Values

ELEMENT_FLAP_PORT

static final int ELEMENT_FLAP_PORT
the index of the finite element for the port flap. Both flaps are always synchronized

See Also:
Constant Field Values

ELEMENT_FLAP_STARBOARD

static final int ELEMENT_FLAP_STARBOARD
the index of the finite element for the starboard flap. Both flaps are always synchronized

See Also:
Constant Field Values

ELEMENT_FUSELAGE

static final int ELEMENT_FUSELAGE
the index of the finite element for the fuselage

See Also:
Constant Field Values

ELEMENT_RUDDER

static final int ELEMENT_RUDDER
the index of the finite element for the combined vertical stabilizer and rudder

See Also:
Constant Field Values

ENCODED_UTM_TO_INTERNAL_SCALE

public static final double ENCODED_UTM_TO_INTERNAL_SCALE
the conversion factor between the UTM (Universal Transverse Mercator latitude/longitude) system of the world coordinates and the internal system for the flight-dynamics model zzz??? not quite; it's a scale on the UTM __encoding__

See Also:
Constant Field Values

G

private static final double G
the gravitational acceleration constant is feet per second squared

See Also:
Constant Field Values

IMMINENT_STALL_LIFT_COEFFICIENT

public static final double IMMINENT_STALL_LIFT_COEFFICIENT
the coefficient of lift corresponding to an imminent stall

See Also:
Constant Field Values

RHO

private static final double RHO
the air density (units to be determined zzz???; see page 130)

See Also:
Constant Field Values
Constructor Detail

AircraftModel

public AircraftModel(CoordinateWorld3D position,
                     AttitudeYaw heading,
                     Airspeed airspeed,
                     RevolutionsPerMinute rpm)
Creates an aircraft model.

Parameters:
position - - the position
heading - - the heading
airspeed - - the airspeed
rpm - - the thrust in revolutions per minute. The range depends on the model configuration, but 0 to 2500 is reasonable
Method Detail

calculateAirspeedAcceleration

private void calculateAirspeedAcceleration()
Calculates the instantaneous change in position per second squared. zzz


calculateAttitudeVelocityAndAcceleration

private void calculateAttitudeVelocityAndAcceleration()
Calculates the instantaneous change in attitude in degrees per second. zzz


calculateCoefficientOfDragGeneral

private double calculateCoefficientOfDragGeneral(double angleOfAttack,
                                                 int controlSurfacePosition)
Calculates the coefficient of drag on a horizontal control surface (flap, aileron, or elevator). The drag table is based on a cambered airfoil with a plain trailing-edge flap having a +/- 15 degree deflection. Proportional input is not implemented yet.

Parameters:
angleOfAttack - - the angle of attack in degrees
controlSurfacePosition - - the control-surface position (-1,0,+1 for up, neutral, down, respectively)
Returns:
the coefficient

calculateCoefficientOfDragRudder

private double calculateCoefficientOfDragRudder(double angleOfAttack)
Calculates the coefficient of drag on a combined vertical stabilizer and rudder. The drag table is based on a symmetric (no camber) airfoil without flaps. In other words, the entire stabilizer rotates.

Parameters:
angleOfAttack - - the angle of attack in degrees
Returns:
the coefficient

calculateCoefficientOfLiftGeneral

private double calculateCoefficientOfLiftGeneral(double angleOfAttack,
                                                 int controlSurfacePosition)
Calculates the coefficient of lift on a horizontal control surface (flap, aileron, or elevator). The lift table is based on a cambered airfoil with a plain trailing-edge flap having a +/- 15 degree deflection. Proportional input is not implemented yet.

Parameters:
angleOfAttack - - the angle of attack in degrees
controlSurfacePosition - - (-1,0,+1 for up, neutral, down, respectively)
Returns:
the coefficient

calculateCoefficientOfLiftRudder

private double calculateCoefficientOfLiftRudder(double angleOfAttack)
Calculates the coefficient of lift on a combined vertical stabilizer and rudder. The lift table is based on a symmetric (no camber) airfoil without flaps. In other words, the entire stabilizer rotates.

Parameters:
angleOfAttack - - the angle of attack in degrees
Returns:
the coefficient

calculateLoads

private void calculateLoads()
Calculates all the forces and moments acting on the plane based on its current state.


calculatePositionAcceleration

private void calculatePositionAcceleration()
Calculates the instantaneous change in position per second squared. zzz


clamp

private double clamp(double value)
Clamps a value to the interval [-1,+1].

Parameters:
value - - the value
Returns:
the clamped value

defineFiniteElements

private void defineFiniteElements()
Defines the discrete finite elements that together form the rigid-body model of the aircraft.


getController

public AircraftModelController getController()
Returns the controller interface that provides input to the flight-control surfaces.

Returns:
the controller

initialize

private void initialize(Vector position,
                        double angleYaw,
                        double airspeed,
                        double rpm)
Initializes the state of the airplane as indicated and configures its finite-element model.

Parameters:
position - - encoded longitude as x, encoded latitude as y, and altitude as z in feet
angleYaw - - the yaw in mathematical degrees
airspeed - - the airspeed in feet per second
rpm - - the rpm

interpolate

private double interpolate(double domainValue,
                           double[] domain,
                           double[] range,
                           double offDomainValue)
Interpolates a value in a two-dimensional table. This is not a general-purpose interpolator because of the way it handles off-scale conditions.

Parameters:
domainValue - - the independent value
domain - - the domain of the independent value
range - - the range of the dependent value to find
offDomainValue - - the value to return if the independent value is off-scale low or high
Returns:
the interpolated dependent value

update

public void update(double deltaTime)
Updates the simulation as a discrete-event time step by using Euler's method of approximation.

Parameters:
deltaTime - - the change in time in seconds from the previous update. A reasonable value is around 0.0025.