How to use the bluesky.traf.asas function in bluesky

To help you get started, we’ve selected a few bluesky examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TUDelft-CNS-ATM / bluesky / bluesky / ui / pygame / screen.py View on Github external
isymb = int(round((bs.traf.hdg[i] - self.ndcrs) / 6.)) % 60
                pos = self.acsymbol[isymb].get_rect()

                # Draw aircraft symbol
                pos.centerx = trafx[i]
                pos.centery = trafy[i]
                dy = int(self.fontrad.linedy * 7 / 6)

                # Draw aircraft altitude line
                if self.isoalt>1e-7:
                    pg.draw.line(self.win,white,(int(trafx[i]),int(trafy[i])),(int(trafx[i]),int(trafy[i]+bs.traf.alt[i]*self.isoalt)))

                # Normal symbol if no conflict else amber
                toosmall=self.lat1-self.lat0>6 #don't draw circles if zoomed out too much

                if not bs.traf.asas.inconf[i]:
                    self.win.blit(self.acsymbol[isymb], pos)
                    if self.swsep and not toosmall:
                        pg.draw.circle(self.win,green,(int(trafx[i]),int(trafy[i])),pixelrad,1)
                else:
                    self.win.blit(self.ambacsymbol[isymb], pos)
                    if self.swsep and not toosmall:
                        pg.draw.circle(self.win,amber,(int(trafx[i]),int(trafy[i])),pixelrad,1)


                # Draw last trail part
                if bs.traf.trails.active:
                    pg.draw.line(self.win, tuple(bs.traf.trails.accolor[i]),
                                 (ltx[i], lty[i]), (trafx[i], trafy[i]))

                # Label text
                label = []
github TUDelft-CNS-ATM / bluesky / bluesky / simulation / screenio.py View on Github external
data['tcpamax'] = bs.traf.asas.tcpamax
        data['nconf_cur'] = len(bs.traf.asas.confpairs_unique)
        data['nconf_tot'] = len(bs.traf.asas.confpairs_all)
        data['nlos_cur'] = len(bs.traf.asas.lospairs_unique)
        data['nlos_tot'] = len(bs.traf.asas.lospairs_all)
        data['trk']        = bs.traf.trk
        data['vs']         = bs.traf.vs
        data['vmin']       = bs.traf.asas.vmin
        data['vmax']       = bs.traf.asas.vmax

        # Transition level as defined in traf
        data['translvl']   = bs.traf.translvl

        # ASAS resolutions for visualization. Only send when evaluated
        if bs.traf.asas.asaseval:
            data['asasn']  = bs.traf.asas.asasn
            data['asase']  = bs.traf.asas.asase
        else:
            data['asasn']  = np.zeros(bs.traf.ntraf, dtype=np.float32)
            data['asase']  = np.zeros(bs.traf.ntraf, dtype=np.float32)

        # Trails, send only new line segments to be added
        data['swtrails'] = bs.traf.trails.active
        data['traillat0'] = bs.traf.trails.newlat0
        data['traillon0'] = bs.traf.trails.newlon0
        data['traillat1'] = bs.traf.trails.newlat1
        data['traillon1'] = bs.traf.trails.newlon1
        bs.traf.trails.clearnew()

        # Last segment which is being built per aircraft
        data['traillastlat'] = bs.traf.trails.lastlat
        data['traillastlon'] = bs.traf.trails.lastlon
github TUDelft-CNS-ATM / bluesky / bluesky / simulation / screenio.py View on Github external
def send_aircraft_data(self):
        data = dict()
        data['simt']       = bs.sim.simt
        data['id']         = bs.traf.id
        data['lat']        = bs.traf.lat
        data['lon']        = bs.traf.lon
        data['alt']        = bs.traf.alt
        data['tas']        = bs.traf.tas
        data['cas']        = bs.traf.cas
        data['gs']         = bs.traf.gs
        data['ingroup']    = bs.traf.groups.ingroup
        data['inconf'] = bs.traf.asas.inconf
        data['tcpamax'] = bs.traf.asas.tcpamax
        data['nconf_cur'] = len(bs.traf.asas.confpairs_unique)
        data['nconf_tot'] = len(bs.traf.asas.confpairs_all)
        data['nlos_cur'] = len(bs.traf.asas.lospairs_unique)
        data['nlos_tot'] = len(bs.traf.asas.lospairs_all)
        data['trk']        = bs.traf.trk
        data['vs']         = bs.traf.vs
        data['vmin']       = bs.traf.asas.vmin
        data['vmax']       = bs.traf.asas.vmax

        # Transition level as defined in traf
        data['translvl']   = bs.traf.translvl

        # ASAS resolutions for visualization. Only send when evaluated
        if bs.traf.asas.asaseval:
            data['asasn']  = bs.traf.asas.asasn
            data['asase']  = bs.traf.asas.asase
        else:
            data['asasn']  = np.zeros(bs.traf.ntraf, dtype=np.float32)
            data['asase']  = np.zeros(bs.traf.ntraf, dtype=np.float32)
github TUDelft-CNS-ATM / bluesky / bluesky / stack / stack.py View on Github external
"DTLOOK": [
            "DTLOOK [time]",
            "[float]",
            bs.traf.asas.SetDtLook,
            "Set lookahead time in seconds for conflict detection",
        ],
        "DTMULT": [
            "DTMULT multiplier",
            "float",
            bs.sim.set_dtmult,
            "Sel multiplication factor for fast-time simulation",
        ],
        "DTNOLOOK": [
            "DTNOLOOK [time]",
            "[float]",
            bs.traf.asas.SetDtNoLook,
            "Set interval for conflict detection",
        ],
        "DUMPRTE": [
            "DUMPRTE acid",
            "acid",
            lambda idx: bs.traf.ap.route[idx].dumpRoute(idx),
            "Write route to output/routelog.txt",
        ],
        "ECHO": [
            "ECHO txt",
            "string",
            bs.scr.echo,
            "Show a text in command window for user to read",
        ],
        "ENG": [
            "ENG acid,[engine_id]",
github TUDelft-CNS-ATM / bluesky / plugins / metrics.py View on Github external
def update(self):
        self.sectorsd = np.zeros(len(self.sectors))
        self.sectorconv = np.zeros(len(self.sectors))
        self.sectoreff = []
        if not traf.ntraf or not self.sectors:
            return

        # Check convergence using CD with large RPZ and tlook
        confpairs, lospairs, inconf, tcpamax, qdr, dist, dcpa, tcpa, tLOS = \
            traf.cd.detect(traf, traf, 20 * nm, traf.asas.dh, 3600)

        if confpairs:
            own, intr = zip(*confpairs)
            ownidx = traf.id2idx(own)
            mask = traf.alt[ownidx] > 70 * ft
            ownidx = np.array(ownidx)[mask]
            dcpa = np.array(dcpa)[mask]
            tcpa = np.array(tcpa)[mask]
        else:
            ownidx = np.array([])
    
        sendeff = False
        for idx, (sector, previnside) in enumerate(zip(self.sectors, self.acinside)):
            inside = areafilter.checkInside(sector, traf.lat, traf.lon, traf.alt)
            sectoreff = []
            # Detect aircraft leaving and entering the sector
github TUDelft-CNS-ATM / bluesky / bluesky / stack / stack.py View on Github external
"CALC": [
            "CALC expression",
            "string",
            calculator,
            "Simple in-line math calculator, evaluates expression",
        ],
        "CD": [
            "CD [path]",
            "[word]",
            setscenpath,
            "Change to a different scenario folder",
        ],
        "CDMETHOD": [
            "CDMETHOD [method]",
            "[txt]",
            bs.traf.asas.SetCDmethod,
            "Set conflict detection method",
        ],
        "CIRCLE": [
            "CIRCLE name,lat,lon,radius,[top,bottom]",
            "txt,latlon,float,[alt,alt]",
            lambda name, *coords: areafilter.defineArea(
                name, "CIRCLE", coords[:3], *coords[3:]
            ),
            "Define a circle-shaped area",
        ],
        "COLOR": [
            "COLOR name,color (named color or r,g,b)",
            "txt,color",
            bs.scr.color,
            "Set a custom color for an aircraft or shape",
        ],
github TUDelft-CNS-ATM / bluesky / bluesky / stack / stack.py View on Github external
"VS acid,vspd (ft/min)",
            "acid,vspd",
            bs.traf.ap.selvspdcmd,
            "Vertical speed command (autopilot)",
        ],
        "WIND": [
            "WIND lat,lon,alt/*,dir,spd,[alt,dir,spd,alt,...]",
            # last 3 args are repeated
            "latlon,[alt],float,float,...,...,...",
            bs.traf.wind.add,
            "Define a wind vector as part of the 2D or 3D wind field",
        ],
        "ZONEDH": [
            "ZONEDH [height]",
            "[float]",
            bs.traf.asas.SetPZH,
            "Set half of the vertical protected zone dimensions in ft",
        ],
        "ZONER": [
            "ZONER [radius]",
            "[float]",
            bs.traf.asas.SetPZR,
            "Set the radius of the horizontal protected zone dimensions in nm",
        ],
        "ZOOM": [
            "ZOOM IN/OUT or factor",
            "float/txt",
            lambda a: bs.scr.zoom(1.4142135623730951)
            if a == "IN"
            else bs.scr.zoom(0.7071067811865475)
            if a == "OUT"
            else bs.scr.zoom(a, True),
github TUDelft-CNS-ATM / bluesky / bluesky / traffic / pilot.py View on Github external
def APorASAS(self):
        #--------- Input to Autopilot settings to follow: destination or ASAS ----------
        # Convert the ASAS commanded speed from ground speed to TAS
        if bs.traf.wind.winddim > 0:
            vwn, vwe     = bs.traf.wind.getdata(bs.traf.lat, bs.traf.lon, bs.traf.alt)
            asastasnorth = bs.traf.asas.tas * np.cos(np.radians(bs.traf.asas.trk)) - vwn
            asastaseast  = bs.traf.asas.tas * np.sin(np.radians(bs.traf.asas.trk)) - vwe
            asastas      = np.sqrt(asastasnorth**2 + asastaseast**2)
        # no wind, then ground speed = TAS
        else:
            asastas = bs.traf.asas.tas # TAS [m/s]

        # Determine desired states from ASAS or AP. Select asas if there is a conflict AND resolution is on.
        self.trk = np.where(bs.traf.asas.active, bs.traf.asas.trk, bs.traf.ap.trk)
        self.tas = np.where(bs.traf.asas.active, asastas, bs.traf.ap.tas)
        self.alt = np.where(bs.traf.asas.active, bs.traf.asas.alt, bs.traf.ap.alt)
        self.vs  = np.where(bs.traf.asas.active, bs.traf.asas.vs, bs.traf.ap.vs)

        # ASAS can give positive and negative VS, but the sign of VS is determined using delalt in Traf.ComputeAirSpeed
        # Therefore, ensure that pilot.vs is always positive to prevent opposite signs of delalt and VS in Traf.ComputeAirSpeed
        self.vs = np.abs(self.vs)

        # Compute the desired heading needed to compensate for the wind
        if bs.traf.wind.winddim > 0:

            # Calculate wind correction
            vwn, vwe = bs.traf.wind.getdata(bs.traf.lat, bs.traf.lon, bs.traf.alt)
            Vw       = np.sqrt(vwn * vwn + vwe * vwe)
            winddir  = np.arctan2(vwe, vwn)
            drift    = np.radians(self.trk) - winddir  # [rad]
            steer    = np.arcsin(np.minimum(1.0, np.maximum(-1.0,
                                     Vw * np.sin(drift) / np.maximum(0.001, bs.traf.tas))))
github TUDelft-CNS-ATM / bluesky / bluesky / simulation / screenio.py View on Github external
data['lon']        = bs.traf.lon
        data['alt']        = bs.traf.alt
        data['tas']        = bs.traf.tas
        data['cas']        = bs.traf.cas
        data['gs']         = bs.traf.gs
        data['ingroup']    = bs.traf.groups.ingroup
        data['inconf'] = bs.traf.asas.inconf
        data['tcpamax'] = bs.traf.asas.tcpamax
        data['nconf_cur'] = len(bs.traf.asas.confpairs_unique)
        data['nconf_tot'] = len(bs.traf.asas.confpairs_all)
        data['nlos_cur'] = len(bs.traf.asas.lospairs_unique)
        data['nlos_tot'] = len(bs.traf.asas.lospairs_all)
        data['trk']        = bs.traf.trk
        data['vs']         = bs.traf.vs
        data['vmin']       = bs.traf.asas.vmin
        data['vmax']       = bs.traf.asas.vmax

        # Transition level as defined in traf
        data['translvl']   = bs.traf.translvl

        # ASAS resolutions for visualization. Only send when evaluated
        if bs.traf.asas.asaseval:
            data['asasn']  = bs.traf.asas.asasn
            data['asase']  = bs.traf.asas.asase
        else:
            data['asasn']  = np.zeros(bs.traf.ntraf, dtype=np.float32)
            data['asase']  = np.zeros(bs.traf.ntraf, dtype=np.float32)

        # Trails, send only new line segments to be added
        data['swtrails'] = bs.traf.trails.active
        data['traillat0'] = bs.traf.trails.newlat0
        data['traillon0'] = bs.traf.trails.newlon0
github TUDelft-CNS-ATM / bluesky / bluesky / simulation / screenio.py View on Github external
def send_aircraft_data(self):
        data = dict()
        data['simt']       = bs.sim.simt
        data['id']         = bs.traf.id
        data['lat']        = bs.traf.lat
        data['lon']        = bs.traf.lon
        data['alt']        = bs.traf.alt
        data['tas']        = bs.traf.tas
        data['cas']        = bs.traf.cas
        data['gs']         = bs.traf.gs
        data['ingroup']    = bs.traf.groups.ingroup
        data['inconf'] = bs.traf.asas.inconf
        data['tcpamax'] = bs.traf.asas.tcpamax
        data['nconf_cur'] = len(bs.traf.asas.confpairs_unique)
        data['nconf_tot'] = len(bs.traf.asas.confpairs_all)
        data['nlos_cur'] = len(bs.traf.asas.lospairs_unique)
        data['nlos_tot'] = len(bs.traf.asas.lospairs_all)
        data['trk']        = bs.traf.trk
        data['vs']         = bs.traf.vs
        data['vmin']       = bs.traf.asas.vmin
        data['vmax']       = bs.traf.asas.vmax

        # Transition level as defined in traf
        data['translvl']   = bs.traf.translvl

        # ASAS resolutions for visualization. Only send when evaluated
        if bs.traf.asas.asaseval:
            data['asasn']  = bs.traf.asas.asasn
            data['asase']  = bs.traf.asas.asase