|
1 | 1 | # -*- coding: utf-8 -*-
|
2 | 2 |
|
3 | 3 | from .async_plugin_manager import AsyncPluginManager
|
4 |
| -from .generated import Action |
5 |
| -from .generated import Calibration |
6 |
| -from .generated import Camera |
7 |
| -from .generated import Core |
8 |
| -from .generated import FollowMe |
9 |
| -from .generated import Ftp |
10 |
| -from .generated import Geofence |
11 |
| -from .generated import Gimbal |
12 |
| -from .generated import Info |
13 |
| -from .generated import LogFiles |
14 |
| -from .generated import Mission |
15 |
| -from .generated import MissionRaw |
16 |
| -from .generated import Mocap |
17 |
| -from .generated import Offboard |
18 |
| -from .generated import Param |
19 |
| -from .generated import Shell |
20 |
| -from .generated import Telemetry |
21 |
| -from .generated import Tune |
| 4 | + |
| 5 | +from .action import action |
| 6 | +from .calibration import calibration |
| 7 | +from .camera import camera |
| 8 | +from .core import core |
| 9 | +from .follow_me import follow_me |
| 10 | +from .ftp import ftp |
| 11 | +from .geofence import geofence |
| 12 | +from .gimbal import gimbal |
| 13 | +from .info import info |
| 14 | +from .log_files import log_files |
| 15 | +from .mission import mission |
| 16 | +from .mission_raw import mission_raw |
| 17 | +from .mocap import mocap |
| 18 | +from .offboard import offboard |
| 19 | +from .param import param |
| 20 | +from .shell import shell |
| 21 | +from .telemetry import telemetry |
| 22 | +from .tune import tune |
22 | 23 |
|
23 | 24 | from . import bin
|
24 | 25 |
|
25 | 26 |
|
26 | 27 | class System:
|
27 |
| - _core_plugins = [ |
28 |
| - "Action", |
29 |
| - "Calibration", |
30 |
| - "Camera", |
31 |
| - "Core", |
32 |
| - "FollowMe", |
33 |
| - "Ftp", |
34 |
| - "Geofence", |
35 |
| - "Gimbal", |
36 |
| - "Info", |
37 |
| - "LogFiles", |
38 |
| - "Mission", |
39 |
| - "MissionRaw", |
40 |
| - "Mocap", |
41 |
| - "Offboard", |
42 |
| - "Param", |
43 |
| - "Shell", |
44 |
| - "Telemetry", |
45 |
| - "Tune", |
46 |
| - ] |
47 |
| - |
48 | 28 | def __init__(self, mavsdk_server_address=None, port=50051):
|
49 | 29 | """Instantiate a System object, that will serve as a proxy to
|
50 | 30 | all the MAVSDK plugins.
|
@@ -90,118 +70,136 @@ async def connect(self, system_address=None):
|
90 | 70 | async def _init_plugins(self, host, port):
|
91 | 71 | plugin_manager = await AsyncPluginManager.create(host=host, port=port)
|
92 | 72 |
|
93 |
| - for plugin in self._core_plugins: |
94 |
| - self._plugins[plugin.lower()] = globals()[plugin](plugin_manager) |
| 73 | + self._plugins = {} |
| 74 | + self._plugins["action"] = action.Action(plugin_manager) |
| 75 | + self._plugins["calibration"] = calibration.Calibration(plugin_manager) |
| 76 | + self._plugins["camera"] = camera.Camera(plugin_manager) |
| 77 | + self._plugins["core"] = core.Core(plugin_manager) |
| 78 | + self._plugins["follow_me"] = follow_me.FollowMe(plugin_manager) |
| 79 | + self._plugins["ftp"] = ftp.Ftp(plugin_manager) |
| 80 | + self._plugins["geofence"] = geofence.Geofence(plugin_manager) |
| 81 | + self._plugins["gimbal"] = gimbal.Gimbal(plugin_manager) |
| 82 | + self._plugins["info"] = info.Info(plugin_manager) |
| 83 | + self._plugins["log_files"] = log_files.LogFiles(plugin_manager) |
| 84 | + self._plugins["mission"] = mission.Mission(plugin_manager) |
| 85 | + self._plugins["mission_raw"] = mission_raw.MissionRaw(plugin_manager) |
| 86 | + self._plugins["mocap"] = mocap.Mocap(plugin_manager) |
| 87 | + self._plugins["offboard"] = offboard.Offboard(plugin_manager) |
| 88 | + self._plugins["param"] = param.Param(plugin_manager) |
| 89 | + self._plugins["shell"] = shell.Shell(plugin_manager) |
| 90 | + self._plugins["telemetry"] = telemetry.Telemetry(plugin_manager) |
| 91 | + self._plugins["tune"] = tune.Tune(plugin_manager) |
| 92 | + |
95 | 93 |
|
96 | 94 | @staticmethod
|
97 | 95 | def error_uninitialized(plugin_name: str) -> str:
|
98 | 96 | return "{plugin_name} plugin has not been initialized!" \
|
99 | 97 | "Did you run `System.connect()`?"
|
100 | 98 |
|
101 | 99 | @property
|
102 |
| - def action(self) -> Action: |
| 100 | + def action(self) -> action.Action: |
103 | 101 | if "action" not in self._plugins:
|
104 | 102 | raise RuntimeError(self.error_uninitialized("Action"))
|
105 | 103 | return self._plugins["action"]
|
106 | 104 |
|
107 | 105 | @property
|
108 |
| - def calibration(self) -> Calibration: |
| 106 | + def calibration(self) -> calibration.Calibration: |
109 | 107 | if "calibration" not in self._plugins:
|
110 | 108 | raise RuntimeError(self.error_uninitialized("Calibration"))
|
111 | 109 | return self._plugins["calibration"]
|
112 | 110 |
|
113 | 111 | @property
|
114 |
| - def camera(self) -> Camera: |
| 112 | + def camera(self) -> camera.Camera: |
115 | 113 | if "camera" not in self._plugins:
|
116 | 114 | raise RuntimeError(self.error_uninitialized("Camera"))
|
117 | 115 | return self._plugins["camera"]
|
118 | 116 |
|
119 | 117 | @property
|
120 |
| - def core(self) -> Core: |
| 118 | + def core(self) -> core.Core: |
121 | 119 | if "core" not in self._plugins:
|
122 | 120 | raise RuntimeError(self.error_uninitialized("Core"))
|
123 | 121 | return self._plugins["core"]
|
124 | 122 |
|
125 | 123 | @property
|
126 |
| - def follow_me(self) -> FollowMe: |
| 124 | + def follow_me(self) -> follow_me.FollowMe: |
127 | 125 | if "follow_me" not in self._plugins:
|
128 | 126 | raise RuntimeError(self.error_uninitialized("FollowMe"))
|
129 | 127 | return self._plugins["follow_me"]
|
130 | 128 |
|
131 | 129 | @property
|
132 |
| - def ftp(self) -> Ftp: |
| 130 | + def ftp(self) -> ftp.Ftp: |
133 | 131 | if "ftp" not in self._plugins:
|
134 | 132 | raise RuntimeError(self.error_uninitialized("Ftp"))
|
135 | 133 | return self._plugins["Ftp"]
|
136 | 134 |
|
137 | 135 | @property
|
138 |
| - def geofence(self) -> Geofence: |
| 136 | + def geofence(self) -> geofence.Geofence: |
139 | 137 | if "geofence" not in self._plugins:
|
140 | 138 | raise RuntimeError(self.error_uninitialized("Geofence"))
|
141 | 139 | return self._plugins["geofence"]
|
142 | 140 |
|
143 | 141 | @property
|
144 |
| - def gimbal(self) -> Gimbal: |
| 142 | + def gimbal(self) -> gimbal.Gimbal: |
145 | 143 | if "gimbal" not in self._plugins:
|
146 | 144 | raise RuntimeError(self.error_uninitialized("Gimbal"))
|
147 | 145 | return self._plugins["gimbal"]
|
148 | 146 |
|
149 | 147 | @property
|
150 |
| - def info(self) -> Info: |
| 148 | + def info(self) -> info.Info: |
151 | 149 | if "info" not in self._plugins:
|
152 | 150 | raise RuntimeError(self.error_uninitialized("Info"))
|
153 | 151 | return self._plugins["info"]
|
154 | 152 |
|
155 | 153 | @property
|
156 |
| - def log_files(self) -> LogFiles: |
| 154 | + def log_files(self) -> log_files.LogFiles: |
157 | 155 | if "log_files" not in self._plugins:
|
158 | 156 | raise RuntimeError(self.error_uninitialized("LogFiles"))
|
159 | 157 | return self._plugins["log_files"]
|
160 | 158 |
|
161 | 159 | @property
|
162 |
| - def mission(self) -> Mission: |
| 160 | + def mission(self) -> mission.Mission: |
163 | 161 | if "mission" not in self._plugins:
|
164 | 162 | raise RuntimeError(self.error_uninitialized("Mission"))
|
165 | 163 | return self._plugins["mission"]
|
166 | 164 |
|
167 | 165 | @property
|
168 |
| - def mission_raw(self) -> MissionRaw: |
| 166 | + def mission_raw(self) -> mission_raw.MissionRaw: |
169 | 167 | if "mission_raw" not in self._plugins:
|
170 | 168 | raise RuntimeError(self.error_uninitialized("MissionRaw"))
|
171 | 169 | return self._plugins["mission_raw"]
|
172 | 170 |
|
173 | 171 | @property
|
174 |
| - def mocap(self) -> Mocap: |
| 172 | + def mocap(self) -> mocap.Mocap: |
175 | 173 | if "mocap" not in self._plugins:
|
176 | 174 | raise RuntimeError(self.error_uninitialized("Mocap"))
|
177 | 175 | return self._plugins["mocap"]
|
178 | 176 |
|
179 | 177 | @property
|
180 |
| - def offboard(self) -> Offboard: |
| 178 | + def offboard(self) -> offboard.Offboard: |
181 | 179 | if "offboard" not in self._plugins:
|
182 | 180 | raise RuntimeError(self.error_uninitialized("Offboard"))
|
183 | 181 | return self._plugins["offboard"]
|
184 | 182 |
|
185 | 183 | @property
|
186 |
| - def param(self) -> Param: |
| 184 | + def param(self) -> param.Param: |
187 | 185 | if "param" not in self._plugins:
|
188 | 186 | raise RuntimeError(self.error_uninitialized("Param"))
|
189 | 187 | return self._plugins["param"]
|
190 | 188 |
|
191 | 189 | @property
|
192 |
| - def shell(self) -> Shell: |
| 190 | + def shell(self) -> shell.Shell: |
193 | 191 | if "shell" not in self._plugins:
|
194 | 192 | raise RuntimeError(self.error_uninitialized("Shell"))
|
195 | 193 | return self._plugins["shell"]
|
196 | 194 |
|
197 | 195 | @property
|
198 |
| - def telemetry(self) -> Telemetry: |
| 196 | + def telemetry(self) -> telemetry.Telemetry: |
199 | 197 | if "telemetry" not in self._plugins:
|
200 | 198 | raise RuntimeError(self.error_uninitialized("Telemetry"))
|
201 | 199 | return self._plugins["telemetry"]
|
202 | 200 |
|
203 | 201 | @property
|
204 |
| - def tune(self) -> Tune: |
| 202 | + def tune(self) -> tune.Tune: |
205 | 203 | if "tune" not in self._plugins:
|
206 | 204 | raise RuntimeError(self.error_uninitialized("Tune"))
|
207 | 205 | return self._plugins["tune"]
|
|
0 commit comments