Skip to content

Commit b45f3d7

Browse files
Merge pull request #202 from mavlink/pr-improve-instructions
Improve instructions for unsupported architectures
2 parents adf41e0 + 1cab2dc commit b45f3d7

File tree

1 file changed

+99
-27
lines changed

1 file changed

+99
-27
lines changed

mavsdk/system.py

Lines changed: 99 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
# -*- coding: utf-8 -*-
22

3-
from .async_plugin_manager import AsyncPluginManager # NOQA
4-
from .generated import * # NOQA
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
522

623
from . import bin
724

@@ -12,15 +29,20 @@ class System:
1229
"Calibration",
1330
"Camera",
1431
"Core",
32+
"FollowMe",
33+
"Ftp",
1534
"Geofence",
1635
"Gimbal",
1736
"Info",
37+
"LogFiles",
1838
"Mission",
39+
"MissionRaw",
1940
"Mocap",
20-
"Param",
2141
"Offboard",
42+
"Param",
2243
"Shell",
23-
"Telemetry"
44+
"Telemetry",
45+
"Tune",
2446
]
2547

2648
def __init__(self, mavsdk_server_address=None, port=50051):
@@ -71,83 +93,118 @@ async def _init_plugins(self, host, port):
7193
for plugin in self._core_plugins:
7294
self._plugins[plugin.lower()] = globals()[plugin](plugin_manager)
7395

96+
@staticmethod
97+
def error_uninitialized(plugin_name: str) -> str:
98+
return "{plugin_name} plugin has not been initialized!" \
99+
"Did you run `System.connect()`?"
100+
74101
@property
75102
def action(self) -> Action:
76103
if "action" not in self._plugins:
77-
raise RuntimeError("Action plugin has not been initialized! Did you run `System.connect()`?")
104+
raise RuntimeError(self.error_uninitialized("Action"))
78105
return self._plugins["action"]
79106

80107
@property
81108
def calibration(self) -> Calibration:
82109
if "calibration" not in self._plugins:
83-
raise RuntimeError("Calibration plugin has not been initialized! Did you run `System.connect()`?")
110+
raise RuntimeError(self.error_uninitialized("Calibration"))
84111
return self._plugins["calibration"]
85112

86113
@property
87114
def camera(self) -> Camera:
88115
if "camera" not in self._plugins:
89-
raise RuntimeError("Camera plugin has not been initialized! Did you run `System.connect()`?")
116+
raise RuntimeError(self.error_uninitialized("Camera"))
90117
return self._plugins["camera"]
91118

92119
@property
93120
def core(self) -> Core:
94121
if "core" not in self._plugins:
95-
raise RuntimeError("Core plugin has not been initialized! Did you run `System.connect()`?")
122+
raise RuntimeError(self.error_uninitialized("Core"))
96123
return self._plugins["core"]
97124

125+
@property
126+
def follow_me(self) -> FollowMe:
127+
if "follow_me" not in self._plugins:
128+
raise RuntimeError(self.error_uninitialized("FollowMe"))
129+
return self._plugins["follow_me"]
130+
131+
@property
132+
def ftp(self) -> Ftp:
133+
if "ftp" not in self._plugins:
134+
raise RuntimeError(self.error_uninitialized("Ftp"))
135+
return self._plugins["Ftp"]
136+
98137
@property
99138
def geofence(self) -> Geofence:
100139
if "geofence" not in self._plugins:
101-
raise RuntimeError("Geofence plugin has not been initialized! Did you run `System.connect()`?")
140+
raise RuntimeError(self.error_uninitialized("Geofence"))
102141
return self._plugins["geofence"]
103142

104143
@property
105144
def gimbal(self) -> Gimbal:
106145
if "gimbal" not in self._plugins:
107-
raise RuntimeError("Gimbal plugin has not been initialized! Did you run `System.connect()`?")
146+
raise RuntimeError(self.error_uninitialized("Gimbal"))
108147
return self._plugins["gimbal"]
109148

110149
@property
111150
def info(self) -> Info:
112151
if "info" not in self._plugins:
113-
raise RuntimeError("Info plugin has not been initialized! Did you run `System.connect()`?")
152+
raise RuntimeError(self.error_uninitialized("Info"))
114153
return self._plugins["info"]
115154

155+
@property
156+
def log_files(self) -> LogFiles:
157+
if "log_files" not in self._plugins:
158+
raise RuntimeError(self.error_uninitialized("LogFiles"))
159+
return self._plugins["log_files"]
160+
116161
@property
117162
def mission(self) -> Mission:
118163
if "mission" not in self._plugins:
119-
raise RuntimeError("Mission plugin has not been initialized! Did you run `System.connect()`?")
164+
raise RuntimeError(self.error_uninitialized("Mission"))
120165
return self._plugins["mission"]
121166

122167
@property
123-
def param(self) -> Param:
124-
if "param" not in self._plugins:
125-
raise RuntimeError("Param plugin has not been initialized! Did you run `System.connect()`?")
126-
return self._plugins["param"]
168+
def mission_raw(self) -> MissionRaw:
169+
if "mission_raw" not in self._plugins:
170+
raise RuntimeError(self.error_uninitialized("MissionRaw"))
171+
return self._plugins["mission_raw"]
172+
173+
@property
174+
def mocap(self) -> Mocap:
175+
if "mocap" not in self._plugins:
176+
raise RuntimeError(self.error_uninitialized("Mocap"))
177+
return self._plugins["mocap"]
127178

128179
@property
129180
def offboard(self) -> Offboard:
130181
if "offboard" not in self._plugins:
131-
raise RuntimeError("Offboard plugin has not been initialized! Did you run `System.connect()`?")
182+
raise RuntimeError(self.error_uninitialized("Offboard"))
132183
return self._plugins["offboard"]
133184

134185
@property
135-
def telemetry(self) -> Telemetry:
136-
if "telemetry" not in self._plugins:
137-
raise RuntimeError("Telemetry plugin has not been initialized! Did you run `System.connect()`?")
138-
return self._plugins["telemetry"]
186+
def param(self) -> Param:
187+
if "param" not in self._plugins:
188+
raise RuntimeError(self.error_uninitialized("Param"))
189+
return self._plugins["param"]
139190

140191
@property
141192
def shell(self) -> Shell:
142193
if "shell" not in self._plugins:
143-
raise RuntimeError("Shell plugin has not been initialized! Did you run `System.connect()`?")
194+
raise RuntimeError(self.error_uninitialized("Shell"))
144195
return self._plugins["shell"]
145196

146197
@property
147-
def mocap(self) -> Mocap:
148-
if "mocap" not in self._plugins:
149-
raise RuntimeError("Mocap plugin has not been initialized! Did you run `System.connect()`?")
150-
return self._plugins["mocap"]
198+
def telemetry(self) -> Telemetry:
199+
if "telemetry" not in self._plugins:
200+
raise RuntimeError(self.error_uninitialized("Telemetry"))
201+
return self._plugins["telemetry"]
202+
203+
@property
204+
def tune(self) -> Tune:
205+
if "tune" not in self._plugins:
206+
raise RuntimeError(self.error_uninitialized("Tune"))
207+
return self._plugins["tune"]
151208

152209
@staticmethod
153210
def _start_mavsdk_server(system_address=None):
@@ -174,8 +231,23 @@ def _start_mavsdk_server(system_address=None):
174231
stdout=subprocess.DEVNULL,
175232
stderr=subprocess.DEVNULL)
176233
except FileNotFoundError:
177-
raise Exception("\nIt seems like this installation does not provide an embedded 'mavsdk_server' binary. If you installed from pip, it means that 'mavsdk_server' is not distributed for your platform (yet). You will need to get and run it manually:\n\n\t1. Build 'mavsdk_server': https://github.com/mavlink/mavsdk.\n\t2. Run it, e.g. on port 50051: './mavsdk_server -p 50051'.\n\t3. Set the 'mavsdk_server_address' and port when creating the System: 'drone = System(mavsdk_server_address='localhost', port=50051)\n")
234+
print("""
235+
This installation does not provide an embedded 'mavsdk_server' binary.
236+
If you installed using pip, this means that 'mavsdk_server' is not distributed
237+
for your platform yet (e.g. arm).
238+
239+
You will need to get and run the 'mavsdk_server' binary manually:
240+
241+
1. Download 'mavsdk_server' from: https://github.com/mavlink/mavsdk/releases
242+
or build it from source.
243+
244+
2. Run it, e.g. on port 50051:
245+
'./mavsdk_server -p 50051'
178246
247+
3. Set the 'mavsdk_server_address' and port when creating the System:
248+
'drone = System(mavsdk_server_address='localhost', port=50051)'
249+
""")
250+
sys.exit(1)
179251

180252
def cleanup():
181253
p.kill()

0 commit comments

Comments
 (0)