uavsim.graphics.instruments.turncoordinator
Class TurnCoordinator

java.lang.Object
  extended by uavsim.graphics.instruments.A_Instrument
      extended by uavsim.graphics.instruments.A_CircularInstrument<GenericValue>
          extended by uavsim.graphics.instruments.turncoordinator.TurnCoordinator
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener, javax.swing.event.MouseInputListener, I_AngleMapper<GenericValue>

public class TurnCoordinator
extends A_CircularInstrument<GenericValue>

Defines a standard turn coordinator to depict rate of turn in degrees per second against a standard rate of three degrees per second. It also shows the slip/skid coordination ball.

Author:
Dan Tappan [20.06.11]

Field Summary
private  Airspeed _airspeed
          the airspeed
private  Attitude _attitude
          the attitude
private  Course _course
          the course
private static java.awt.Color AIRPLANE_COLOR
          the color of the airplane
private static Scaler AIRPLANE_DOT_SCALE
          the size scale of the airplane center dot relative to the instrument size
private static Scaler AIRPLANE_LINE_END_SCALE
          the position scale of the airplane wing lines relative to the instrument center
private static Scaler AIRPLANE_LINE_SCALE
          the weight scale of the airplane wing lines relative to the instrument size
private static double AIRPLANE_WING_DEVIATION
          an empirically determined coefficient to align the airplane wings with the rate of turn
private static Scaler ARC_INNER_RADIUS_SCALE
          the size scale of the arc inner radius relative to the instrument size
private static Scaler ARC_OUTER_RADIUS_SCALE
          the size scale of the arc outer radius relative to the instrument size
private static java.awt.Color BALL_COLOR
          the color of the slip/skid ball
private static AngleMathematical BALL_LINE_ANGLE_LEFT
          the angle of the left line of the ball cage
private static AngleMathematical BALL_LINE_ANGLE_RIGHT
          the angle of the right line of the ball cage
private static java.awt.Color BALL_LINE_COLOR
          the color of the coordination cage for the ball
private static Scaler BALL_LINE_SCALE
          the size scale of the ball line relative to the instrument size
private static Scaler BALL_SCALE
          the size scale of the ball relative to the instrument size
private static int BALL_SKEW_SCALE
          an empirically determined ratio to convert the coordination factor to the ball angle
private static double COORDINATION_YAW_SCALE
          an empirically determined coefficient to infer the coordination fraction from the yaw
private static double STANDARD_RATE
          the degrees per second in a standard-rate turn
private static double STANDARD_RATE_MAX
          the maximum clockwise degrees per second to depict
private static double STANDARD_RATE_MIN
          the maximum counterclockwise degrees per second to depict
private static AngleMathematical TICK_ANGLE_LEVEL_LEFT
          the left tick angle for level flight
private static AngleMathematical TICK_ANGLE_LEVEL_RIGHT
          the right tick angle for level flight
private static AngleMathematical TICK_ANGLE_STANDARD_LEFT
          the left tick angle for a standard-rate turn
private static AngleMathematical TICK_ANGLE_STANDARD_RIGHT
          the right tick angle for a standard-rate turn
private static java.awt.Color TICK_COLOR
          the color of the ticks
private static Scaler TICK_LINE_SCALE
          the size scale of the tick lines relative to the instrument size
private static java.awt.Color TUBE_COLOR
          the color of the ball tube
private static GenericValue TUBE_END_PADDING_NEGATIVE
          the angle-mapped arc interval for the start of the ball tube
private static GenericValue TUBE_END_PADDING_POSITIVE
          the angle-mapped arc interval for the end of the ball tube
private static Scaler TUBE_RADIUS_INNER_SCALE
          the size scale of the tube inner radius relative to the instrument size
private static Scaler TUBE_RADIUS_OUTER_SCALE
          the size scale of the tube outer radius relative to the instrument size
private static Scaler TUBE_RADIUS_POSITION_SCALE
          the position scale of the tube anchor relative to the instrument center
private static double UNCOORDINATION_MAX
          the maximum amount of positive uncoordination as a percent angle-mapped by a GenericValue
private static double UNCOORDINATION_MIN
          the maximum amount of negative uncoordination as a percent angle-mapped by a GenericValue
 
Fields inherited from class uavsim.graphics.instruments.A_CircularInstrument
_ringSize, DISK_COLOR, MOUNT_RING_COLOR, MOUNT_RING_INNER_SCALE
 
Fields inherited from class uavsim.graphics.instruments.A_Instrument
_canvasAnchor, _canvasSize, _graphics, _id
 
Constructor Summary
TurnCoordinator(java.lang.String id, int canvasSize, CoordinateCartesianAbsolute canvasAnchor)
          Creates a turn coordinator.
 
Method Summary
 double calculateTurnRateDegreesPerSecond()
          Gets the rate of turn as degrees per second based on the current bank angle and airspeed.
 double calculateTurnRateMultipleOfStandard()
          Gets the rate of turn as multiples of standard rate (three degrees per second) based on the current bank angle and airspeed.
private  double clampStandardRate(double degreesPerSecond)
          Clamps the rate of turn to the defined limits.
 Airspeed getAirspeed()
          Gets the airspeed in knots.
 Attitude getAttitude()
          Gets the attitude.
 double getCoordinationFraction()
          Gets the ratio of coordinated flight on the clamped interval [-1.0,+1.0], where 0 is coordinated, negative is ball left, and positive is ball right.
 Course getCourse()
          Gets the course.
private  double getYawDerived()
          Returns the derived yaw as the difference between the course and heading.
 AngleMathematical mapAngle_(GenericValue coordinationFraction)
          Returns the angle corresponding to the value of a unit.
 void render(java.awt.Graphics graphics)
          Renders the current state of the instrument.
private  void renderMiniaturePlane()
          Renders the miniature airplane.
private  void renderTicks()
          Renders the standard-rate ticks.
private  void renderTubeAndBall()
          Renders the slip/skid tube and ball.
 java.lang.String toString()
          
 void update(Attitude attitude, Course course, Airspeed airspeed)
          Updates the state of the instrument without rendering it.
 
Methods inherited from class uavsim.graphics.instruments.A_CircularInstrument
mapAngle, renderDisk, renderMountRing
 
Methods inherited from class uavsim.graphics.instruments.A_Instrument
getAnchor, getCanvasSize, getGraphics, getID, getParentComponent, handleControlCallback, hasControls, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, refresh, registerControl, setCanvasAnchor, setCanvasSize, setParentComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_airspeed

private Airspeed _airspeed
the airspeed


_attitude

private Attitude _attitude
the attitude


_course

private Course _course
the course


AIRPLANE_COLOR

private static final java.awt.Color AIRPLANE_COLOR
the color of the airplane


AIRPLANE_DOT_SCALE

private static final Scaler AIRPLANE_DOT_SCALE
the size scale of the airplane center dot relative to the instrument size


AIRPLANE_LINE_END_SCALE

private static final Scaler AIRPLANE_LINE_END_SCALE
the position scale of the airplane wing lines relative to the instrument center


AIRPLANE_LINE_SCALE

private static final Scaler AIRPLANE_LINE_SCALE
the weight scale of the airplane wing lines relative to the instrument size


AIRPLANE_WING_DEVIATION

private static final double AIRPLANE_WING_DEVIATION
an empirically determined coefficient to align the airplane wings with the rate of turn

See Also:
Constant Field Values

ARC_INNER_RADIUS_SCALE

private static final Scaler ARC_INNER_RADIUS_SCALE
the size scale of the arc inner radius relative to the instrument size


ARC_OUTER_RADIUS_SCALE

private static final Scaler ARC_OUTER_RADIUS_SCALE
the size scale of the arc outer radius relative to the instrument size


BALL_COLOR

private static final java.awt.Color BALL_COLOR
the color of the slip/skid ball


BALL_LINE_ANGLE_LEFT

private static final AngleMathematical BALL_LINE_ANGLE_LEFT
the angle of the left line of the ball cage


BALL_LINE_ANGLE_RIGHT

private static final AngleMathematical BALL_LINE_ANGLE_RIGHT
the angle of the right line of the ball cage


BALL_LINE_COLOR

private static final java.awt.Color BALL_LINE_COLOR
the color of the coordination cage for the ball


BALL_LINE_SCALE

private static final Scaler BALL_LINE_SCALE
the size scale of the ball line relative to the instrument size


BALL_SCALE

private static final Scaler BALL_SCALE
the size scale of the ball relative to the instrument size


BALL_SKEW_SCALE

private static final int BALL_SKEW_SCALE
an empirically determined ratio to convert the coordination factor to the ball angle

See Also:
Constant Field Values

COORDINATION_YAW_SCALE

private static final double COORDINATION_YAW_SCALE
an empirically determined coefficient to infer the coordination fraction from the yaw

See Also:
Constant Field Values

STANDARD_RATE

private static final double STANDARD_RATE
the degrees per second in a standard-rate turn

See Also:
Constant Field Values

STANDARD_RATE_MAX

private static final double STANDARD_RATE_MAX
the maximum clockwise degrees per second to depict

See Also:
Constant Field Values

STANDARD_RATE_MIN

private static final double STANDARD_RATE_MIN
the maximum counterclockwise degrees per second to depict

See Also:
Constant Field Values

TICK_ANGLE_LEVEL_LEFT

private static final AngleMathematical TICK_ANGLE_LEVEL_LEFT
the left tick angle for level flight


TICK_ANGLE_LEVEL_RIGHT

private static final AngleMathematical TICK_ANGLE_LEVEL_RIGHT
the right tick angle for level flight


TICK_ANGLE_STANDARD_LEFT

private static final AngleMathematical TICK_ANGLE_STANDARD_LEFT
the left tick angle for a standard-rate turn


TICK_ANGLE_STANDARD_RIGHT

private static final AngleMathematical TICK_ANGLE_STANDARD_RIGHT
the right tick angle for a standard-rate turn


TICK_COLOR

private static final java.awt.Color TICK_COLOR
the color of the ticks


TICK_LINE_SCALE

private static final Scaler TICK_LINE_SCALE
the size scale of the tick lines relative to the instrument size


TUBE_COLOR

private static final java.awt.Color TUBE_COLOR
the color of the ball tube


TUBE_END_PADDING_NEGATIVE

private static final GenericValue TUBE_END_PADDING_NEGATIVE
the angle-mapped arc interval for the start of the ball tube


TUBE_END_PADDING_POSITIVE

private static final GenericValue TUBE_END_PADDING_POSITIVE
the angle-mapped arc interval for the end of the ball tube


TUBE_RADIUS_INNER_SCALE

private static final Scaler TUBE_RADIUS_INNER_SCALE
the size scale of the tube inner radius relative to the instrument size


TUBE_RADIUS_OUTER_SCALE

private static final Scaler TUBE_RADIUS_OUTER_SCALE
the size scale of the tube outer radius relative to the instrument size


TUBE_RADIUS_POSITION_SCALE

private static final Scaler TUBE_RADIUS_POSITION_SCALE
the position scale of the tube anchor relative to the instrument center


UNCOORDINATION_MAX

private static final double UNCOORDINATION_MAX
the maximum amount of positive uncoordination as a percent angle-mapped by a GenericValue

See Also:
Constant Field Values

UNCOORDINATION_MIN

private static final double UNCOORDINATION_MIN
the maximum amount of negative uncoordination as a percent angle-mapped by a GenericValue

See Also:
Constant Field Values
Constructor Detail

TurnCoordinator

public TurnCoordinator(java.lang.String id,
                       int canvasSize,
                       CoordinateCartesianAbsolute canvasAnchor)
Creates a turn coordinator.

Parameters:
id - - the unique instrument identifier
canvasSize - - the square size of the instrument footprint in pixels
canvasAnchor - - the anchor position for the center of the canvas in pixels
Method Detail

calculateTurnRateDegreesPerSecond

public double calculateTurnRateDegreesPerSecond()
Gets the rate of turn as degrees per second based on the current bank angle and airspeed.

Returns:
the rate

calculateTurnRateMultipleOfStandard

public double calculateTurnRateMultipleOfStandard()
Gets the rate of turn as multiples of standard rate (three degrees per second) based on the current bank angle and airspeed. It clamps the multiple to [-4.5,+4.5].

Returns:
the multiple

clampStandardRate

private double clampStandardRate(double degreesPerSecond)
Clamps the rate of turn to the defined limits.

Parameters:
degreesPerSecond - - the rate
Returns:
the clamped rate

getAirspeed

public Airspeed getAirspeed()
Gets the airspeed in knots.

Returns:
the airspeed.

getAttitude

public Attitude getAttitude()
Gets the attitude.

Returns:
the attitude

getCoordinationFraction

public double getCoordinationFraction()
Gets the ratio of coordinated flight on the clamped interval [-1.0,+1.0], where 0 is coordinated, negative is ball left, and positive is ball right. The approximation is based on the derived yaw.

Returns:
the fraction

getCourse

public Course getCourse()
Gets the course.

Returns:
the course

getYawDerived

private double getYawDerived()
Returns the derived yaw as the difference between the course and heading. This approximation is not entirely justified, but its behavior is reasonable.

Returns:
the yaw

mapAngle_

public AngleMathematical mapAngle_(GenericValue coordinationFraction)
Returns the angle corresponding to the value of a unit.

Parameters:
coordinationFraction - - the unit
Returns:
the angle

render

public void render(java.awt.Graphics graphics)
Renders the current state of the instrument.

Overrides:
render in class A_CircularInstrument<GenericValue>
Parameters:
graphics - - the graphics context

renderMiniaturePlane

private void renderMiniaturePlane()
Renders the miniature airplane.


renderTicks

private void renderTicks()
Renders the standard-rate ticks.


renderTubeAndBall

private void renderTubeAndBall()
Renders the slip/skid tube and ball.


toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

update

public void update(Attitude attitude,
                   Course course,
                   Airspeed airspeed)
Updates the state of the instrument without rendering it.

Parameters:
attitude - - the attitude
course - - the course
airspeed - - the airspeed