Exemple #1
0
    def __init__(self, navdb):
        self.wind = WindSim()

        # Define the periodic loggers
        # ToDo: explain what these line sdo in comments (type of logs?)
        datalog.definePeriodicLogger('SNAPLOG', 'SNAPLOG logfile.',
                                     settings.snapdt)
        datalog.definePeriodicLogger('INSTLOG', 'INSTLOG logfile.',
                                     settings.instdt)
        datalog.definePeriodicLogger('SKYLOG', 'SKYLOG logfile.',
                                     settings.skydt)

        with RegisterElementParameters(self):

            # Register the following parameters for logging
            with datalog.registerLogParameters('SNAPLOG', self):
                # Aircraft Info
                self.id = []  # identifier (string)
                self.type = []  # aircaft type (string)

                # Positions
                self.lat = np.array([])  # latitude [deg]
                self.lon = np.array([])  # longitude [deg]
                self.alt = np.array([])  # altitude [m]
                self.hdg = np.array([])  # traffic heading [deg]
                self.trk = np.array([])  # track angle [deg]

                # Velocities
                self.tas = np.array([])  # true airspeed [m/s]
                self.gs = np.array([])  # ground speed [m/s]
                self.gsnorth = np.array([])  # ground speed [m/s]
                self.gseast = np.array([])  # ground speed [m/s]
                self.cas = np.array([])  # calibrated airspeed [m/s]
                self.M = np.array([])  # mach number
                self.vs = np.array([])  # vertical speed [m/s]

                # Atmosphere
                self.p = np.array([])  # air pressure [N/m2]
                self.rho = np.array([])  # air density [kg/m3]
                self.Temp = np.array([])  # air temperature [K]
                self.dtemp = np.array([])  # delta t for non-ISA conditions

                # Traffic autopilot settings
                self.aspd = np.array([])  # selected spd(CAS) [m/s]
                self.aptas = np.array([])  # just for initializing
                self.ama = np.array(
                    [])  # selected spd above crossover altitude (Mach) [-]
                self.apalt = np.array([])  # selected alt[m]
                self.avs = np.array([])  # selected vertical speed [m/s]

            # Whether to perform LNAV and VNAV
            self.swlnav = np.array([], dtype=np.bool)
            self.swvnav = np.array([], dtype=np.bool)

            # Flight Models
            self.asas = ASAS(self)
            self.ap = Autopilot(self)
            self.pilot = Pilot(self)
            self.adsb = ADSB(self)
            self.trails = Trails(self)
            self.actwp = ActiveWaypoint(self)

            # Traffic performance data
            self.avsdef = np.array(
                [])  # [m/s]default vertical speed of autopilot
            self.aphi = np.array([])  # [rad] bank angle setting of autopilot
            self.ax = np.array(
                [])  # [m/s2] absolute value of longitudinal accelleration
            self.bank = np.array([])  # nominal bank angle, [radian]
            self.hdgsel = np.array(
                [], dtype=np.bool)  # determines whether aircraft is turning

            # Crossover altitude
            self.abco = np.array([])
            self.belco = np.array([])

            # limit settings
            self.limspd = np.array([])  # limit speed
            self.limspd_flag = np.array(
                [], dtype=np.bool
            )  # flag for limit spd - we have to test for max and min
            self.limalt = np.array([])  # limit altitude
            self.limvs = np.array(
                [])  # limit vertical speed due to thrust limitation
            self.limvs_flag = np.array([])

            # Display information on label
            self.label = []  # Text and bitmap of traffic label

            # Miscallaneous
            self.coslat = np.array([])  # Cosine of latitude for computations
            self.eps = np.array([])  # Small nonzero numbers

        # Default bank angles per flight phase
        self.bphase = np.deg2rad(np.array([15, 35, 35, 35, 15, 45]))

        self.reset(navdb)