dasher
Class CAutoSpeedControl

java.lang.Object
  extended by dasher.CDasherComponent
      extended by dasher.CAutoSpeedControl

public class CAutoSpeedControl
extends CDasherComponent

AutoSpeedControl is responsible for adaptively tuning Dasher's maximum speed by observing user actions whilst dashing.

At present it is only used by DefaultFilter.

Its mode of action essentially involves observing how 'eratically' the user is behaving, something quantised by the angle they tend to move at compared to due East (in a left-to-right configuration).

A more scientific description can be found in dasher/Doc/speedcontrol.tex in the original Dasher source distribution, available from www.dasher.org.uk


Field Summary
protected  double m_dBitrate
          Current maximum speed.
protected  double m_dChange1
          Fractional changes to speed which can be used to control speed.
protected  double m_dChange2
          Fractional changes to speed which can be used to control speed.
protected  double m_dChange3
          Fractional changes to speed which can be used to control speed.
protected  double m_dChange4
          Fractional changes to speed which can be used to control speed.
protected  java.util.LinkedList<java.lang.Double> m_dequeAngles
          List of the previous angles observed.
protected  double m_dMinRadius
          Variables for adaptive radius calculations
protected  double m_dMinRRate
          Controls rate at which MinRadius is adapted; higher means slower.
protected  double m_dSampleOffset
          TODO Find out what this does
protected  double m_dSampleScale
          TODO Find out what this does
protected  double m_dSensitivity
          Currently unused; may be used to tune the sensitivity of auto speed-control in the future.
protected  double m_dSigma1
          Variables for adaptive radius calculations
protected  double m_dSigma2
          Variables for adaptive radius calculations
protected  double m_dSpeedMax
          Maximum and minimum speed limits
protected  double m_dSpeedMin
          Maximum and minimum speed limits
protected  double m_dTier1
          Critical points in user's movement angle variance.
protected  double m_dTier2
          Critical points in user's movement angle variance.
protected  double m_dTier3
          Critical points in user's movement angle variance.
protected  double m_dTier4
          Critical points in user's movement angle variance.
protected  int m_nSpeedCounter
          How many samples have been taken to date
protected  int m_nSpeedSamples
          Maximum number of samples to take
 
Fields inherited from class dasher.CDasherComponent
m_EventHandler, m_SettingsStore
 
Constructor Summary
CAutoSpeedControl(CEventHandler EventHandler, CSettingsStore SettingsStore, double dFrameRate)
          Creates a new speed controller configured with a sample size appropriate to the reported frame rate.
 
Method Summary
protected  double round(double dVal)
          Rounds a double to the nearest integer without casting to an integer type.
 void SpeedControl(long iDasherX, long iDasherY, double dFrameRate, CDasherView View)
          AUTOMATIC SPEED CONTROL, CEH 7/05: Analyse variance of angle mouse position makes with +ve x-axis in Dasher-space.
protected  double UpdateBitrate()
          Updates the current dasher speed according to the current variance in the user's angle of attack.
protected  double UpdateMinRadius()
          Finds adaptive minimum radius for auto-speed control.
protected  int UpdateSampleSize(double dFrameRate)
          Determines the number of speed samples to take into account, based on the current frame rate and the user's movement rate.
 void UpdateSigmas(double r, double dFrameRate)
          Updates VARIANCES of two populations of mixture-of-2-centred-Gaussians model!
protected  double Variance()
          Finds the variance in the user's angle of movement.
 
Methods inherited from class dasher.CDasherComponent
GetBoolParameter, GetLongParameter, GetParameterName, GetParameterType, GetStringParameter, HandleEvent, InsertEvent, SetBoolParameter, SetLongParameter, SetStringParameter, UnregisterComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_dBitrate

protected double m_dBitrate
Current maximum speed.


m_dSampleScale

protected double m_dSampleScale
TODO Find out what this does


m_dSampleOffset

protected double m_dSampleOffset
TODO Find out what this does


m_nSpeedCounter

protected int m_nSpeedCounter
How many samples have been taken to date


m_nSpeedSamples

protected int m_nSpeedSamples
Maximum number of samples to take


m_dSpeedMax

protected double m_dSpeedMax
Maximum and minimum speed limits


m_dSpeedMin

protected double m_dSpeedMin
Maximum and minimum speed limits


m_dTier1

protected double m_dTier1
Critical points in user's movement angle variance.


m_dTier2

protected double m_dTier2
Critical points in user's movement angle variance.


m_dTier3

protected double m_dTier3
Critical points in user's movement angle variance.


m_dTier4

protected double m_dTier4
Critical points in user's movement angle variance.


m_dChange1

protected double m_dChange1
Fractional changes to speed which can be used to control speed.

Tier 4 represents the greatest change, so we must have 1 < 2 < 3 < 4.


m_dChange2

protected double m_dChange2
Fractional changes to speed which can be used to control speed.

Tier 4 represents the greatest change, so we must have 1 < 2 < 3 < 4.


m_dChange3

protected double m_dChange3
Fractional changes to speed which can be used to control speed.

Tier 4 represents the greatest change, so we must have 1 < 2 < 3 < 4.


m_dChange4

protected double m_dChange4
Fractional changes to speed which can be used to control speed.

Tier 4 represents the greatest change, so we must have 1 < 2 < 3 < 4.


m_dMinRRate

protected double m_dMinRRate
Controls rate at which MinRadius is adapted; higher means slower.


m_dSensitivity

protected double m_dSensitivity
Currently unused; may be used to tune the sensitivity of auto speed-control in the future.


m_dequeAngles

protected java.util.LinkedList<java.lang.Double> m_dequeAngles
List of the previous angles observed.


m_dSigma1

protected double m_dSigma1
Variables for adaptive radius calculations


m_dSigma2

protected double m_dSigma2
Variables for adaptive radius calculations


m_dMinRadius

protected double m_dMinRadius
Variables for adaptive radius calculations

Constructor Detail

CAutoSpeedControl

public CAutoSpeedControl(CEventHandler EventHandler,
                         CSettingsStore SettingsStore,
                         double dFrameRate)
Creates a new speed controller configured with a sample size appropriate to the reported frame rate.

Parameters:
EventHandler - Event handler to dispatch and received events.
SettingsStore - Settings store to retrieve and set settings.
dFrameRate - Initial frame rate, in FPS.
Method Detail

UpdateBitrate

protected double UpdateBitrate()
Updates the current dasher speed according to the current variance in the user's angle of attack. Essentially, we compare their variance to the m_dTier variables, and multiply by the corresponding m_dChange in the case that they are above or below it.

Also caps the new speed at SpeedMin and SpeedMax.

Returns:
New calculated speed.

Variance

protected double Variance()
Finds the variance in the user's angle of movement.

Returns:
Variance

UpdateSampleSize

protected int UpdateSampleSize(double dFrameRate)
Determines the number of speed samples to take into account, based on the current frame rate and the user's movement rate.

Parameters:
dFrameRate - Current frame rate
Returns:
Recommended number of samples

UpdateMinRadius

protected double UpdateMinRadius()
Finds adaptive minimum radius for auto-speed control. Calculated by DJCM's mixture-of-2-centred-gaussians model.

Returns:
New minimum radius.

UpdateSigmas

public void UpdateSigmas(double r,
                         double dFrameRate)
Updates VARIANCES of two populations of mixture-of-2-centred-Gaussians model!

Parameters:
r - Current minimum radius
dFrameRate - Current Dasher frame rate in FPS

SpeedControl

public void SpeedControl(long iDasherX,
                         long iDasherY,
                         double dFrameRate,
                         CDasherView View)
AUTOMATIC SPEED CONTROL, CEH 7/05: Analyse variance of angle mouse position makes with +ve x-axis in Dasher-space.

SpeedControl alters the LP_MAX_BITRATE parameter to reflect the perceived user's need.

Parameters:
iDasherX - User's current mouse position in Dasher co-ordinates
iDasherY - User's current mouse position in Dasher co-ordinates
dFrameRate - Current Dasher frame rate in FPS
View - Current DasherView, used to ascertain the user's true mouse position.

round

protected double round(double dVal)
Rounds a double to the nearest integer without casting to an integer type.

Parameters:
dVal - Value to round
Returns:
Nearest integer (as an FP value)