Esempio n. 1
0
	def __init__(self, altitude_change = False):
		super(BSEnv, self).__init__()
		bs.init("sim-detached")
		#bs.net.connect()
		
		self.initial_number_of_planes = bs.traf.ntraf
		self.update_interval = 25	#[s] time between each timestep from the reinforcement learing model
		self.max_heading = 359 #[º] Max. relative degree heading. Used later to scale the state space.
		self.max_distance = bs.settings.asas_pzr * nm * 5 #[m] Maximum distance between planes that gets passed in the states
													  # Not sure if this has any effect.
		"""
		if altitude_change:
			self.n_actions = 7 #Taking changes of vertical speed as possible actions
		else:
			self.n_actions = 5 #Just horizontal heading changes
		"""

		#self.action_space = np.arange(self.n_actions)	#Vector that will containt the possible options
		self.observation_space = np.array([])	#Vector that will contain the state space.
		self.number_of_planes = 5	#Number of surrounding planes that each agent takes into account when calculating individual states.
		self.time_step = 5	#[s] time between each timestep for the rl model.
		self.agents_id_idx = {bs.traf.id[i]: i for i in range(bs.traf.ntraf)}
		self.routes = {}
		for i in range(bs.traf.ntraf):
			self.routes[bs.traf.id[i]] = Route(np.append(bs.traf.lat[i],bs.traf.ap.route[i].wplat), 
			np.append(bs.traf.lon[i],bs.traf.ap.route[i].wplon),
			np.append(bs.traf.alt[i],bs.traf.ap.route[i].wpalt), bs.traf.id[i])

		self.traffic = None
		self.simulation = None 
		self.screen = None
		self.net = None
Esempio n. 2
0
def main():
    """
    Start BlueSky: Create gui and simulation objects
    """
    # When importerror gives different name than (pip) install needs, also advise latest version
    missingmodules = {"OpenGL": "pyopengl and pyopengl-accelerate", "PyQt4": "pyqt5"}

    # Catch import errors
    try:
        # Initialize bluesky modules
        bs.init()

        # Start gui if this is the main process
        if bs.settings.is_gui:
            from bluesky.ui import qtgl
            qtgl.start()

        elif bs.settings.is_sim:
            bs.sim.start()

    # Give info on missing module
    except ImportError as error:
        modulename = missingmodules.get(error.name) or error.name
        print("Bluesky needs", modulename)
        print("Install using e.g. pip install", modulename)

    print('BlueSky normal end.')
Esempio n. 3
0
    def reset(self):
        # reset and reinitizalie sim
        bs.sim.reset()
        bs.init(self.mode,
                discovery=self.discovery,
                cfgfile=self.cfgfile,
                scnfile=self.scnfile)
        bs.sim.step()
        bs.sim.fastforward()
        # calculate state values
        dist_plane = tools.geo.kwikdist(bs.traf.lat[0], bs.traf.lon[0],
                                        bs.traf.lat[1], bs.traf.lon[1])
        dist_wpt = tools.geo.kwikdist(bs.traf.lat[0], bs.traf.lon[0],
                                      bs.traf.actwp.lat[0],
                                      bs.traf.actwp.lon[0])
        # create initial observation is a array of 4 collums [latitude,longitude,hdg,dist_plane,dist_waypoint]
        self.state = np.array([
            bs.traf.lat[0], bs.traf.lon[0],
            normalizer(bs.traf.hdg[0], 'HDGToNorm', self.min_hdg,
                       self.max_hdg),
            normalizer(dist_plane, 'DistToNorm', self.min_dist_plane,
                       self.max_dist_plane),
            normalizer(dist_wpt, 'DistToNorm', self.min_dist_waypoint,
                       self.max_dist_waypoint)
        ])

        # self.state = np.array([bs.traf.lat[0], bs.traf.lon[0], bs.traf.hdg[0], dist_plane, dist_wpt])
        self.state_object = np.array(
            [bs.traf.lat[1], bs.traf.lon[1], bs.traf.hdg[1]])
        self.ep = 0
        return self.state
Esempio n. 4
0
def traffic_():
    """
    Suite-level setup and teardown function, for those test functions
    naming `traffic_` in their parameter lists.
    """
    bluesky.settings.is_sim = True
    bluesky.init()
    yield bluesky.traf
Esempio n. 5
0
def traffic_():
    """
    Suite-level setup and teardown function, for those test functions
    naming `traffic_` in their parameter lists.
    """
    bluesky.settings.is_sim = True
    bluesky.init()
    yield bluesky.traf
Esempio n. 6
0
    def __init__(self):
        # Initialize BlueSky
        # With networking
        bs.init()
        # Without networking
        # bs.init(mode='sim-detached')

        # Setup simulation
        bs.sim.connect()
Esempio n. 7
0
    def reset(self):
        """
        Reset the environment to initial state
        recdata is a dict that contains requested simulation data from Bluesky. Can be changed in plugin MLCONTROL.
        """
        # Connect to the BlueSky server and pan to area.
        if not self.connected:
            #if self.env_id == 1:
            bs.init(mode="sim-detached")
            #else:
            #bs.init()
            #bs.net.connect()

            self.connected = True
            str_to_send = 'IC ' + self.scenfile
            bs.stack.stack(str_to_send)
            simstep()
            simstep()

        bs.sim.reset()
        # bs.sim.fastforward()

        ## Create aircraft
        # Randomize location withing netherlands
        aclat = np.random.randn(
            self.n_ac) * (self.max_lat - self.min_lat) + self.min_lat
        aclon = np.random.randn(
            self.n_ac) * (self.max_lon - self.min_lon) + self.min_lon
        achdg = np.random.randint(1, 360, self.n_ac)
        acspd = np.ones(self.n_ac) * 250
        bs.traf.create(n=self.n_ac,
                       aclat=aclat,
                       aclon=aclon,
                       achdg=achdg,
                       acspd=acspd)

        recdata = dict(lat=bs.traf.lat,
                       lon=bs.traf.lon,
                       hdg=bs.traf.hdg,
                       actwplat=bs.traf.actwp.lat,
                       actwplon=bs.traf.actwp.lon,
                       id=bs.traf.id)

        simstep()
        # set properties based on loaded scenfile
        self.nr_agents = len(recdata['id'])
        self.id_agents = recdata['id']

        self.init_agent = dict.fromkeys(self.id_agents)
        for id in self.id_agents:
            self.init_agent[id] = False

        self.state = BlueSkyEnv.calc_state(self, recdata)
        self.ep = 0

        return self.state
Esempio n. 8
0
def main_loop():
    # Initialize bluesky modules
    bs.init()

    if bs.settings.is_sim:
        from bluesky.simulation.qtgl import nodemanager as manager
        manager.run()

    else:
        telnet_in, manager = start()
        gui.start()
        stop(telnet_in, manager)
Esempio n. 9
0
	def __init__(self):
		super(BSEnv, self).__init__()
		bs.init("sim")
		bs.net.connect()
		self.update_interval = 25	#[s] time between each timestep from the reinforcement learing model
		self.max_ehading = 359 #[º] Max. relative degree heading. Used later to scale the state space.
		self.max_distance = bs.settings.asas * nm * 5 #[m] Maximum distance between planes that gets passed in the states
													  # Not sure if this has any effect.
		if altitude_change:
			self.n_actions = 7 #Taking changes of vertical speed as possible actions
		else:
			self.n_actions = 5 #Just horizontal heading changes

		self.action_space = np.arange(self.n_actions)	#Vector that will containt the possible options
		self.observation_space = np.array([])	#Vector that will contain the state space.
Esempio n. 10
0
def main():
    """ Start the mainloop (and possible other threads) """
    splash.show()
    bs.init(pygame=True)
    # bs.sim.op()
    bs.scr.init()

    # Main loop for BlueSky
    while not bs.sim.state == bs.END:
        bs.sim.step()   # Update sim
        bs.scr.update()   # GUI update

    bs.sim.quit()
    pg.quit()

    print('BlueSky normal end.')
Esempio n. 11
0
def start():
    """ Start the mainloop (and possible other threads) """
    splash.show()
    bs.init()
    bs.sim.operate()
    bs.scr.init()

    # Main loop for tmx object
    while not bs.sim.mode == bs.sim.end:
        bs.sim.update()  # Update sim
        bs.scr.update()  # GUI update

        # Restart traffic simulation:
        if bs.sim.mode == bs.sim.init:
            bs.sim.reset()
            bs.scr.objdel()  # Delete user defined objects
Esempio n. 12
0
def start():
    # =============================================================================
    # Start the mainloop (and possible other threads)
    # =============================================================================
    splash.show()
    bs.init()
    bs.sim.operate()
    bs.scr.init()

    # Main loop for tmx object
    while not bs.sim.mode == bs.sim.end:
        bs.sim.update()   # Update sim
        bs.scr.update()   # GUI update

        # Restart traffic simulation:
        if bs.sim.mode == bs.sim.init:
            bs.sim.reset()
            bs.scr.objdel()     # Delete user defined objects
Esempio n. 13
0
def main():

    mode = 'sim-detached'
    # mode = 'server - headless'

    discovery = False

    # Check if alternate config file is passed or a default scenfile
    cfgfile = ''
    scnfile = '/synthetics/super/super2.scn'

    bs.init(mode, discovery=discovery, cfgfile=cfgfile, scnfile=scnfile)
    bs.sim.step()
    # print_state()
    # print(np.array([bs.traf.lat[0], bs.traf.lon[0], bs.traf.hdg[0]], bs.traf.asas.dist[0]))
    for i in range(10000):

        bs.sim.step()
        print_location()
Esempio n. 14
0
 def __init__(self):
     super(BlueSkyEnv, self).__init__()
     bs.init('sim')
     bs.net.connect()
     #bs.settings.set_variable_defaults(asas_pzr=5.0, asas_pzh=1000.0,
     #                          asas_dtlookahead=300.0)
     self.action_space = gym.spaces.Discrete(9)
     self.number_of_planes = 3
     self.update_interval = 15
     self.max_number_conflicts = 15
     self.max_heading = 359
     self.max_speed = 300
     self.max_distance = bs.settings.asas_pzr * nm * 5
     self.acumulated_fuelflow = 0
     self.observation_space = gym.spaces.Box(
         low=np.zeros((self.number_of_planes * 4 + 3, 1), dtype=np.float32),
         high=np.ones((self.number_of_planes * 4 + 3, 1), dtype=np.float32))
     print("End of __init__ of the environment")
     print(bs.traf.lat)
Esempio n. 15
0
def main():
    """ Start the mainloop (and possible other threads) """
    splash.show()
    bs.init(pygame=True)
    bs.sim.operate()
    bs.scr.init()

    # Main loop for BlueSky
    while not bs.sim.mode == bs.sim.end:
        bs.sim.update()   # Update sim
        bs.scr.update()   # GUI update

        # Restart traffic simulation:
        if bs.sim.mode == bs.sim.init:
            bs.sim.reset()
            bs.scr.objdel()     # Delete user defined objects

    bs.sim.stop()
    pg.quit()

    print('BlueSky normal end.')
Esempio n. 16
0
def main():
    """ Start the mainloop (and possible other threads) """
    splash.show()
    bs.init(pygame=True)
    bs.sim.operate()
    bs.scr.init()

    # Main loop for BlueSky
    while not bs.sim.mode == bs.sim.end:
        bs.sim.update()  # Update sim
        bs.scr.update()  # GUI update

        # Restart traffic simulation:
        if bs.sim.mode == bs.sim.init:
            bs.sim.reset()
            bs.scr.objdel()  # Delete user defined objects

    bs.sim.stop()
    pg.quit()

    print('BlueSky normal end.')
Esempio n. 17
0
def main_loop():
    # =============================================================================
    # Start the mainloop (and possible other threads)
    # =============================================================================
    splash.show()
    bs.init()
    bs.sim.start()
    bs.scr.init()

    # Main loop for tmx object
    while not bs.sim.mode == bs.sim.end:
        bs.sim.update()  # Update sim
        bs.scr.update()  # GUI update

        # Restart traffic simulation:
        if bs.sim.mode == bs.sim.init:
            bs.sim.reset()
            bs.scr.objdel()  # Delete user defined objects

    # After the simulation is done, close the gui
    bs.sim.stop()
    pg.quit()
    print('BlueSky normal end.')
    return
Esempio n. 18
0
def main():
    """
        Start BlueSky: This is the main entrypoint for BlueSky.
        Depending on settings and arguments passed it can start in different
        modes. The central part of BlueSky consists of a server managing all
        simulations, normally together with a gui. The different modes for this
        are:
        - server-gui: Start gui and simulation server
        - server-headless: start server without gui
        - client: start gui only, which can connect to an already running server

        A BlueSky server can start one or more simulation processes, which run
        the actual simulations. These simulations can also be started completely
        separate from all other BlueSky functionality, in the detached mode.
        This is useful when calling bluesky from within another python
        script/program. The corresponding modes are:
        - sim: The normal simulation process started by a BlueSky server
        - sim-detached: An isolated simulation node, without networking
    """
    # When importerror gives different name than (pip) install needs,
    # also advise latest version
    missingmodules = {"OpenGL": "pyopengl"}


    # Catch import errors
    try:
        # Parse command-line arguments
        args = cmdargs.parse()
        # Initialize bluesky modules. Pass command-line arguments parsed by cmdargs
        bs.init(**args)

        # Only start a simulation node if called with --sim or --detached
        if bs.mode == 'sim':
            bs.net.connect()
            bs.net.run()
        else:
            # Only print start message in the non-sim cases to avoid printing
            # this for every started node
            print("   *****   BlueSky Open ATM simulator *****")
            print("Distributed under GNU General Public License v3")

        # Start server if server/gui or server-headless is started here
        if bs.mode == 'server':
            if bs.gui is None:
                bs.server.run()
            else:
                bs.server.start()

        # Start gui if client or main server/gui combination is started here
        if bs.gui == 'qtgl':
            from bluesky.ui import qtgl
            qtgl.start(hostname=args.get('hostname'))

        elif bs.gui == 'console':
            from bluesky.ui import console
            console.start(hostname=args.get('hostname'))

    # Give info on missing module
    except ImportError as error:
        modulename = missingmodules.get(error.name) or error.name
        if modulename is None or 'bluesky' in modulename:
            raise error
        print("Bluesky needs", modulename)
        print("Run setup-python.bat (Windows) or check requirements.txt (other systems)")
        print("Install using e.g. pip install", modulename)

    print('BlueSky normal end.')
Esempio n. 19
0
import bluesky as bs
bs.init("server-headless")

for i in range(15):
    print(i)
    bs.sim.step()
    bs.net.step()
Esempio n. 20
0
def main():
    """
        Start BlueSky: This is the main entrypoint for BlueSky.
        Depending on settings and arguments passed it can start in different
        modes. The central part of BlueSky consists of a server managing all
        simulations, normally together with a gui. The different modes for this
        are:
        - server-gui: Start gui and simulation server
        - server-headless: start server without gui
        - client: start gui only, which can connect to an already running server

        A BlueSky server can start one or more simulation processes, which run
        the actual simulations. These simulations can also be started completely
        separate from all other BlueSky functionality, in the detached mode.
        This is useful when calling bluesky from within another python
        script/program. The corresponding modes are:
        - sim: The normal simulation process started by a BlueSky server
        - sim-detached: An isolated simulation node, without networking
    """
    # When importerror gives different name than (pip) install needs,
    # also advise latest version
    missingmodules = {"OpenGL": "pyopengl and pyopengl-accelerate"}

    ### Parse command-line arguments ###
    # BlueSky.py modes:
    # server-gui: Start gui and simulation server
    # client: start gui only, which can connect to an already running server
    # server-headless: start server only
    # detached: start only one simulation node, without networking
    #   ==> useful for calling bluesky from within another python script/program
    sys.argv.append('--headless')
    sys.argv.append('--scenfile')
    # sys.argv.append('Flight Test\\SCNM_FE.scn')
    sys.argv.append('Trajectories-batch4.scn')
    # sys.argv.append('Trajectories-batch.scn')
    if '--detached' in sys.argv:
        mode = 'sim-detached'
    elif '--sim' in sys.argv:
        mode = 'sim'
    elif '--client' in sys.argv:
        mode = 'client'
    elif '--headless' in sys.argv:
        mode = 'server-headless'
    else:
        mode = 'server-gui'

    discovery = ('--discoverable' in sys.argv or mode[-8:] == 'headless')

    # Check if alternate config file is passed or a default scenfile
    cfgfile = ''
    scnfile = ''
    for i in range(len(sys.argv)):
        if len(sys.argv) > i + 1:
            if sys.argv[i] == '--config-file':
                cfgfile = sys.argv[i + 1]
            elif sys.argv[i] == '--scenfile':
                scnfile = sys.argv[i + 1]

    # Catch import errors
    try:
        # Initialize bluesky modules
        bs.init(mode, discovery=discovery, cfgfile=cfgfile, scnfile=scnfile)

        # Only start a simulation node if called with --sim or --detached
        if mode[:3] == 'sim':
            if mode[-8:] != 'detached':
                bs.sim.connect()
            bs.sim.run()
        else:
            # Only print start message in the non-sim cases to avoid printing
            # this for every started node
            print("   *****   BlueSky Open ATM simulator *****")
            print("Distributed under GNU General Public License v3")

        # Start server if server/gui or server-headless is started here
        if mode[:6] == 'server':
            if mode[-8:] == 'headless':
                bs.server.run()
            else:
                bs.server.start()

        # Start gui if client or main server/gui combination is started here
        if mode in ('client', 'server-gui'):
            from bluesky.ui import qtgl
            qtgl.start(mode)

    # Give info on missing module
    except ImportError as error:
        modulename = missingmodules.get(error.name) or error.name
        if modulename is None:
            raise error
        print("Bluesky needs", modulename)
        print(
            "Run setup-python.bat (Windows) or check requirements.txt (other systems)"
        )
        print("Install using e.g. pip install", modulename)

    print('BlueSky normal end.')
Esempio n. 21
0
if np and sp and mpl:
    canrunqt = (qt and gl and glhw)
    canrunpg = pg
    if canrunpg or canrunqt:
        print(
            'You have all the required libraries to run BlueSky. You can use',
            end=' ')
    if canrunpg and canrunqt:
        print('both the QTGL and the pygame versions.')
    else:
        print('only the %s version.' % ('pygame' if canrunpg else 'QTGL'))

print("Checking bluesky modules")
try:
    import bluesky
    bluesky.init(mode='client')
    from bluesky.ui import *
    from bluesky.stack import *
    from bluesky.simulation import *
    from bluesky.traffic import *
    from bluesky.traffic.asas import *
    from bluesky.traffic.performance import *
    from bluesky.navdatabase import *
except Exception as err:
    print(traceback.format_exc())
    print(
        "One or more BlueSky modules are not working properly, check the above error for more detail."
    )
else:
    print(
        "Successfully loaded all BlueSky modules. Start BlueSky by running BlueSky.py."
Esempio n. 22
0
    pg = True
    print('[OK]')

print()
if np and sp and mpl:
    canrunqt = (qt and gl and glhw)
    canrunpg = pg
    if canrunpg or canrunqt:
        print('You have all the required libraries to run BlueSky. You can use', end=' ')
    if canrunpg and canrunqt:
        print('both the QTGL and the pygame versions.')
    else:
        print('only the %s version.' % ('pygame' if canrunpg else 'QTGL'))

print("Checking bluesky modules")
try:
    import bluesky
    bluesky.init()
    from bluesky.ui import *
    from bluesky.stack import *
    from bluesky.simulation import *
    from bluesky.traffic import *
    from bluesky.traffic.asas import *
    from bluesky.traffic.performance import *
    from bluesky.navdatabase import *
except Exception as err:
    print(traceback.format_exc())
    print("One or more BlueSky modules are not working properly, check the above error for more detail.")
else:
    print("Successfully loaded all BlueSky modules. Start BlueSky by running BlueSky.py.")
Esempio n. 23
0
def main():
    """
        Start BlueSky: This is the main entrypoint for BlueSky.
        Depending on settings and arguments passed it can start in different
        modes. The central part of BlueSky consists of a server managing all
        simulations, normally together with a gui. The different modes for this
        are:
        - server-gui: Start gui and simulation server
        - server-headless: start server without gui
        - client: start gui only, which can connect to an already running server

        A BlueSky server can start one or more simulation processes, which run
        the actual simulations. These simulations can also be started completely
        separate from all other BlueSky functionality, in the detached mode.
        This is useful when calling bluesky from within another python
        script/program. The corresponding modes are:
        - sim: The normal simulation process started by a BlueSky server
        - sim-detached: An isolated simulation node, without networking
    """
    # When importerror gives different name than (pip) install needs,
    # also advise latest version
    missingmodules = {"OpenGL": "pyopengl and pyopengl-accelerate"}

    ### Parse command-line arguments ###
    # BlueSky.py modes:
    # server-gui: Start gui and simulation server
    # client: start gui only, which can connect to an already running server
    # server-headless: start server only
    # detached: start only one simulation node, without networking
    #   ==> useful for calling bluesky from within another python script/program
    if '--detached' in sys.argv:
        mode = 'sim-detached'
    elif '--sim' in sys.argv:
        mode = 'sim'
    elif '--client' in sys.argv:
        mode = 'client'
    elif '--headless' in sys.argv:
        mode = 'server-headless'
    else:
        mode = 'server-gui'

    discovery = ('--discoverable' in sys.argv or mode[-8:] == 'headless')

    # Check if alternate config file is passed or a default scenfile
    cfgfile = ''
    scnfile = ''
    for i in range(len(sys.argv)):
        if len(sys.argv) > i + 1:
            if sys.argv[i] == '--config-file':
                cfgfile = sys.argv[i + 1]
            elif sys.argv[i] == '--scenfile':
                scnfile = sys.argv[i + 1]

    # Catch import errors
    try:
        # Initialize bluesky modules
        bs.init(mode, discovery=discovery, cfgfile=cfgfile, scnfile=scnfile)

        # Only start a simulation node if called with --sim or --detached
        if mode[:3] == 'sim':
            if mode[-8:] != 'detached':
                bs.sim.connect()
            bs.sim.run()
        else:
            # Only print start message in the non-sim cases to avoid printing
            # this for every started node
            print("   *****   BlueSky Open ATM simulator *****")
            print("Distributed under GNU General Public License v3")

        # Start server if server/gui or server-headless is started here
        if mode[:6] == 'server':
            if mode[-8:] == 'headless':
                bs.server.run()
            else:
                bs.server.start()

        # Start gui if client or main server/gui combination is started here
        if mode in ('client', 'server-gui'):
            from bluesky.ui import qtgl
            qtgl.start(mode)

    # Give info on missing module
    except ImportError as error:
        modulename = missingmodules.get(error.name) or error.name
        if modulename is None:
            raise error
        print("Bluesky needs", modulename)
        print("Install using e.g. pip install", modulename)

    print('BlueSky normal end.')
Esempio n. 24
0
 def reset(self):
     bs.init("sim")
     bs.net.connect()
     state = self.calculate_state()
     return state
Esempio n. 25
0
    def __init__(self, **kwargs):
        def on_event(eventname, eventdata, sender_id):
            print(eventdata)
            print(sender_id)

        def on_stream(streamname, data, sender_id):
            print('Stream data received:', streamname)
            self.received_data = True
            self.data = data

        ## Enable client server interface
        self.NodeID = kwargs['NodeID']
        self.received_data = False
        myclient = Client()
        myclient.connect(event_port=11000, stream_port=11001)
        myclient.receive()
        myclient.actnode(
            myclient.servers[myclient.host_id]['nodes'][self.NodeID])
        myclient.subscribe(b'ACDATA')

        myclient.stream_received.connect(on_stream)
        myclient.event_received.connect(on_event)

        while not self.received_data:
            myclient.receive()

        self.nm = 1852
        self.ep = 0
        self.los = 5 * 1.05  # [nm] Horizontal separation minimum for resolution
        self.wpt_reached = 5
        # observation is a array of 4 collums [latitude,longitude,hdg,dist_plane,dist_waypoint] Real values, so not yet normalized
        self.min_hdg = 0  #0
        self.max_hdg = 360  #360
        self.min_lat = -1
        self.max_lat = 1
        self.min_lon = -1
        self.max_lon = 1
        # max values based upon size of latlon box
        self.min_dist_plane = self.los * 0.95
        self.max_dist_plane = 125
        self.min_dist_waypoint = self.wpt_reached * 0.95
        self.max_dist_waypoint = 125

        # define observation bounds
        self.low_obs = np.array([
            self.min_lat, self.min_lon,
            normalizer(self.min_hdg, 'HDGToNorm', self.min_hdg, self.max_hdg),
            normalizer(self.min_dist_plane, 'DistToNorm', self.min_dist_plane,
                       self.max_dist_plane),
            normalizer(self.min_dist_waypoint, 'DistToNorm',
                       self.min_dist_waypoint, self.max_dist_waypoint)
        ])
        self.high_obs = np.array([
            self.max_lat, self.max_lon,
            normalizer(self.max_hdg, 'HDGToNorm', self.min_hdg, self.max_hdg),
            normalizer(self.max_dist_plane, 'DistToNorm', self.min_dist_plane,
                       self.max_dist_plane),
            normalizer(self.max_dist_waypoint, 'DistToNorm',
                       self.min_dist_waypoint, self.max_dist_waypoint)
        ])
        self.viewer = None

        # Initialize bluesky
        self.mode = 'sim-detached'
        self.discovery = ('--discoverable' in sys.argv
                          or self.mode[-8:] == 'headless')
        # Check if alternate config file is passed or a default scenfile
        self.cfgfile = ''
        self.scnfile = '/synthetics/super/super3.scn'
        bs.init(self.mode,
                discovery=self.discovery,
                cfgfile=self.cfgfile,
                scnfile=self.scnfile)
        bs.sim.fastforward()
        self.observation_space = spaces.Box(low=self.low_obs,
                                            high=self.high_obs,
                                            dtype=np.float32)
        # self.action_space = spaces.Discrete(360)
        self.action_space = spaces.Box(low=-1,
                                       high=1,
                                       shape=(1, ),
                                       dtype=np.float32)
Esempio n. 26
0
import bluesky
bluesky.init("sim-detached")

for i in range(10):
    bluesky.sim.step()
    bluesky.net.step()

print("Ending script...")
Esempio n. 27
0
	def reset(self):
		#TO DO: Rewrite this function so it is easier to restart the scenario. It takes too long since it has to
		#restart all bluesky.
		bs.init("sim")
		bs.net.connect()
		return self.calculate_state()