Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diferent results on same scenario #494

Open
uriibra opened this issue Jan 15, 2024 · 6 comments
Open

Diferent results on same scenario #494

uriibra opened this issue Jan 15, 2024 · 6 comments

Comments

@uriibra
Copy link

uriibra commented Jan 15, 2024

Hello bluesky team,

I'm doing some simulations and need to collect data, I'm using fast time simulation. The problem comes with RTA and AT, when runing an scnario. When i run on the grafic simulator itself i dont get any error on the console, while when i run it on the datalog on python i get errors not finding the waypoints created but they seem to be added. this is the console output:

Loading global navigation database...
Reading cache: C:\Users\breic\bluesky\cache\navdata.p
Loading global navigation database...
Reading cache: C:\Users\breic\bluesky\cache\navdata.p
BlueSky console: Base dt set to 1.0
performance dt is unchanged.
asas dt is unchanged.
AREA dt is unchanged.
DATAFEED.update dt set to 1.0 to match integer multiple of base dt.
BlueSky console: Selected StateBased as CD method.
BlueSky console: Conflict Resolution turned off.
BlueSky console: DESTEZY34QN added to navdb.
BlueSky console: DESTEZY74EY added to navdb.
BlueSky console: DESTRYR913K added to navdb.
BlueSky console: DESTEZY85PT added to navdb.
BlueSky console: ADDWPT EZY34QN DESTEZY34QN
Syntax error: Waypoint DESTEZY34QN not found.
BlueSky console: ADDWPT EZY74EY DESTEZY74EY
Syntax error: Waypoint DESTEZY74EY not found.
BlueSky console: ADDWPT RYR913K DESTRYR913K
Syntax error: Waypoint DESTRYR913K not found.
BlueSky console: ADDWPT EZY85PT DESTEZY85PT
Syntax error: Waypoint DESTEZY85PT not found.
BlueSky console: EZY34QN AT DESTEZY34QN DO DEL EZY34QN

DESTEZY34QN not found in the route of EZY34QN
Usage:
AT acidx,atwp,args
BlueSky console: EZY74EY AT DESTEZY74EY DO DEL EZY74EY

DESTEZY74EY not found in the route of EZY74EY
Usage:
AT acidx,atwp,args
BlueSky console: RYR913K AT DESTRYR913K DO DEL RYR913K

DESTRYR913K not found in the route of RYR913K
Usage:
AT acidx,atwp,args
BlueSky console: EZY85PT AT DESTEZY85PT DO DEL EZY85PT

DESTEZY85PT not found in the route of EZY85PT
Usage:
AT acidx,atwp,args

This is the scnario:

00:00:00.00>ASAS ON
00:00:00.00>RESO OFF
00:00:00.00>TRAILS ON
00:00:00.00>DEFWPT DESTEZY34QN, 51.88166666666667 , -0.32777778333333335
00:00:00.00>CRE EZY34QN , A320 , 40.47111111666666 , 18.76833333333333 , 317.9199863129349 , FL298, .75
00:00:00.00>ADDWPT EZY34QN , 40.47111111666666 , 18.76833333333333 ,FL298
00:00:00.00>ADDWPT EZY34QN , 41.256111116666666 , 17.95944445 ,FL375
00:00:00.00>ADDWPT EZY34QN , 43.154583333333335 , 15.745208333333334 ,FL380
00:00:00.00>ADDWPT EZY34QN , 45.262777783333334 , 12.99555555 ,FL380
00:00:00.00>ADDWPT EZY34QN , 46.905277775 , 9.812013883333332 ,FL380
00:00:00.00>ADDWPT EZY34QN , 47.66458333333334 , 6.442187495833334 ,FL380
00:00:00.00>ADDWPT EZY34QN , 49.21312500416667 , 2.9770486104166665 ,FL380
00:00:00.00>ADDWPT EZY34QN , 50.530833333333334 , 0.7722222166666667 ,FL327
00:00:00.00>ADDWPT EZY34QN , 51.185555550000004 , -0.07138888333333333 ,FL190
00:00:00.00>ADDWPT EZY34QN , 51.839166666666664 , -0.08805555 ,FL120
00:00:00.00>ADDWPT EZY34QN , 52.07805555 , -0.23249999999999998 ,FL63
00:00:00.00>EZY34QN VNAV ON
00:00:00.00>DEFWPT DESTEZY74EY, 51.88194445 , -0.32583333333333336
00:00:00.00>CRE EZY74EY , A320 , 41.247222216666664 , 22.758333333333333 , 315.58585352715437 , FL340, .75
00:00:00.00>ADDWPT EZY74EY , 41.247222216666664 , 22.758333333333333 ,FL340
00:00:00.00>ADDWPT EZY74EY , 42.83388888333333 , 20.311388883333333 ,FL340
00:00:00.00>ADDWPT EZY74EY , 44.48444445 , 17.127499999999998 ,FL340
00:00:00.00>ADDWPT EZY74EY , 46.05312499583333 , 14.172777783333334 ,FL340
00:00:00.00>ADDWPT EZY74EY , 47.41833333333333 , 11.490277783333333 ,FL340
00:00:00.00>ADDWPT EZY74EY , 48.97111111666666 , 8.679722216666667 ,FL350
00:00:00.00>ADDWPT EZY74EY , 50.55791666666667 , 5.2154166625 ,FL360
00:00:00.00>ADDWPT EZY74EY , 51.26861111666666 , 3.546666666666667 ,FL325
00:00:00.00>ADDWPT EZY74EY , 51.60875 , 2.2333333333333334 ,FL240
00:00:00.00>ADDWPT EZY74EY , 52.21722221666666 , 0.6583333333333333 ,FL130
00:00:00.00>ADDWPT EZY74EY , 52.32388888333333 , -0.3788888833333333 ,FL100
00:00:00.00>ADDWPT EZY74EY , 51.983333333333334 , -0.07638888333333332 ,FL49
00:00:00.00>EZY74EY VNAV ON
00:00:00.00>DEFWPT DESTRYR913K, 52.832499999999996 , -1.24055555
00:00:00.00>CRE RYR913K , B738 , 40.789999995833334 , 19.808125000000004 , 321.9152613055542 , FL360, .75
00:00:00.00>ADDWPT RYR913K , 40.789999995833334 , 19.808125000000004 ,FL360
00:00:00.00>ADDWPT RYR913K , 42.561215277083335 , 17.700555550000004 ,FL380
00:00:00.00>ADDWPT RYR913K , 44.664583335416665 , 14.349652779166668 ,FL380
00:00:00.00>ADDWPT RYR913K , 46.42444445 , 11.811666666666667 ,FL380
00:00:00.00>ADDWPT RYR913K , 48.51614583125001 , 9.048854166666668 ,FL380
00:00:00.00>ADDWPT RYR913K , 50.104722225 , 6.063194441666667 ,FL380
00:00:00.00>ADDWPT RYR913K , 51.32159721666666 , 2.44524305 ,FL380
00:00:00.00>ADDWPT RYR913K , 51.64611111666667 , 0.15166666666666667 ,FL250
00:00:00.00>ADDWPT RYR913K , 52.21666666666667 , -0.8225 ,FL150
00:00:00.00>ADDWPT RYR913K , 52.82611111666667 , -1.1586111166666666 ,FL27
00:00:00.00>RYR913K VNAV ON
00:00:00.00>DEFWPT DESTEZY85PT, 51.879722216666664 , -0.3397222166666667
00:00:00.00>CRE EZY85PT , A320 , 38.17583333333334 , 15.2325 , 327.944846284614 , FL230, .75
00:00:00.00>ADDWPT EZY85PT , 38.17583333333334 , 15.2325 ,FL230
00:00:00.00>ADDWPT EZY85PT , 39.56152778333333 , 14.3373958375 ,FL360
00:00:00.00>ADDWPT EZY85PT , 42.174166666666665 , 12.427638891666668 ,FL360
00:00:00.00>ADDWPT EZY85PT , 44.71944445 , 10.38694445 ,FL360
00:00:00.00>ADDWPT EZY85PT , 46.69527778333334 , 8.241111116666666 ,FL365
00:00:00.00>ADDWPT EZY85PT , 47.906388883333335 , 5.2491666666666665 ,FL380
00:00:00.00>ADDWPT EZY85PT , 49.89017361041667 , 1.6977777833333332 ,FL380
00:00:00.00>ADDWPT EZY85PT , 50.64305555 , 0.6219444500000001 ,FL294
00:00:00.00>ADDWPT EZY85PT , 51.41222221666667 , -0.3238888833333334 ,FL180
00:00:00.00>ADDWPT EZY85PT , 51.82944445 , 0.0275 ,FL120
00:00:00.00>ADDWPT EZY85PT , 51.935277783333326 , -0.22888888333333332 ,FL42
00:00:00.00>EZY85PT VNAV ON
00:00:00.01>ADDWPT EZY34QN DESTEZY34QN
00:00:00.01>ADDWPT EZY74EY DESTEZY74EY
00:00:00.01>ADDWPT RYR913K DESTRYR913K
00:00:00.01>ADDWPT EZY85PT DESTEZY85PT
00:00:00.02>EZY34QN AT DESTEZY34QN DO DEL EZY34QN
00:00:00.02>EZY74EY AT DESTEZY74EY DO DEL EZY74EY
00:00:00.02>RYR913K AT DESTRYR913K DO DEL RYR913K
00:00:00.02>EZY85PT AT DESTEZY85PT DO DEL EZY85PT

And this is my python code

import bluesky as bs
from bluesky.simulation import ScreenIO

class ScreenDummy(ScreenIO):
def echo(self, text='', flags=0):
print("BlueSky console:", text)

bs.init(mode='sim', detached=True)

def simulation(scn_route,simtime):
route = scn_route

t_max = simtime

bs.scr = ScreenDummy()
bs.stack.simstack.ic(route)
n_flights = len(bs.stack.simstack.ic(route))-1
bs.stack.stack('DT 1;FF')

bs.stack.stack()

ntraf = bs.traf.ntraf
n_steps = int(t_max + 1)
t = np.linspace(0, t_max, n_steps)

flightff = [] #list of list with the fuelflow (kg/s) per each step
n_conf = [] #sumatory of conflicts number ubdated on every step
dist_flown = [] #sumatory of km flown updated on each step
spd = []  #list of list with the ground speed (m/s) for each step

for i in range(n_steps):
    bs.sim.step()
    for j in range(len(bs.traf.id)):
        if i == 0 or j >= len(flightff): #if first cration for initial time or new aircraft
            flightid = bs.traf.id
            flightff.append([bs.traf.perf.fuelflow[j]])
            if bs.traf.cd.inconf[j] == True: #inconf is an array of conf True or False per each aircraft
                n_conf.append(1)
            else:
                n_conf.append(0)
            dist_flown.append(0)
            spd.append([bs.traf.gs[j]]) 

        else: # add new step info to each list
            flightff[j].append(bs.traf.perf.fuelflow[j])
            if bs.traf.cd.inconf[j] == True:
                n_conf[j] += 1
            dist_flown[j] = round(bs.traf.distflown[j]/1000,3)
            spd[j].append(bs.traf.gs[j])

return flightff
@jooste
Copy link
Member

jooste commented Jan 16, 2024

Hi @uriibra,

If I run your scenario directly in bluesky I get no errors. The code snippet you've posted is incomplete (your function simulation() isn't called for one), but other than that I don't see anything there that might cause your problems. Are you sure you're correctly loading this scenario, or could it be that part of your code is resetting stack / otherwise changing traffic?

@uriibra
Copy link
Author

uriibra commented Jan 16, 2024

Hi @uriibra,

If I run your scenario directly in bluesky I get no errors. The code snippet you've posted is incomplete (your function simulation() isn't called for one), but other than that I don't see anything there that might cause your problems. Are you sure you're correctly loading this scenario, or could it be that part of your code is resetting stack / otherwise changing traffic?

Hello @jooste,

Thank you for your fast reply, I'm sorry, the code is incomplete because it is part of a longer code. When calling the function, it reads the scenario completely, and I get fuel_flow results. The problem lies in that it does not interpret the waypoints used RTA and AT commands, throwing this error: "DESTEZY34QN not found in the route of EZY34QN," even though it has loaded that waypoint as I get this output when running it: "BlueSky console: DESTEZY34QN added to navdb."

Analyzing the results, the aircraft does not modify the speed to achieve the RTA. What confuses me is that when I run it in the simulator on the screen, I don't get any waypoint errors, and the RTAs are indeed met. I understand that the error could be in how the file is being read; I am using bs.stack.simstack.ic(route). I also do not know if the scenario, to be executed with bs.stack.simstack.ic(route), should have a different syntax.

This is the console output on the python simulation:
image

and this is on Bluesky window:
image

The scenrio is the same file for both simulation, so I'm not sure what is the reason for that.

@jooste
Copy link
Member

jooste commented Jan 16, 2024

Ok, I also tried turning your code into a minimum working example:

import numpy as np
import bluesky as bs
from bluesky.simulation import ScreenIO


class ScreenDummy(ScreenIO):
    def echo(self, text='', flags=0):
        print("BlueSky console:", text)

bs.init(mode='sim', detached=True)


def simulation(scn_route,simtime):
    route = scn_route
    t_max = simtime

    bs.scr = ScreenDummy()
    bs.stack.simstack.ic(route)
    n_flights = len(bs.stack.simstack.ic(route))-1
    bs.stack.stack('DT 1;FF')

    bs.stack.stack()

    ntraf = bs.traf.ntraf
    n_steps = int(t_max + 1)
    t = np.linspace(0, t_max, n_steps)

    flightff = [] #list of list with the fuelflow (kg/s) per each step
    n_conf = [] #sumatory of conflicts number ubdated on every step
    dist_flown = [] #sumatory of km flown updated on each step
    spd = []  #list of list with the ground speed (m/s) for each step

    for i in range(n_steps):
        bs.sim.step()
        for j in range(len(bs.traf.id)):
            if i == 0 or j >= len(flightff): #if first cration for initial time or new aircraft
                flightid = bs.traf.id
                flightff.append([bs.traf.perf.fuelflow[j]])
                if bs.traf.cd.inconf[j] == True: #inconf is an array of conf True or False per each aircraft
                    n_conf.append(1)
                else:
                    n_conf.append(0)
                dist_flown.append(0)
                spd.append([bs.traf.gs[j]]) 

            else: # add new step info to each list
                flightff[j].append(bs.traf.perf.fuelflow[j])
                if bs.traf.cd.inconf[j] == True:
                    n_conf[j] += 1
                dist_flown[j] = round(bs.traf.distflown[j]/1000,3)
                spd[j].append(bs.traf.gs[j])

    return flightff

simulation('gh_test', 1000.0)

When I run this I also don't get any errors. There must be something else happening in your code. I assume you are on the current version of the master branch?

@uriibra
Copy link
Author

uriibra commented Jan 16, 2024

Ok, I also tried turning your code into a minimum working example:

import numpy as np
import bluesky as bs
from bluesky.simulation import ScreenIO


class ScreenDummy(ScreenIO):
    def echo(self, text='', flags=0):
        print("BlueSky console:", text)

bs.init(mode='sim', detached=True)


def simulation(scn_route,simtime):
    route = scn_route
    t_max = simtime

    bs.scr = ScreenDummy()
    bs.stack.simstack.ic(route)
    n_flights = len(bs.stack.simstack.ic(route))-1
    bs.stack.stack('DT 1;FF')

    bs.stack.stack()

    ntraf = bs.traf.ntraf
    n_steps = int(t_max + 1)
    t = np.linspace(0, t_max, n_steps)

    flightff = [] #list of list with the fuelflow (kg/s) per each step
    n_conf = [] #sumatory of conflicts number ubdated on every step
    dist_flown = [] #sumatory of km flown updated on each step
    spd = []  #list of list with the ground speed (m/s) for each step

    for i in range(n_steps):
        bs.sim.step()
        for j in range(len(bs.traf.id)):
            if i == 0 or j >= len(flightff): #if first cration for initial time or new aircraft
                flightid = bs.traf.id
                flightff.append([bs.traf.perf.fuelflow[j]])
                if bs.traf.cd.inconf[j] == True: #inconf is an array of conf True or False per each aircraft
                    n_conf.append(1)
                else:
                    n_conf.append(0)
                dist_flown.append(0)
                spd.append([bs.traf.gs[j]]) 

            else: # add new step info to each list
                flightff[j].append(bs.traf.perf.fuelflow[j])
                if bs.traf.cd.inconf[j] == True:
                    n_conf[j] += 1
                dist_flown[j] = round(bs.traf.distflown[j]/1000,3)
                spd[j].append(bs.traf.gs[j])

    return flightff

simulation('gh_test', 1000.0)

When I run this I also don't get any errors. There must be something else happening in your code. I assume you are on the current version of the master branch?

Yes i'm running bluesky library and i just update it. The scenario doesn't produce errors; that's correct. The issue arises when reading added waypoints, such as in this simple scenario:

00:00:00.00>ASAS ON
00:00:00.00>RESO OFF
00:00:00.00>DEFWPT DESTEZY34QN, 51.88166666666667 , -0.32777778333333335
00:00:00.00>CRE EZY34QN , A320 , 40.47111111666666 , 18.76833333333333 , 317.9199863129349 ,FL298,.75
00:00:00.01>ADDWPT EZY34QN DESTEZY34QN
00:00:00.02>EZY34QN AT DESTEZY34QN DO DEL EZY34QN

the output i get is this:
BlueSky console: Selected StateBased as CD method.
BlueSky console: Conflict Resolution turned off.
BlueSky console: DESTEZY34QN added to navdb.
BlueSky console: ADDWPT EZY34QN DESTEZY34QN
Syntax error: Waypoint DESTEZY34QN not found.
BlueSky console: EZY34QN AT DESTEZY34QN DO DEL EZY34QN

DESTEZY34QN not found in the route of EZY34QN
Usage:
AT acidx,atwp,args

It seems that the created waypoints are not stored or are not found when the addwpt or AT command is executed; it does not find these waypoints. Is there any example code that uses a .scn file as input and not commands through bs.stack.stack?

@jooste
Copy link
Member

jooste commented Jan 16, 2024

Well, it does for me: the gh_test file in my example is the scenario file you provided in your first post in this issue. Your problem therefore has to lie somewhere else.

@uriibra
Copy link
Author

uriibra commented Jan 16, 2024

Well, it does for me: the gh_test file in my example is the scenario file you provided in your first post in this issue. Your problem therefore has to lie somewhere else.

Yes, your're right I've just tried on a different computer and it works well. I will try to uninstall the package and maybe check for other libraries dependecies. I will let you know if I find where the problem lies.

Thank you, for your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants