-
Notifications
You must be signed in to change notification settings - Fork 236
/
mlcontrol.py
75 lines (55 loc) · 2.16 KB
/
mlcontrol.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
""" External control plugin for Machine Learning applications. """
# Import the global bluesky objects. Uncomment the ones you need
from bluesky import stack, sim, traf #, settings, navdb, traf, sim, scr, tools
myclientrte = None
### Initialization function of your plugin. Do not change the name of this
### function, as it is the way BlueSky recognises this file as a plugin.
def init_plugin():
# Addtional initilisation code
# Configuration parameters
config = {
# The name of your plugin
'plugin_name': 'MLCONTROL',
# The type of this plugin. For now, only simulation plugins are possible.
'plugin_type': 'sim',
# Update interval in seconds. By default, your plugin's update function(s)
# are called every timestep of the simulation. If your plugin needs less
# frequent updates provide an update interval.
'update_interval': 1.0,
'update': update,
# If your plugin has a state, you will probably need a reset function to
# clear the state in between simulations.
'reset': reset
}
stackfunctions = {
# The command name for your function
'MLSTEP': [
# A short usage string. This will be printed if you type HELP <name> in the BlueSky console
'MLSTEP',
# A list of the argument types your function accepts. For a description of this, see ...
'',
# The name of your function in this plugin
mlstep,
# a longer help text of your function.
'Simulate one MLCONTROL time interval.']
}
# init_plugin() should always return these two dicts.
return config, stackfunctions
### Periodic update functions that are called by the simulation. You can replace
### this by anything, so long as you communicate this in init_plugin
def update():
data = dict(
lat=traf.lat,
lon=traf.lon,
alt=traf.alt
)
sim.send_event(b'MLSTATEREPLY', data, myclientrte)
sim.hold()
def preupdate():
pass
def reset():
pass
def mlstep():
global myclientrte
myclientrte = stack.routetosender()
sim.op()