ICAROUS
|
#include <AircraftState.h>
Public Member Functions | |
AircraftState (const std::string &name, int buffer_size) | |
AircraftState () | |
AircraftState (const std::string &id) | |
AircraftState (const AircraftState &orig) | |
AircraftState & | operator= (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 Position & | position (int i) const |
const Velocity & | velocity (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 |
Position * | s_list |
Velocity * | v_list |
double * | t_list |
EuclideanProjection | sp |
Vect2 * | projS2 |
double * | projH |
Vect2 * | projV2 |
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) |
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.
larcfm::AircraftState::AircraftState | ( | const std::string & | name, |
int | buffer_size | ||
) |
Construct a new object.
name | the string name for this object |
buffer_size | the maximum number of data values that are stored in this object. |
larcfm::AircraftState::AircraftState | ( | ) |
Construct a new object with the default buffer size
|
explicit |
Construct a new object with the default buffer size
id | Aircraft identifier |
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.
ss | the position at the given time |
vv | the velocity at the given time |
tm | the time of the position and velocity |
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
numPtsTrkRateCalc | number of data points used in the average, must be at least 2 |
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
numPtsVsRateCalc | number of data points used in the average, must be at least 2 |
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
numPtsVsRateCalc | number of data points used in the average, must be at least 2 |
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.
ll | value to check lat/lon status against |
void larcfm::AircraftState::clear | ( | ) |
Clear all data
Determines if these two velocities are "close" to each other
v1 | velocity of one aircraft |
v2 | velocity of another aircraft |
AircraftState larcfm::AircraftState::copy | ( | ) | const |
return a deep copy of this object
string larcfm::AircraftState::dump | ( | ) | const |
Return a debug string
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.
time | time |
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.
i | index |
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()
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.
|
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.
Implements larcfm::ErrorReporter.
|
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.)
Implements larcfm::ErrorReporter.
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.
|
inlinevirtual |
|
inlinevirtual |
Does this object have an error or a warning?
Implements larcfm::ErrorReporter.
bool larcfm::AircraftState::inLevelFlight | ( | ) |
Determines if the aircraft is almost in level flight
bool larcfm::AircraftState::isLatLon | ( | ) | const |
double larcfm::AircraftState::lastStraightTime | ( | ) | const |
Last time when track rate was near zero
string larcfm::AircraftState::name | ( | ) | const |
Return the name of this object
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
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.
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.
t | time |
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.
t | time |
void larcfm::AircraftState::prune | ( | ) |
Throw away old points that have accelerations "significantly" different from the latest
void larcfm::AircraftState::remove | ( | int | n | ) |
remove oldest n entries
n | number of entries |
void larcfm::AircraftState::removeLast | ( | ) |
remove the latest (i.e. newest) data point
void larcfm::AircraftState::removeUpToTime | ( | double | time | ) |
remove any data older than the given time
time | value of time |
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.
p | the new projection object |
int larcfm::AircraftState::size | ( | ) | const |
Return the number of data elements
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
i | index |
double larcfm::AircraftState::timeLast | ( | ) | const |
The latest (i.e., last) time in this object.
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.
string larcfm::AircraftState::toOutput | ( | ) | const |
Returns a string representation of this object compatible with StateReader
string larcfm::AircraftState::toString | ( | ) | const |
Return a string representation of this object
double larcfm::AircraftState::trackRate | ( | int | i | ) |
void larcfm::AircraftState::updateProjection | ( | ) |
Reproject all the points
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
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.
t | time |
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.
|
static |
The maximum number of history points this detector will allow
|
staticprivate |
The percent difference in altitude that is assumed to be acceptable, used in prune()