:py:mod:`pycasx.acas` ===================== .. py:module:: pycasx.acas .. autoapi-nested-parse:: Main module to calculate advisories. Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 acasx/index.rst hcas/index.rst runner/index.rst vcas/index.rst Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: pycasx.acas.NNet pycasx.acas.HCASAdvisories pycasx.acas.VCASAdvisories pycasx.acas.HCASStateVariables pycasx.acas.VCASStateVariables pycasx.acas.Aircraft pycasx.acas.Intruder pycasx.acas.ACASXProtocol pycasx.acas.AdvisoryDict pycasx.acas.SystemInfo pycasx.acas.RootInfo pycasx.acas.APIHCASStateVariables pycasx.acas.APIVCASStateVariables pycasx.acas.AutoavoidInfo pycasx.acas.ExtendedAircraft pycasx.acas.ExtendedIntruder Functions ~~~~~~~~~ .. autoapisummary:: pycasx.acas.check_for_loss_of_separation pycasx.acas.extend_intruder Attributes ~~~~~~~~~~ .. autoapisummary:: pycasx.acas.ModelDict pycasx.acas.Quantity pycasx.acas.DEFAULT_MODEL_PATH pycasx.acas.DEFAULT_HCAS_MODEL_PATH pycasx.acas.DEFAULT_VCAS_MODEL_PATH pycasx.acas.ureg pycasx.acas.HCAS_ACTIONS pycasx.acas.VCAS_ACTIONS .. py:class:: NNet(filename) Class that represents a fully connected ReLU network from a .nnet file. :param filename: A .nnet file to load :type filename: str .. attribute:: numLayers Number of weight matrices or bias vectors in neural network :type: int .. attribute:: layerSizes Size of input layer, hidden layers, and output layer :type: list of ints .. attribute:: inputSize Size of input :type: int .. attribute:: outputSize Size of output :type: int .. attribute:: mins Minimum values of inputs :type: list of floats .. attribute:: maxes Maximum values of inputs :type: list of floats .. attribute:: means Means of inputs and mean of outputs :type: list of floats .. attribute:: ranges Ranges of inputs and range of outputs :type: list of floats .. attribute:: weights Weight matrices in network :type: list of numpy arrays .. attribute:: biases Bias vectors in network :type: list of numpy arrays .. py:method:: evaluate_network(inputs) Evaluate network using given inputs. :param inputs: Network inputs to be evaluated :type inputs: numpy array of floats :returns: Network output :rtype: (numpy array of floats) .. py:method:: evaluate_network_multiple(inputs) Evaluate network using multiple sets of inputs. :param inputs: Array of network inputs to be evaluated. :type inputs: numpy array of floats :returns: Network outputs for each set of inputs :rtype: (numpy array of floats) .. py:method:: num_inputs() Get network input size. .. py:method:: num_outputs() Get network output size. .. py:data:: ModelDict :type: typing_extensions.TypeAlias .. py:data:: Quantity :type: typing_extensions.TypeAlias .. py:data:: DEFAULT_MODEL_PATH .. py:data:: DEFAULT_HCAS_MODEL_PATH .. py:data:: DEFAULT_VCAS_MODEL_PATH .. py:data:: ureg .. py:function:: 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. :param ac_1: The first aircraft. :type ac_1: Aircraft :param ac_2: The second aircraft. :type ac_2: Aircraft :param h_lim: The horizontal separation limit. :type h_lim: Quantity :param v_lim: The vertical separation limit. :type v_lim: Quantity :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). :rtype: tuple[bool, bool] :raises ValueError: Raised if the horizontal separation is not a length or the vertical separation is not a length. .. py:class:: HCASAdvisories Bases: :py:obj:`enum.IntEnum` The advisories of the HCAS model. .. attribute:: INOP inoperative .. attribute:: OFF off .. attribute:: ACTIVE active .. attribute:: COC clear of conflict .. attribute:: WL weak left .. attribute:: WR weak right .. attribute:: SL strong left .. attribute:: SR strong right .. py:attribute:: INOP .. py:attribute:: OFF .. py:attribute:: ACTIVE .. py:attribute:: COC :value: 0 .. py:attribute:: WL :value: 1 .. py:attribute:: WR :value: 2 .. py:attribute:: SL :value: 3 .. py:attribute:: SR :value: 4 .. py:class:: VCASAdvisories Bases: :py:obj:`enum.IntEnum` The advisories of the VCAS model. .. attribute:: INOP inoperative .. attribute:: OFF off .. attribute:: ACTIVE active .. attribute:: COC clear of conflict .. attribute:: DNC do not climb .. attribute:: DND do not descend .. attribute:: DES1500 descend >=1500 ft/min .. attribute:: CL1500 climb >=1500 ft/min .. attribute:: SDES1500 strengthen descend to >=1500 ft/min .. attribute:: SCL1500 strengthen climb to >=1500 ft/min .. attribute:: SDES2500 strengthen descend to >=2500 ft/min .. attribute:: SCL2500 strengthen climb to >=2500 ft/min .. py:attribute:: INOP .. py:attribute:: OFF .. py:attribute:: ACTIVE .. py:attribute:: COC :value: 0 .. py:attribute:: DNC :value: 1 .. py:attribute:: DND :value: 2 .. py:attribute:: DES1500 :value: 3 .. py:attribute:: CL1500 :value: 4 .. py:attribute:: SDES1500 :value: 5 .. py:attribute:: SCL1500 :value: 6 .. py:attribute:: SDES2500 :value: 7 .. py:attribute:: SCL2500 :value: 8 .. py:class:: HCASStateVariables The state variables of the HCAS model. .. attribute:: rho range to intruder, measured in feet. :type: Quantity .. attribute:: theta bearing angle to intruder, measured in degrees. :type: Quantity .. attribute:: psi relative heading angle of intruder, measured in degrees. :type: Quantity .. attribute:: v_own ownship speed, measured in feet per second. :type: Quantity .. attribute:: v_int intruder speed, measured in feet per second. :type: Quantity .. attribute:: tau time to loss of vertical separation, measured in seconds. :type: Quantity .. attribute:: s_adv previous advisory. :type: HCASAdvisories .. py:attribute:: rho :type: Quantity .. py:attribute:: theta :type: Quantity .. py:attribute:: psi :type: Quantity .. py:attribute:: v_own :type: Quantity .. py:attribute:: v_int :type: Quantity .. py:attribute:: tau :type: Quantity .. py:attribute:: s_adv :type: HCASAdvisories .. py:class:: VCASStateVariables The state variables of the VCAS model. .. attribute:: h relative intruder altitude, measured in feet. :type: Quantity .. attribute:: hdot_own ownship vertical rate, measured in feet per minute. :type: Quantity .. attribute:: hdot_int intruder vertical rate, measured in feet per minute. :type: Quantity .. attribute:: tau time to loss of horizontal separation, measured in seconds. :type: Quantity .. attribute:: s_adv previous advisory. :type: VCASAdvisories .. py:attribute:: h :type: Quantity .. py:attribute:: hdot_own :type: Quantity .. py:attribute:: hdot_int :type: Quantity .. py:attribute:: tau :type: Quantity .. py:attribute:: s_adv :type: VCASAdvisories .. py:class:: 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. .. attribute:: call_sign The call_sign of the aircraft. :type: str .. attribute:: altitude The aircraft's current altitude, measured in feet. :type: Quantity .. attribute:: vertical_speed The aircraft's current vertical speed, measured in feet per second. :type: Quantity .. attribute:: true_airspeed The aircraft's current true airspeed, measured in knots. :type: Quantity .. attribute:: heading The aircraft's current heading, measured in degrees. :type: Quantity .. attribute:: latitude The aircraft's current latitude, measured in degrees. :type: Quantity .. attribute:: longitude The aircraft's current longitude, measured in degrees. :type: Quantity .. py:attribute:: call_sign :type: str .. py:attribute:: altitude :type: Quantity .. py:attribute:: vertical_speed :type: Quantity .. py:attribute:: true_airspeed :type: Quantity .. py:attribute:: heading :type: Quantity .. py:attribute:: latitude :type: Quantity .. py:attribute:: longitude :type: Quantity .. py:class:: Intruder An intruder representation relying also on advisory data. .. attribute:: aircraft The aircraft data. :type: Aircraft .. attribute:: hcas_advisory The HCAS advisory. :type: HCASAdvisories .. attribute:: vcas_advisory The VCAS advisory. :type: VCASAdvisories .. attribute:: hcas_state_variables The HCAS state with respect to the ownship. :type: HCASStateVariables .. attribute:: vcas_state_variables The VCAS state with respect to the ownship. :type: VCASStateVariables .. py:property:: triggers_nmac :type: 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. :rtype: bool .. py:attribute:: aircraft :type: Aircraft .. py:attribute:: hcas_advisory :type: HCASAdvisories .. py:attribute:: vcas_advisory :type: VCASAdvisories .. py:attribute:: hcas_state_variables :type: HCASStateVariables .. py:attribute:: vcas_state_variables :type: VCASStateVariables .. py:class:: ACASXProtocol Bases: :py:obj:`Protocol` Protocol for an ACAS X model. Provides crucial typing info for the mixin classes. .. py:property:: model_dict :type: dict[str, Any] The dictionary of models. .. py:property:: ownship :type: Aircraft The ownship's state. .. py:method:: evaluate(model_name, inputs) Evaluate a CAS model. :param model_name: Name of the model to evaluate from the model dictionary. :type model_name: str :param inputs: The inputs to the model. :type inputs: npt.NDArray[np.float32] :returns: The outputs of the model. :rtype: npt.NDArray[np.float32] :raises NotImplementedError: Raised if the requested backend is not implemented. .. py:data:: HCAS_ACTIONS :type: dict[HCASAdvisories, float | str | None] .. py:data:: VCAS_ACTIONS :type: dict[VCASAdvisories, float | str | None] .. py:class:: AdvisoryDict Bases: :py:obj:`typing_extensions.TypedDict` The advisory dictionary. .. attribute:: value The advisory value. :type: int .. attribute:: name The advisory name. :type: str .. py:attribute:: value :type: int .. py:attribute:: name :type: str .. py:class:: SystemInfo Bases: :py:obj:`typing_extensions.TypedDict` The information about a CAS system. .. attribute:: advisory The advisory information. :type: AdvisoryDict .. attribute:: connector The connector name. :type: str .. attribute:: timestamp The timestamp of the information. :type: float .. py:attribute:: advisory :type: AdvisoryDict .. py:attribute:: connector :type: Literal[adsb] .. py:attribute:: timestamp :type: float .. py:class:: RootInfo Bases: :py:obj:`typing_extensions.TypedDict` The information all CAS systems. .. attribute:: hcas The HCAS information. :type: SystemInfo .. attribute:: vcas The VCAS information. :type: SystemInfo .. attribute:: timestamp The timestamp of the information. :type: float .. py:attribute:: hcas :type: SystemInfo .. py:attribute:: vcas :type: SystemInfo .. py:attribute:: timestamp :type: float .. py:class:: APIHCASStateVariables The state variables of the HCAS model. .. attribute:: rho range to intruder, measured in feet. :type: float .. attribute:: theta bearing angle to intruder, measured in degrees. :type: float .. attribute:: psi relative heading angle of intruder, measured in degrees. :type: float .. attribute:: v_own ownship speed, measured in feet per second. :type: float .. attribute:: v_int intruder speed, measured in feet per second. :type: float .. attribute:: tau time to loss of vertical separation, measured in seconds. :type: float .. attribute:: s_adv previous advisory. :type: HCASAdvisories .. py:attribute:: rho :type: float .. py:attribute:: theta :type: float .. py:attribute:: psi :type: float .. py:attribute:: v_own :type: float .. py:attribute:: v_int :type: float .. py:attribute:: tau :type: float .. py:attribute:: s_adv :type: HCASAdvisories .. py:class:: APIVCASStateVariables The state variables of the VCAS model. .. attribute:: h relative intruder altitude, measured in feet. :type: float .. attribute:: hdot_own ownship vertical rate, measured in feet per minute. :type: float .. attribute:: hdot_int intruder vertical rate, measured in feet per minute. :type: float .. attribute:: tau time to loss of horizontal separation, measured in seconds. :type: float .. attribute:: s_adv previous advisory. :type: VCASAdvisories .. py:attribute:: h :type: float .. py:attribute:: hdot_own :type: float .. py:attribute:: hdot_int :type: float .. py:attribute:: tau :type: float .. py:attribute:: s_adv :type: VCASAdvisories .. py:class:: AutoavoidInfo An extended aircraft representation including the current timestamp. .. attribute:: active Whether autoavoid is active. :type: bool .. attribute:: mode The autoavoid mode to use. :type: Optional[Literal["hcas", "vcas"]] .. attribute:: action The action to take. :type: Optional[float] .. attribute:: command The command issued to FlightGear. :type: Optional[float] .. attribute:: timestamp The timestamp of the information. :type: float .. py:attribute:: active :type: bool .. py:attribute:: mode :type: Literal[hcas, vcas] | None .. py:attribute:: action :type: float | None .. py:attribute:: command :type: float | None .. py:attribute:: timestamp :type: float .. py:class:: ExtendedAircraft An extended aircraft representation including the current timestamp. .. attribute:: call_sign The call_sign of the aircraft. :type: str .. attribute:: altitude The aircraft's current altitude, measured in feet. :type: float .. attribute:: vertical_speed The aircraft's current vertical speed, measured in feet per second. :type: float .. attribute:: true_airspeed The aircraft's current true airspeed, measured in knots. :type: float .. attribute:: heading The aircraft's current heading, measured in degrees. :type: float .. attribute:: latitude The aircraft's current latitude, measured in degrees. :type: float .. attribute:: longitude The aircraft's current longitude, measured in degrees. :type: float .. attribute:: timestamp The timestamp of the information. :type: float .. py:attribute:: call_sign :type: str .. py:attribute:: altitude :type: float .. py:attribute:: vertical_speed :type: float .. py:attribute:: true_airspeed :type: float .. py:attribute:: heading :type: float .. py:attribute:: latitude :type: float .. py:attribute:: longitude :type: float .. py:attribute:: timestamp :type: float .. py:class:: ExtendedIntruder An extended intruder representation relying also on advisory data. .. attribute:: aircraft The aircraft data. :type: Aircraft .. attribute:: triggers_nmac Whether the intruder triggers a near mid-air collision for the ownship. :type: bool .. attribute:: hcas_advisory The HCAS advisory. :type: HCASAdvisories .. attribute:: vcas_advisory The VCAS advisory. :type: VCASAdvisories .. attribute:: hcas_state_variables The HCAS state with respect to the ownship. :type: HCASStateVariables .. attribute:: vcas_state_variables The VCAS state with respect to the ownship. :type: VCASStateVariables .. attribute:: timestamp The timestamp of the information. :type: float .. py:attribute:: aircraft :type: ExtendedAircraft .. py:attribute:: triggers_nmac :type: bool .. py:attribute:: hcas_advisory :type: HCASAdvisories .. py:attribute:: vcas_advisory :type: VCASAdvisories .. py:attribute:: hcas_state_variables :type: APIHCASStateVariables .. py:attribute:: vcas_state_variables :type: APIVCASStateVariables .. py:attribute:: timestamp :type: float .. py:function:: extend_intruder(intruder) Extend the intruder with additional information. This will make the intruder JSON serializable and add the `triggers_nmac` attribute. :param intruder: The intruder to extend. :type intruder: Intruder :returns: The extended intruder. :rtype: ExtendedIntruder