uavsim.flightdynamicsmodel
Class AircraftModelController

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

public class AircraftModelController
extends java.lang.Object

Defines the basic inputs to the control surfaces of the aircraft, which in turn modify its state with respect to the flight-dynamics model.

Author:
Dan Tappan [21.08.11]

Field Summary
private  java.util.Queue<HistoryEntry<SevenDOFDescriptor>> _DOFHistory
          the restricted-length history queue for the degree-of-freedom state at each simulation update
private  AircraftModel _model
          the aircraft model
private static int HISTORY_WINDOW_LENGTH
          the number of history entries in the averaging window
static double THRUST_DELTA
          the step for incrementing and decrementing the thrust
static double THRUST_MAX
          the maximum thrust in RPM
static double THRUST_MIN
          the minimum thrust in RPM
 
Constructor Summary
AircraftModelController(AircraftModel model)
          Creates a controller for the aircraft.
 
Method Summary
(package private)  void addHistoryEntry()
          Records the current degree-of-freedom state containing 3D coordinate and attitude.
 boolean areFlapsExtended()
          Returns whether the flaps are fully extended.
 Course determineCourse()
          Calculates the current course as the average change of latitude and longitude over the history window.
 void determinePositionAcceleration()
          Calculates the change in position in zzz per second squared as the average over the history window.
 void determinePositionVelocity()
          Calculates the change in position in zzz per second as the average over the history window.
 void doAileronsDownUp()
          Deflects the port and starboard ailerons down and up a full 15 degrees, respectively.
 void doAileronsNeutral()
          Neutralizes the ailerons to 0 degrees.
 void doAileronsUpDown()
          Deflects the port and starboard ailerons up and down a full 15 degrees, respectively.
 void doAllInputsNeutral()
          Neutralizes the rudder, ailerons, and elevator.
 void doElevatorDown()
          Deflects the elevator down a full 15 degrees.
 void doElevatorNeutral()
          Neutralizes the elevator to 0 degrees.
 void doElevatorUp()
          Deflects the elevator up a full 15 degrees.
 void doFlapsExtend()
          Extends the flaps to a full 15 degrees.
 void doFlapsRetract()
          Retracts the flaps to 0 degrees.
 void doRudderLeft()
          Deflects the rudder left a full 15 degrees.
 void doRudderNeutral()
          Neutralizes the rudder right to 0 degrees.
 void doRudderRight()
          Deflects the rudder right a full 15 degrees.
 void doThrustDecrease()
          Decreases the thrust by THRUST_DELTA down to THRUST_MIN.
 void doThrustIncrease()
          Increases the thrust by THRUST_DELTA up to THRUST_MAX.
 void export(java.io.BufferedWriter outfile, boolean isHeaderIncluded)
          Exports the state of the model to a text file.
private  java.lang.String format(double value)
          Formats a number to four decimal places.
 Airspeed getAirspeed()
          Returns the airspeed.
 SevenDOFDescriptor getDOFDescriptor()
          Determines the current degree-of-freedom state.
 double getLiftCoefficient()
          Returns the current coefficient of lift.
 AircraftModel getModel()
          Returns the aircraft model.
 AircraftRigidBody getRigidBody()
          Returns a copy of the rigid body.
 RevolutionsPerMinute getRPM()
          Returns the current thrust as an absolute value on the interval [THRUST_MIN,THRUST_MAX].
 int getStepNumber()
          Returns the current simulation step number.
 double getThrustAbsolute()
          Returns the current thrust as an absolute value on the interval [THRUST_MIN,THRUST_MAX].
 double getThrustRelative()
          Returns the current thrust as a relative value on the interval [0,1], which corresponds to 0 to 100%.
 Vector getThrustVector()
          Returns the 3D vector of the thrust.
 Time getTimeAbsolute()
          Returns the absolute simulation time.
 Time getTimeRelative()
          Returns the relative simulation time since the last update.
 boolean isStalled()
          Returns whether the aircraft is fully stalled.
 boolean isStalling()
          Returns whether the aircraft is approaching a stall.
 void printState()
          Prints the state of the model to standard output.
 void setThrustAbsolute(double thrust)
          Sets the current thrust as an absolute value on the interval [THRUST_MIN,THRUST_MAX].
 void setThrustRelative(double thrustRatio)
          Set the current thrust as a relative value on the interval [0,1], which corresponds to 0 to 100%.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_DOFHistory

private final java.util.Queue<HistoryEntry<SevenDOFDescriptor>> _DOFHistory
the restricted-length history queue for the degree-of-freedom state at each simulation update


_model

private final AircraftModel _model
the aircraft model


HISTORY_WINDOW_LENGTH

private static final int HISTORY_WINDOW_LENGTH
the number of history entries in the averaging window

See Also:
Constant Field Values

THRUST_DELTA

public static final double THRUST_DELTA
the step for incrementing and decrementing the thrust

See Also:
Constant Field Values

THRUST_MAX

public static final double THRUST_MAX
the maximum thrust in RPM

See Also:
Constant Field Values

THRUST_MIN

public static final double THRUST_MIN
the minimum thrust in RPM

See Also:
Constant Field Values
Constructor Detail

AircraftModelController

public AircraftModelController(AircraftModel model)
Creates a controller for the aircraft.

Parameters:
model - - the aircraft model
Method Detail

addHistoryEntry

void addHistoryEntry()
Records the current degree-of-freedom state containing 3D coordinate and attitude.


areFlapsExtended

public boolean areFlapsExtended()
Returns whether the flaps are fully extended.
Proportional control is not implemented yet.

Returns:
the state

determineCourse

public Course determineCourse()
Calculates the current course as the average change of latitude and longitude over the history window.

Returns:
the course, with a default of north if no history is available yet

determinePositionAcceleration

public void determinePositionAcceleration()
Calculates the change in position in zzz per second squared as the average over the history window.


determinePositionVelocity

public void determinePositionVelocity()
Calculates the change in position in zzz per second as the average over the history window.


doAileronsDownUp

public void doAileronsDownUp()
Deflects the port and starboard ailerons down and up a full 15 degrees, respectively.
Proportional control is not implemented yet.


doAileronsNeutral

public void doAileronsNeutral()
Neutralizes the ailerons to 0 degrees.
Proportional control is not implemented yet.


doAileronsUpDown

public void doAileronsUpDown()
Deflects the port and starboard ailerons up and down a full 15 degrees, respectively.
Proportional control is not implemented yet.


doAllInputsNeutral

public void doAllInputsNeutral()
Neutralizes the rudder, ailerons, and elevator.


doElevatorDown

public void doElevatorDown()
Deflects the elevator down a full 15 degrees. The model defines the elevator as two control surfaces, but for semantic consistency, they are referred to in the singular because they always operate synchronized as one surface.
Proportional control is not implemented yet.


doElevatorNeutral

public void doElevatorNeutral()
Neutralizes the elevator to 0 degrees. The model defines the elevator as two control surfaces, but for semantic consistency, they are referred to in the singular because they always operate synchronized as one surface.
Proportional control is not implemented yet.


doElevatorUp

public void doElevatorUp()
Deflects the elevator up a full 15 degrees. The model defines the elevator as two control surfaces, but for semantic consistency, they are referred to in the singular because they always operate synchronized as one surface.
Proportional control is not implemented yet.


doFlapsExtend

public void doFlapsExtend()
Extends the flaps to a full 15 degrees.
Proportional or multi-position flaps are not implemented yet.


doFlapsRetract

public void doFlapsRetract()
Retracts the flaps to 0 degrees.
Proportional or multi-position flaps are not implemented yet.


doRudderLeft

public void doRudderLeft()
Deflects the rudder left a full 15 degrees.
Proportional or multi-position flaps are not implemented yet.


doRudderNeutral

public void doRudderNeutral()
Neutralizes the rudder right to 0 degrees.
Proportional or multi-position flaps are not implemented yet.


doRudderRight

public void doRudderRight()
Deflects the rudder right a full 15 degrees.
Proportional or multi-position flaps are not implemented yet.


doThrustDecrease

public void doThrustDecrease()
Decreases the thrust by THRUST_DELTA down to THRUST_MIN.


doThrustIncrease

public void doThrustIncrease()
Increases the thrust by THRUST_DELTA up to THRUST_MAX.


export

public void export(java.io.BufferedWriter outfile,
                   boolean isHeaderIncluded)
            throws java.io.IOException
Exports the state of the model to a text file.

Parameters:
outfile - - the outfile file
isHeaderIncluded - - whether to export the field headers first
Throws:
java.io.IOException - - if the export file cannot be written to

format

private java.lang.String format(double value)
Formats a number to four decimal places.

Parameters:
value - - the value
Returns:
the formatted value

getAirspeed

public Airspeed getAirspeed()
Returns the airspeed.

Returns:
the airspeed

getDOFDescriptor

public SevenDOFDescriptor getDOFDescriptor()
Determines the current degree-of-freedom state. The position and attitude are based directly on the latest update; the course is derived from the average change in position over the history window. If there is no history, course defaults to north.

Returns:
the descriptor

getLiftCoefficient

public double getLiftCoefficient()
Returns the current coefficient of lift.

Returns:
the coefficient

getModel

public AircraftModel getModel()
Returns the aircraft model.

Returns:
the model

getRigidBody

public AircraftRigidBody getRigidBody()
Returns a copy of the rigid body.

Returns:
the body

getRPM

public RevolutionsPerMinute getRPM()
Returns the current thrust as an absolute value on the interval [THRUST_MIN,THRUST_MAX]. xxx need set

Returns:
the thrust

getStepNumber

public int getStepNumber()
Returns the current simulation step number.

Returns:
the number

getThrustAbsolute

public double getThrustAbsolute()
Returns the current thrust as an absolute value on the interval [THRUST_MIN,THRUST_MAX].

Returns:
the thrust

getThrustRelative

public double getThrustRelative()
Returns the current thrust as a relative value on the interval [0,1], which corresponds to 0 to 100%.

Returns:
the thrust

getThrustVector

public Vector getThrustVector()
Returns the 3D vector of the thrust.

Returns:
the vector

getTimeAbsolute

public Time getTimeAbsolute()
Returns the absolute simulation time.

Returns:
the time in seconds

getTimeRelative

public Time getTimeRelative()
Returns the relative simulation time since the last update. This is based on the delta-time argument supplied to the update, not on any real-time clock.

Returns:
the time in seconds

isStalled

public boolean isStalled()
Returns whether the aircraft is fully stalled. If any of the lifting surfaces has a zero coefficient of lift, a full stall is assumed. There is no partial-stall condition, which precludes realistic spins.

Returns:
the state

isStalling

public boolean isStalling()
Returns whether the aircraft is approaching a stall. If any of the lifting surfaces has a coefficient of lift near zero, an imminent stall is assumed.

Returns:
the state
See Also:
AircraftModel.IMMINENT_STALL_LIFT_COEFFICIENT

printState

public void printState()
Prints the state of the model to standard output.


setThrustAbsolute

public void setThrustAbsolute(double thrust)
Sets the current thrust as an absolute value on the interval [THRUST_MIN,THRUST_MAX].

Parameters:
thrust - - the thrust

setThrustRelative

public void setThrustRelative(double thrustRatio)
Set the current thrust as a relative value on the interval [0,1], which corresponds to 0 to 100%.

Parameters:
thrustRatio - - the thrust ratio