ICAROUS
All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Modules Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
larcfm::AircraftState Class Reference

#include <AircraftState.h>

Inheritance diagram for larcfm::AircraftState:
larcfm::ErrorReporter

Public Member Functions

 AircraftState (const std::string &name, int buffer_size)
 
 AircraftState ()
 
 AircraftState (const std::string &id)
 
 AircraftState (const AircraftState &orig)
 
AircraftStateoperator= (const AircraftState &rhs)
 
std::string name () const
 
bool checkLatLon (bool ll) const
 
bool isLatLon () const
 
AircraftState copy () const
 
int getBufferSize () const
 
void clear ()
 
int find (double time) const
 
int size () const
 
void add (const Position &ss, const Velocity &vv, double tm)
 
StateVector get (int i)
 
StateVector getLast ()
 
const Positionposition (int i) const
 
const Velocityvelocity (int i) const
 
double time (int i) const
 
Position positionLast () const
 
Velocity velocityLast () const
 
double timeLast () const
 
void remove (int n)
 
void removeUpToTime (double time)
 
void removeLast ()
 
void setProjection (const EuclideanProjection &p)
 
void updateProjection ()
 
EuclideanProjection getProjection () const
 
StateVector pred (double t)
 
StateVector predLinear (double t)
 
Position positionLinear (double t) const
 
Velocity velocityAt (double t) const
 
bool inLevelFlight ()
 
double lastStraightTime () const
 
double trackRate (int i)
 
double timeLastZeroTrackRate ()
 
double avgTrackRate (int numPtsTrkRateCalc)
 
double avgVsRate (int numPtsVsRateCalc)
 
void prune ()
 
std::string dump () const
 
std::string toString () const
 
std::string toOutput () const
 
bool hasError () const
 
bool hasMessage () const
 
std::string getMessage ()
 
std::string getMessageNoClear () const
 

Static Public Member Functions

static bool closeEnough (Velocity v1, Velocity v2)
 

Static Public Attributes

static const int DEFAULT_BUFFER_SIZE = 10
 
static bool projectVelocity = true
 

Private Member Functions

void init (std::string name, int buffer_size)
 
void insertAt (int i, const Position &ss, const Velocity &vv, double tm)
 
void calc (Vect2 *vel2, double *velZ, double *timevar, int length)
 
Vect3 predS (double t) const
 
Velocity predV (double t) const
 
int ext2int (int i) const
 

Private Attributes

int bufferSize
 
int oldest
 
int sz
 
ErrorLog error
 
std::string id
 
Positions_list
 
Velocityv_list
 
double * t_list
 
EuclideanProjection sp
 
Vect2projS2
 
double * projH
 
Vect2projV2
 
double * projVZ
 
double * projT
 
bool projection_initialized
 
bool projection_done
 
bool regression_done
 
int recentInd
 
double horizvelintercept
 
double horizvelslope
 
double vertvelintercept
 
double vertvelslope
 
double ls_t
 
double ls_trk
 
double lastZeroTrackRateThreshold
 

Static Private Attributes

static double MAX_RELATIVE_DIFF = 0.10
 
static double minClimbVelocity = Units::from("fpm",150)
 

Detailed Description

This class captures a limited history of an aircraft's position and velocity.
This class essentially operates as an array, where the time field determines the order. It is intended that this method is called frequently and the oldest values are dropped. The maximum number of values stored is available through maxBufferSize(). The oldest value (that is, the smallest t) is always in element 0, the latest element (that is, the largest time) is always at index size() - 1.

The primary accessors are position() and velocity() which are indexed from 0 to size()-1. The latest values are located at size()-1.

The method get() will return a Euclidean projection of the position and velocity given the projection function in setProjection() or updateProjection(). Be careful: if you do not specifically indicate which projection to use, this class will make a choice for you, that is probably not what you expect.

In addition, this method can predict future points (currently this uses a quadratic regression approximation). These predictions are available through the methods pred(t), and predLinear(t). These are based on the Euclidean projected points.

Constructor & Destructor Documentation

◆ AircraftState() [1/3]

larcfm::AircraftState::AircraftState ( const std::string &  name,
int  buffer_size 
)

Construct a new object.

Parameters
namethe string name for this object
buffer_sizethe maximum number of data values that are stored in this object.

◆ AircraftState() [2/3]

larcfm::AircraftState::AircraftState ( )

Construct a new object with the default buffer size

◆ AircraftState() [3/3]

larcfm::AircraftState::AircraftState ( const std::string &  id)
explicit

Construct a new object with the default buffer size

Parameters
idAircraft identifier

Member Function Documentation

◆ add()

void larcfm::AircraftState::add ( const Position ss,
const Velocity vv,
double  tm 
)

Add a new position and velocity vector for the given time. If the given time is greater than any other time in the list, then this method will operate very fast. On the other hand, if the time is between some elements that already exist then the addition will be in the correct order, but may be fairly slow. If an element is added that matches another time, then this point overwrites the existing point.

Parameters
ssthe position at the given time
vvthe velocity at the given time
tmthe time of the position and velocity

◆ avgTrackRate()

double larcfm::AircraftState::avgTrackRate ( int  numPtsTrkRateCalc)

EXPERIMENTAL Estimate track rate from sequence of velocity vectors stored in this object. The sign of the track rate indicates the direction of the turn

Parameters
numPtsTrkRateCalcnumber of data points used in the average, must be at least 2
Returns
signed track rate (if insufficient number of points, return 0);

◆ avgVsRate()

double larcfm::AircraftState::avgVsRate ( int  numPtsVsRateCalc)

EXPERIMENTAL Estimate rate of change of vertical speed from sequence of velocity vectors stored in this object.
The sign of the vertical speed rate indicates the direction of the acceleration

Parameters
numPtsVsRateCalcnumber of data points used in the average, must be at least 2
Returns
signed vertical speed rate (if insufficient number of points, return 0);

EXPERIMENTAL Estimate rate of change of vertical speed from sequence of velocity vectors stored in this object. The sign of the vertical speed rate indicates the direction of the acceleration

Parameters
numPtsVsRateCalcnumber of data points used in the average, must be at least 2
Returns
signed vertical speed rate (if insufficient number of points, return 0);

◆ checkLatLon()

bool larcfm::AircraftState::checkLatLon ( bool  ll) const

If the parameter ll matches the current latlon (true for lat/lon/alt, false for Euclidean) value, then return true. If there are no positions in this object, then true is always returned.

Parameters
llvalue to check lat/lon status against
Returns
if ll agrees with the lat/lon status of this object

◆ clear()

void larcfm::AircraftState::clear ( )

Clear all data

◆ closeEnough()

bool larcfm::AircraftState::closeEnough ( Velocity  v1,
Velocity  v2 
)
static

Determines if these two velocities are "close" to each other

Parameters
v1velocity of one aircraft
v2velocity of another aircraft
Returns
true, if close

◆ copy()

AircraftState larcfm::AircraftState::copy ( ) const

return a deep copy of this object

Returns
the copy

◆ dump()

string larcfm::AircraftState::dump ( ) const

Return a debug string

Returns
string

◆ find()

int larcfm::AircraftState::find ( double  time) const

Return the index of the given time. A negative index is returned if the time doesn't exist.

Parameters
timetime
Returns
an index

◆ get()

StateVector larcfm::AircraftState::get ( int  i)

Return a Euclidean position and velocity for the given index. The position and velocity are projected into a Euclidean frame by the projection set by the setProjection() method. If the index is out of range (less than zero or greater than size()), then a zero position and velocity are returned.

Parameters
iindex
Returns
position and velocity at index i

◆ getBufferSize()

int larcfm::AircraftState::getBufferSize ( ) const

Return the maximum number of elements that can be stored.
This value is always greater or equal to size().
There is deliberately no method setBufferSize()

Returns
maximum number of elements

◆ getLast()

StateVector larcfm::AircraftState::getLast ( )

Return a Euclidean position and velocity for the latest time in this object. The position and velocity are projected into a Euclidean frame by the projection set by the setProjection() method.

Returns
last position and velocity

◆ getMessage()

std::string larcfm::AircraftState::getMessage ( )
inlinevirtual

Return a string representation of any errors or warnings. Calling this method will clear any messages and reset both the error and warning status to none.

Returns
error and warning messages. If there are no messages, an empty string is returned.

Implements larcfm::ErrorReporter.

◆ getMessageNoClear()

std::string larcfm::AircraftState::getMessageNoClear ( ) const
inlinevirtual

Return a string representation of any errors or warnings. Calling this method will not clear the error or warning status (i.e., hasError() will return the same value before and after this call.)

Returns
error and warning messages. If there are no messages, an empty string is returned.

Implements larcfm::ErrorReporter.

◆ getProjection()

EuclideanProjection larcfm::AircraftState::getProjection ( ) const

Return the current projection used in this AircraftState Be sure to note if the returned projection point has a zero altitude or not.

Returns
the current projection object

◆ hasError()

bool larcfm::AircraftState::hasError ( ) const
inlinevirtual

Does this object have an error?

Returns
true if there is an error.

Implements larcfm::ErrorReporter.

◆ hasMessage()

bool larcfm::AircraftState::hasMessage ( ) const
inlinevirtual

Does this object have an error or a warning?

Returns
true if there is an error or warning.

Implements larcfm::ErrorReporter.

◆ inLevelFlight()

bool larcfm::AircraftState::inLevelFlight ( )

Determines if the aircraft is almost in level flight

Returns
true, if in level flight

◆ isLatLon()

bool larcfm::AircraftState::isLatLon ( ) const
Returns
is lat/lon

◆ lastStraightTime()

double larcfm::AircraftState::lastStraightTime ( ) const

Last time when track rate was near zero

Returns
time

◆ name()

string larcfm::AircraftState::name ( ) const

Return the name of this object

Returns
name

◆ position()

const Position & larcfm::AircraftState::position ( int  i) const

The position for the given index. An index of 0 corresponds to the earliest time in this object; and index of size()-1 corresponds to the latest time. This method returns a "zero" position for an out of bounds index

◆ positionLast()

Position larcfm::AircraftState::positionLast ( ) const

The latest (i.e., last) position in this object. Note that this may not be synchronized with data from other aircraft! It is generally better to use positionLinear(tm) for traffic aircraft.

Returns
last position

◆ pred()

StateVector larcfm::AircraftState::pred ( double  t)

Return a predicted Euclidean position and velocity for the given time, based on an analysis of the history data. For accuracy, the time, t, should be close the latest time added to this class (accessed through the method timeLast()). The positions and velocities used are projected into a Euclidean frame by the projection set by the setProjection() method.

Parameters
ttime
Returns
position and velocity vector

◆ predLinear()

StateVector larcfm::AircraftState::predLinear ( double  t)

Return a predicted Euclidean position and velocity for the given time, based on a linear extrapolation from the most recent (relative to t) data point. For accuracy, the time, t, should be close the latest time added to this class (accessed through the method timeLast()). The positions and velocities used are projected into a Euclidean frame by the projection set by the setProjection() method.

A warning is generated if all data points are at times greater than t.

Parameters
ttime
Returns
position and velocity vector

◆ prune()

void larcfm::AircraftState::prune ( )

Throw away old points that have accelerations "significantly" different from the latest

◆ remove()

void larcfm::AircraftState::remove ( int  n)

remove oldest n entries

Parameters
nnumber of entries

◆ removeLast()

void larcfm::AircraftState::removeLast ( )

remove the latest (i.e. newest) data point

◆ removeUpToTime()

void larcfm::AircraftState::removeUpToTime ( double  time)

remove any data older than the given time

Parameters
timevalue of time

◆ setProjection()

void larcfm::AircraftState::setProjection ( const EuclideanProjection &  p)

Set the new projection, but do not do any calculations Note that altitudes will be preserved when using this projection – it should have a projection reference point with a zero altitude.

Parameters
pthe new projection object

◆ size()

int larcfm::AircraftState::size ( ) const

Return the number of data elements

Returns
size

◆ time()

double larcfm::AircraftState::time ( int  i) const

The time of the given index. An index of 0 corresponds to the earliest time in this object; and index of size()-1 corresponds to the latest time. This method returns a negative time for an out of bounds index

Parameters
iindex
Returns
time

◆ timeLast()

double larcfm::AircraftState::timeLast ( ) const

The latest (i.e., last) time in this object.

Returns
last time

◆ timeLastZeroTrackRate()

double larcfm::AircraftState::timeLastZeroTrackRate ( )

EXPERIMENTAL returns time when track rate was near zero. This method cannot return a value older than bufferSize. The companion method lastStraightTime is not as limited.

Returns
time

◆ toOutput()

string larcfm::AircraftState::toOutput ( ) const

Returns a string representation of this object compatible with StateReader

Returns
string

◆ toString()

string larcfm::AircraftState::toString ( ) const

Return a string representation of this object

Returns
string

◆ trackRate()

double larcfm::AircraftState::trackRate ( int  i)

Track Rate calculation

Parameters
iindex (0..size()-1)
Returns
track rate at ith data location

◆ updateProjection()

void larcfm::AircraftState::updateProjection ( )

Reproject all the points

◆ velocity()

const Velocity & larcfm::AircraftState::velocity ( int  i) const

The velocity for the given index. An index of 0 corresponds to the earliest time in this object; and index of size()-1 corresponds to the latest time. This method returns a zero velocity for an out of bounds index

◆ velocityAt()

Velocity larcfm::AircraftState::velocityAt ( double  t) const

Returns the velocity data from the most recent entry at or before time t.

Generates a warning and returns INVALID if there is no data.

Parameters
ttime
Returns
velocity

◆ velocityLast()

Velocity larcfm::AircraftState::velocityLast ( ) const

The latest (i.e., last) velocity in this object. Note that this may not be synchronized with data from other aircraft! It is generally better to use velocityBefore(tm) for traffic aircraft.

Returns
last velocity

Member Data Documentation

◆ DEFAULT_BUFFER_SIZE

const int larcfm::AircraftState::DEFAULT_BUFFER_SIZE = 10
static

The maximum number of history points this detector will allow

◆ MAX_RELATIVE_DIFF

double larcfm::AircraftState::MAX_RELATIVE_DIFF = 0.10
staticprivate

The percent difference in altitude that is assumed to be acceptable, used in prune()


The documentation for this class was generated from the following files: