pycasx.acas

Main module to calculate advisories.

Submodules

Package Contents

Classes

NNet

Class that represents a fully connected ReLU network from a .nnet file.

HCASAdvisories

The advisories of the HCAS model.

VCASAdvisories

The advisories of the VCAS model.

HCASStateVariables

The state variables of the HCAS model.

VCASStateVariables

The state variables of the VCAS model.

Aircraft

A generic aircraft class to save important state information.

Intruder

An intruder representation relying also on advisory data.

ACASXProtocol

Protocol for an ACAS X model.

AdvisoryDict

The advisory dictionary.

SystemInfo

The information about a CAS system.

RootInfo

The information all CAS systems.

APIHCASStateVariables

The state variables of the HCAS model.

APIVCASStateVariables

The state variables of the VCAS model.

AutoavoidInfo

An extended aircraft representation including the current timestamp.

ExtendedAircraft

An extended aircraft representation including the current timestamp.

ExtendedIntruder

An extended intruder representation relying also on advisory data.

Functions

check_for_loss_of_separation(ac_1, ac_2[, h_lim, v_lim])

Checks whether two aircraft will lose separation.

extend_intruder(intruder)

Extend the intruder with additional information.

Attributes

ModelDict

Quantity

DEFAULT_MODEL_PATH

DEFAULT_HCAS_MODEL_PATH

DEFAULT_VCAS_MODEL_PATH

ureg

HCAS_ACTIONS

VCAS_ACTIONS

class pycasx.acas.NNet(filename)

Class that represents a fully connected ReLU network from a .nnet file.

Parameters:

filename (str) – A .nnet file to load

numLayers

Number of weight matrices or bias vectors in neural network

Type:

int

layerSizes

Size of input layer, hidden layers, and output layer

Type:

list of ints

inputSize

Size of input

Type:

int

outputSize

Size of output

Type:

int

mins

Minimum values of inputs

Type:

list of floats

maxes

Maximum values of inputs

Type:

list of floats

means

Means of inputs and mean of outputs

Type:

list of floats

ranges

Ranges of inputs and range of outputs

Type:

list of floats

weights

Weight matrices in network

Type:

list of numpy arrays

biases

Bias vectors in network

Type:

list of numpy arrays

evaluate_network(inputs)

Evaluate network using given inputs.

Parameters:

inputs (numpy array of floats) – Network inputs to be evaluated

Returns:

Network output

Return type:

(numpy array of floats)

evaluate_network_multiple(inputs)

Evaluate network using multiple sets of inputs.

Parameters:

inputs (numpy array of floats) – Array of network inputs to be evaluated.

Returns:

Network outputs for each set of inputs

Return type:

(numpy array of floats)

num_inputs()

Get network input size.

Return type:

int

num_outputs()

Get network output size.

Return type:

int

pycasx.acas.ModelDict: typing_extensions.TypeAlias
pycasx.acas.Quantity: typing_extensions.TypeAlias
pycasx.acas.DEFAULT_MODEL_PATH
pycasx.acas.DEFAULT_HCAS_MODEL_PATH
pycasx.acas.DEFAULT_VCAS_MODEL_PATH
pycasx.acas.ureg
pycasx.acas.check_for_loss_of_separation(ac_1, ac_2, h_lim=500 * ureg.feet, v_lim=100 * ureg.feet)

Checks whether two aircraft will lose separation.

This function determines whether two aircraft will lose separation based on their current positions and speeds. The function assumes that the aircraft are flying in a straight line without changes in speed or direction.

Parameters:
  • ac_1 (Aircraft) – The first aircraft.

  • ac_2 (Aircraft) – The second aircraft.

  • h_lim (Quantity) – The horizontal separation limit.

  • v_lim (Quantity) – The vertical separation limit.

Returns:

A tuple of two booleans. The first boolean

indicates whether the aircraft will lose horizontal separation, the second boolean indicates whether the aircraft will lose vertical separation (True if possible collision is detected).

Return type:

tuple[bool, bool]

Raises:

ValueError – Raised if the horizontal separation is not a length or the vertical separation is not a length.

class pycasx.acas.HCASAdvisories

Bases: enum.IntEnum

The advisories of the HCAS model.

INOP

inoperative

OFF

off

ACTIVE

active

COC

clear of conflict

WL

weak left

WR

weak right

SL

strong left

SR

strong right

INOP
OFF
ACTIVE
COC = 0
WL = 1
WR = 2
SL = 3
SR = 4
class pycasx.acas.VCASAdvisories

Bases: enum.IntEnum

The advisories of the VCAS model.

INOP

inoperative

OFF

off

ACTIVE

active

COC

clear of conflict

DNC

do not climb

DND

do not descend

DES1500

descend >=1500 ft/min

CL1500

climb >=1500 ft/min

SDES1500

strengthen descend to >=1500 ft/min

SCL1500

strengthen climb to >=1500 ft/min

SDES2500

strengthen descend to >=2500 ft/min

SCL2500

strengthen climb to >=2500 ft/min

INOP
OFF
ACTIVE
COC = 0
DNC = 1
DND = 2
DES1500 = 3
CL1500 = 4
SDES1500 = 5
SCL1500 = 6
SDES2500 = 7
SCL2500 = 8
class pycasx.acas.HCASStateVariables

The state variables of the HCAS model.

rho

range to intruder, measured in feet.

Type:

Quantity

theta

bearing angle to intruder, measured in degrees.

Type:

Quantity

psi

relative heading angle of intruder, measured in degrees.

Type:

Quantity

v_own

ownship speed, measured in feet per second.

Type:

Quantity

v_int

intruder speed, measured in feet per second.

Type:

Quantity

tau

time to loss of vertical separation, measured in seconds.

Type:

Quantity

s_adv

previous advisory.

Type:

HCASAdvisories

rho: Quantity
theta: Quantity
psi: Quantity
v_own: Quantity
v_int: Quantity
tau: Quantity
s_adv: HCASAdvisories
class pycasx.acas.VCASStateVariables

The state variables of the VCAS model.

h

relative intruder altitude, measured in feet.

Type:

Quantity

hdot_own

ownship vertical rate, measured in feet per minute.

Type:

Quantity

hdot_int

intruder vertical rate, measured in feet per minute.

Type:

Quantity

tau

time to loss of horizontal separation, measured in seconds.

Type:

Quantity

s_adv

previous advisory.

Type:

VCASAdvisories

h: Quantity
hdot_own: Quantity
hdot_int: Quantity
tau: Quantity
s_adv: VCASAdvisories
class pycasx.acas.Aircraft

A generic aircraft class to save important state information.

Although this dataclass relies on Pint for unit handling, default units are given in the docstring for each attribute.

call_sign

The call_sign of the aircraft.

Type:

str

altitude

The aircraft’s current altitude, measured in feet.

Type:

Quantity

vertical_speed

The aircraft’s current vertical speed, measured in feet per second.

Type:

Quantity

true_airspeed

The aircraft’s current true airspeed, measured in knots.

Type:

Quantity

heading

The aircraft’s current heading, measured in degrees.

Type:

Quantity

latitude

The aircraft’s current latitude, measured in degrees.

Type:

Quantity

longitude

The aircraft’s current longitude, measured in degrees.

Type:

Quantity

call_sign: str
altitude: Quantity
vertical_speed: Quantity
true_airspeed: Quantity
heading: Quantity
latitude: Quantity
longitude: Quantity
class pycasx.acas.Intruder

An intruder representation relying also on advisory data.

aircraft

The aircraft data.

Type:

Aircraft

hcas_advisory

The HCAS advisory.

Type:

HCASAdvisories

vcas_advisory

The VCAS advisory.

Type:

VCASAdvisories

hcas_state_variables

The HCAS state with respect to the ownship.

Type:

HCASStateVariables

vcas_state_variables

The VCAS state with respect to the ownship.

Type:

VCASStateVariables

property triggers_nmac: bool

Whether the intruder triggers a near mid-air collision for the ownship.

A near mid-air collision (NMAC) is defined as a loss of separation between two aircraft that endangers the safety of the aircraft involved. The boundary for a NMAC is defined as 500 ft horizontally and 100 ft vertically.

Returns:

Whether the intruder triggers a NMAC.

Return type:

bool

aircraft: Aircraft
hcas_advisory: HCASAdvisories
vcas_advisory: VCASAdvisories
hcas_state_variables: HCASStateVariables
vcas_state_variables: VCASStateVariables
class pycasx.acas.ACASXProtocol

Bases: Protocol

Protocol for an ACAS X model.

Provides crucial typing info for the mixin classes.

property model_dict: dict[str, Any]

The dictionary of models.

Return type:

dict[str, Any]

property ownship: Aircraft

The ownship’s state.

Return type:

Aircraft

evaluate(model_name, inputs)

Evaluate a CAS model.

Parameters:
  • model_name (str) – Name of the model to evaluate from the model dictionary.

  • inputs (npt.NDArray[np.float32]) – The inputs to the model.

Returns:

The outputs of the model.

Return type:

npt.NDArray[np.float32]

Raises:

NotImplementedError – Raised if the requested backend is not implemented.

pycasx.acas.HCAS_ACTIONS: dict[HCASAdvisories, float | str | None]
pycasx.acas.VCAS_ACTIONS: dict[VCASAdvisories, float | str | None]
class pycasx.acas.AdvisoryDict

Bases: typing_extensions.TypedDict

The advisory dictionary.

value

The advisory value.

Type:

int

name

The advisory name.

Type:

str

value: int
name: str
class pycasx.acas.SystemInfo

Bases: typing_extensions.TypedDict

The information about a CAS system.

advisory

The advisory information.

Type:

AdvisoryDict

connector

The connector name.

Type:

str

timestamp

The timestamp of the information.

Type:

float

advisory: AdvisoryDict
connector: Literal[adsb]
timestamp: float
class pycasx.acas.RootInfo

Bases: typing_extensions.TypedDict

The information all CAS systems.

hcas

The HCAS information.

Type:

SystemInfo

vcas

The VCAS information.

Type:

SystemInfo

timestamp

The timestamp of the information.

Type:

float

hcas: SystemInfo
vcas: SystemInfo
timestamp: float
class pycasx.acas.APIHCASStateVariables

The state variables of the HCAS model.

rho

range to intruder, measured in feet.

Type:

float

theta

bearing angle to intruder, measured in degrees.

Type:

float

psi

relative heading angle of intruder, measured in degrees.

Type:

float

v_own

ownship speed, measured in feet per second.

Type:

float

v_int

intruder speed, measured in feet per second.

Type:

float

tau

time to loss of vertical separation, measured in seconds.

Type:

float

s_adv

previous advisory.

Type:

HCASAdvisories

rho: float
theta: float
psi: float
v_own: float
v_int: float
tau: float
s_adv: HCASAdvisories
class pycasx.acas.APIVCASStateVariables

The state variables of the VCAS model.

h

relative intruder altitude, measured in feet.

Type:

float

hdot_own

ownship vertical rate, measured in feet per minute.

Type:

float

hdot_int

intruder vertical rate, measured in feet per minute.

Type:

float

tau

time to loss of horizontal separation, measured in seconds.

Type:

float

s_adv

previous advisory.

Type:

VCASAdvisories

h: float
hdot_own: float
hdot_int: float
tau: float
s_adv: VCASAdvisories
class pycasx.acas.AutoavoidInfo

An extended aircraft representation including the current timestamp.

active

Whether autoavoid is active.

Type:

bool

mode

The autoavoid mode to use.

Type:

Optional[Literal[“hcas”, “vcas”]]

action

The action to take.

Type:

Optional[float]

command

The command issued to FlightGear.

Type:

Optional[float]

timestamp

The timestamp of the information.

Type:

float

active: bool
mode: Literal[hcas, vcas] | None
action: float | None
command: float | None
timestamp: float
class pycasx.acas.ExtendedAircraft

An extended aircraft representation including the current timestamp.

call_sign

The call_sign of the aircraft.

Type:

str

altitude

The aircraft’s current altitude, measured in feet.

Type:

float

vertical_speed

The aircraft’s current vertical speed, measured in feet per second.

Type:

float

true_airspeed

The aircraft’s current true airspeed, measured in knots.

Type:

float

heading

The aircraft’s current heading, measured in degrees.

Type:

float

latitude

The aircraft’s current latitude, measured in degrees.

Type:

float

longitude

The aircraft’s current longitude, measured in degrees.

Type:

float

timestamp

The timestamp of the information.

Type:

float

call_sign: str
altitude: float
vertical_speed: float
true_airspeed: float
heading: float
latitude: float
longitude: float
timestamp: float
class pycasx.acas.ExtendedIntruder

An extended intruder representation relying also on advisory data.

aircraft

The aircraft data.

Type:

Aircraft

triggers_nmac

Whether the intruder triggers a near mid-air collision for the ownship.

Type:

bool

hcas_advisory

The HCAS advisory.

Type:

HCASAdvisories

vcas_advisory

The VCAS advisory.

Type:

VCASAdvisories

hcas_state_variables

The HCAS state with respect to the ownship.

Type:

HCASStateVariables

vcas_state_variables

The VCAS state with respect to the ownship.

Type:

VCASStateVariables

timestamp

The timestamp of the information.

Type:

float

aircraft: ExtendedAircraft
triggers_nmac: bool
hcas_advisory: HCASAdvisories
vcas_advisory: VCASAdvisories
hcas_state_variables: APIHCASStateVariables
vcas_state_variables: APIVCASStateVariables
timestamp: float
pycasx.acas.extend_intruder(intruder)

Extend the intruder with additional information.

This will make the intruder JSON serializable and add the triggers_nmac attribute.

Parameters:

intruder (Intruder) – The intruder to extend.

Returns:

The extended intruder.

Return type:

ExtendedIntruder