codrone-edu 2.9__tar.gz → 2.11__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {codrone_edu-2.9 → codrone_edu-2.11}/PKG-INFO +1 -1
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/drone.py +290 -33
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/protocol.py +254 -13
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/storage.py +6 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/system.py +104 -10
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/tools/transformer.py +144 -2
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/tools/update.py +1 -1
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu.egg-info/PKG-INFO +1 -1
- {codrone_edu-2.9 → codrone_edu-2.11}/setup.py +1 -1
- {codrone_edu-2.9 → codrone_edu-2.11}/MANIFEST.in +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/README.md +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/__init__.py +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/__main__.py +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/crc.py +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/data/black.txt +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/data/blue.txt +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/data/green.txt +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/data/lightblue.txt +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/data/purple.txt +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/data/red.txt +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/data/white.txt +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/data/yellow.txt +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/errors.py +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/receiver.py +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/swarm.py +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/tools/__init__.py +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/tools/interrupter.py +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/tools/module_loader.py +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/tools/parser.py +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu/tools/scrubber.py +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu.egg-info/SOURCES.txt +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu.egg-info/dependency_links.txt +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu.egg-info/not-zip-safe +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu.egg-info/requires.txt +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/codrone_edu.egg-info/top_level.txt +0 -0
- {codrone_edu-2.9 → codrone_edu-2.11}/setup.cfg +0 -0
|
@@ -137,7 +137,7 @@ class Drone:
|
|
|
137
137
|
# BaseFunctions Start
|
|
138
138
|
|
|
139
139
|
def __init__(self, flagCheckBackground=True, flagShowErrorMessage=False, flagShowLogMessage=False,
|
|
140
|
-
flagShowTransferData=False, flagShowReceiveData=False, swarm=False, color_data_dir=None):
|
|
140
|
+
flagShowTransferData=False, flagShowReceiveData=False, swarm=False, color_data_dir=None, flagShowDepLibraryVersion=True):
|
|
141
141
|
|
|
142
142
|
self._serialport = None
|
|
143
143
|
if sys.platform == 'emscripten':
|
|
@@ -270,10 +270,12 @@ class Drone:
|
|
|
270
270
|
library_name = "codrone-edu"
|
|
271
271
|
library = importlib.metadata.distribution(library_name)
|
|
272
272
|
if sys.platform != 'emscripten' and not self._swarm:
|
|
273
|
-
|
|
274
|
-
|
|
273
|
+
if flagShowDepLibraryVersion:
|
|
274
|
+
colorama.init()
|
|
275
|
+
print(Fore.GREEN + f"Running {library_name} library version {library.version}" + Style.RESET_ALL)
|
|
275
276
|
elif sys.platform == 'emscripten':
|
|
276
|
-
|
|
277
|
+
if flagShowDepLibraryVersion:
|
|
278
|
+
print("Running {0} library version {1}".format(library_name, library.version), color="green")
|
|
277
279
|
# this only works when using the release version of the library
|
|
278
280
|
|
|
279
281
|
def __del__(self):
|
|
@@ -1284,7 +1286,7 @@ class Drone:
|
|
|
1284
1286
|
speed_level = 1
|
|
1285
1287
|
|
|
1286
1288
|
self.sendCommand(CommandType.ControlSpeed, int(speed_level))
|
|
1287
|
-
if self.information_data[1]
|
|
1289
|
+
if is_jrotc_drone(self.information_data[1]):
|
|
1288
1290
|
time.sleep(0.03)
|
|
1289
1291
|
else:
|
|
1290
1292
|
time.sleep(0.01)
|
|
@@ -1308,6 +1310,70 @@ class Drone:
|
|
|
1308
1310
|
await asyncio.sleep(0.01)
|
|
1309
1311
|
await self._trigger_speed_callback()
|
|
1310
1312
|
|
|
1313
|
+
def control_change(self, mode=ModeControlFlight.Position):
|
|
1314
|
+
"""
|
|
1315
|
+
Changes the flight control mode of the drone.
|
|
1316
|
+
default is set to ModeControlFlight.Position
|
|
1317
|
+
:param mode: ModeControlFlight enum value (e.g. Attitude, Position)
|
|
1318
|
+
:return: N/A
|
|
1319
|
+
"""
|
|
1320
|
+
if not isinstance(mode, ModeControlFlight):
|
|
1321
|
+
return None
|
|
1322
|
+
|
|
1323
|
+
if sys.platform != 'emscripten' and not self._swarm:
|
|
1324
|
+
return self._control_change_desktop(mode)
|
|
1325
|
+
if sys.platform != 'emscripten' and self._swarm:
|
|
1326
|
+
return asyncio.create_task(self._control_change_swarm(mode))
|
|
1327
|
+
else:
|
|
1328
|
+
return asyncio.create_task(self._control_change_emscripten(mode))
|
|
1329
|
+
|
|
1330
|
+
def _control_change_desktop(self, mode=ModeControlFlight.Position):
|
|
1331
|
+
for _ in range(2):
|
|
1332
|
+
self.sendCommand(CommandType.ModeControlFlight, mode.value)
|
|
1333
|
+
time.sleep(0.03)
|
|
1334
|
+
|
|
1335
|
+
async def _control_change_swarm(self, mode=ModeControlFlight.Position):
|
|
1336
|
+
for _ in range(2):
|
|
1337
|
+
await self.sendCommand(CommandType.ModeControlFlight, mode.value)
|
|
1338
|
+
await asyncio.sleep(0.03)
|
|
1339
|
+
|
|
1340
|
+
async def _control_change_emscripten(self, mode=ModeControlFlight.Position):
|
|
1341
|
+
for _ in range(2):
|
|
1342
|
+
await self.sendCommand(CommandType.ModeControlFlight, mode.value)
|
|
1343
|
+
await asyncio.sleep(0.03)
|
|
1344
|
+
|
|
1345
|
+
def headless_change(self, mode=Headless.Normal):
|
|
1346
|
+
"""
|
|
1347
|
+
Changes the headless mode of the drone.
|
|
1348
|
+
default is set to Headless.Normal
|
|
1349
|
+
:param mode: Headless enum value (Headless, Normal)
|
|
1350
|
+
:return: N/A
|
|
1351
|
+
"""
|
|
1352
|
+
if not isinstance(mode, Headless):
|
|
1353
|
+
return None
|
|
1354
|
+
|
|
1355
|
+
if sys.platform != 'emscripten' and not self._swarm:
|
|
1356
|
+
return self._headless_change_desktop(mode)
|
|
1357
|
+
if sys.platform != 'emscripten' and self._swarm:
|
|
1358
|
+
return asyncio.create_task(self._headless_change_swarm(mode))
|
|
1359
|
+
else:
|
|
1360
|
+
return asyncio.create_task(self._headless_change_emscripten(mode))
|
|
1361
|
+
|
|
1362
|
+
def _headless_change_desktop(self, mode=Headless.Normal):
|
|
1363
|
+
for _ in range(3):
|
|
1364
|
+
self.sendCommand(CommandType.Headless, mode.value)
|
|
1365
|
+
time.sleep(0.03)
|
|
1366
|
+
|
|
1367
|
+
async def _headless_change_swarm(self, mode=Headless.Normal):
|
|
1368
|
+
for _ in range(3):
|
|
1369
|
+
await self.sendCommand(CommandType.Headless, mode.value)
|
|
1370
|
+
await asyncio.sleep(0.03)
|
|
1371
|
+
|
|
1372
|
+
async def _headless_change_emscripten(self, mode=Headless.Normal):
|
|
1373
|
+
for _ in range(3):
|
|
1374
|
+
await self.sendCommand(CommandType.Headless, mode.value)
|
|
1375
|
+
await asyncio.sleep(0.03)
|
|
1376
|
+
|
|
1311
1377
|
def update_motion_data(self, drone_type):
|
|
1312
1378
|
|
|
1313
1379
|
"""
|
|
@@ -2211,7 +2277,7 @@ class Drone:
|
|
|
2211
2277
|
if state_flight is ModeFlight.Ready:
|
|
2212
2278
|
device_info = self.get_information_data()
|
|
2213
2279
|
|
|
2214
|
-
if self.information_data[1]
|
|
2280
|
+
if is_jrotc_drone(self.information_data[1]):
|
|
2215
2281
|
print(Fore.GREEN + "Connected to CoDrone EDU (JROTC ed.)." + Style.RESET_ALL)
|
|
2216
2282
|
else:
|
|
2217
2283
|
print(Fore.GREEN + "Connected to CoDrone EDU." + Style.RESET_ALL)
|
|
@@ -2221,7 +2287,11 @@ class Drone:
|
|
|
2221
2287
|
# set the speed to medium level
|
|
2222
2288
|
self.speed_change(speed_level=2)
|
|
2223
2289
|
time.sleep(0.2)
|
|
2224
|
-
|
|
2290
|
+
self.control_change(mode=ModeControlFlight.Position)
|
|
2291
|
+
time.sleep(0.2)
|
|
2292
|
+
self.headless_change(mode=Headless.Normal)
|
|
2293
|
+
time.sleep(0.2)
|
|
2294
|
+
|
|
2225
2295
|
# disable the previous YPRT commands
|
|
2226
2296
|
self.sendControl(0, 0, 0, 0)
|
|
2227
2297
|
time.sleep(0.2)
|
|
@@ -2293,7 +2363,7 @@ class Drone:
|
|
|
2293
2363
|
if state_flight is ModeFlight.Ready:
|
|
2294
2364
|
device_info = await self.get_information_data()
|
|
2295
2365
|
|
|
2296
|
-
if self.information_data[1]
|
|
2366
|
+
if is_jrotc_drone(self.information_data[1]):
|
|
2297
2367
|
print(Fore.GREEN + "Connected to CoDrone EDU (JROTC ed.)." + Style.RESET_ALL)
|
|
2298
2368
|
else:
|
|
2299
2369
|
print(Fore.GREEN + "Connected to CoDrone EDU." + Style.RESET_ALL)
|
|
@@ -2303,6 +2373,10 @@ class Drone:
|
|
|
2303
2373
|
# set the speed to medium level
|
|
2304
2374
|
await self.speed_change(speed_level=2)
|
|
2305
2375
|
await asyncio.sleep(0.2)
|
|
2376
|
+
await self.control_change(mode=ModeControlFlight.Position)
|
|
2377
|
+
await asyncio.sleep(0.2)
|
|
2378
|
+
await self.headless_change(mode=Headless.Normal)
|
|
2379
|
+
await asyncio.sleep(0.2)
|
|
2306
2380
|
|
|
2307
2381
|
# disable the previous YPRT commands
|
|
2308
2382
|
await self.sendControl(0, 0, 0, 0)
|
|
@@ -2338,7 +2412,7 @@ class Drone:
|
|
|
2338
2412
|
|
|
2339
2413
|
device_info = await self.get_information_data()
|
|
2340
2414
|
|
|
2341
|
-
if device_info[
|
|
2415
|
+
if is_jrotc_drone(device_info[1]):
|
|
2342
2416
|
print("Connected to CoDrone EDU (JROTC ed.).", color="green")
|
|
2343
2417
|
else:
|
|
2344
2418
|
print("Connected to CoDrone EDU.", color="green")
|
|
@@ -2350,6 +2424,12 @@ class Drone:
|
|
|
2350
2424
|
await self.speed_change(speed_level=2)
|
|
2351
2425
|
await asyncio.sleep(0.2)
|
|
2352
2426
|
|
|
2427
|
+
# put all users in the same control/headless modes
|
|
2428
|
+
await self.control_change(mode=ModeControlFlight.Position)
|
|
2429
|
+
await asyncio.sleep(0.2)
|
|
2430
|
+
await self.headless_change(mode=Headless.Normal)
|
|
2431
|
+
await asyncio.sleep(0.2)
|
|
2432
|
+
|
|
2353
2433
|
# disable the previous YPRT commands
|
|
2354
2434
|
await self.sendControl(0, 0, 0, 0)
|
|
2355
2435
|
await asyncio.sleep(0.2)
|
|
@@ -2543,7 +2623,7 @@ class Drone:
|
|
|
2543
2623
|
|
|
2544
2624
|
if monitor0.monitorDataType == MonitorDataType.F32:
|
|
2545
2625
|
|
|
2546
|
-
dataCount = (
|
|
2626
|
+
dataCount = (len(dataArray) - 1 - Monitor0.getSize()) // 4
|
|
2547
2627
|
|
|
2548
2628
|
for i in range(0, dataCount):
|
|
2549
2629
|
|
|
@@ -2559,7 +2639,7 @@ class Drone:
|
|
|
2559
2639
|
|
|
2560
2640
|
self.systemTimeMonitorData = monitor4.systemTime
|
|
2561
2641
|
|
|
2562
|
-
dataCount = (
|
|
2642
|
+
dataCount = (len(dataArray) - 1 - Monitor4.getSize()) // 4
|
|
2563
2643
|
|
|
2564
2644
|
for i in range(0, dataCount):
|
|
2565
2645
|
|
|
@@ -2575,7 +2655,7 @@ class Drone:
|
|
|
2575
2655
|
|
|
2576
2656
|
self.systemTimeMonitorData = monitor8.systemTime
|
|
2577
2657
|
|
|
2578
|
-
dataCount = (
|
|
2658
|
+
dataCount = (len(dataArray) - 1 - Monitor8.getSize()) // 4
|
|
2579
2659
|
|
|
2580
2660
|
for i in range(0, dataCount):
|
|
2581
2661
|
|
|
@@ -3408,7 +3488,7 @@ class Drone:
|
|
|
3408
3488
|
"""
|
|
3409
3489
|
:param distance: the numerical value of the value to move
|
|
3410
3490
|
:param units: can either be in inches, centimeters, meters, feet.
|
|
3411
|
-
:param speed: default
|
|
3491
|
+
:param speed: default 0.5 meter per second. Max is 2 meters/second.
|
|
3412
3492
|
:return: N/A
|
|
3413
3493
|
"""
|
|
3414
3494
|
if sys.platform != 'emscripten' and not self._swarm:
|
|
@@ -3497,7 +3577,7 @@ class Drone:
|
|
|
3497
3577
|
"""
|
|
3498
3578
|
:param distance: the numerical value of the value to move
|
|
3499
3579
|
:param units: can either be in inches, centimeters, meters, feet.
|
|
3500
|
-
:param speed: default
|
|
3580
|
+
:param speed: default 0.5 meter per second. Max is 2 meters/second.
|
|
3501
3581
|
:return: N/A
|
|
3502
3582
|
"""
|
|
3503
3583
|
if sys.platform != 'emscripten' and not self._swarm:
|
|
@@ -3586,7 +3666,7 @@ class Drone:
|
|
|
3586
3666
|
"""
|
|
3587
3667
|
:param distance: the numerical value of the value to move
|
|
3588
3668
|
:param units: can either be in inches, centimeters, meters, feet.
|
|
3589
|
-
:param speed: default
|
|
3669
|
+
:param speed: default 0.5 meter per second. Max is 2 meters/second.
|
|
3590
3670
|
:return: N/A
|
|
3591
3671
|
"""
|
|
3592
3672
|
if sys.platform != 'emscripten' and not self._swarm:
|
|
@@ -3674,7 +3754,7 @@ class Drone:
|
|
|
3674
3754
|
"""
|
|
3675
3755
|
:param distance: the numerical value of the value to move
|
|
3676
3756
|
:param units: can either be in inches, centimeters, meters, feet.
|
|
3677
|
-
:param speed: default
|
|
3757
|
+
:param speed: default 0.5 meter per second. Max is 2 meters/second.
|
|
3678
3758
|
:return: N/A
|
|
3679
3759
|
"""
|
|
3680
3760
|
if sys.platform != 'emscripten' and not self._swarm:
|
|
@@ -3758,6 +3838,183 @@ class Drone:
|
|
|
3758
3838
|
|
|
3759
3839
|
await asyncio.sleep(delay + 1.0)
|
|
3760
3840
|
|
|
3841
|
+
|
|
3842
|
+
def move_upward(self, distance, units="cm", speed=0.5):
|
|
3843
|
+
"""
|
|
3844
|
+
:param distance: the numerical value of the value to move
|
|
3845
|
+
:param units: can either be in inches, centimeters, meters, feet.
|
|
3846
|
+
:param speed: default 0.5 meter per second. Max is 2 meters/second.
|
|
3847
|
+
:return: N/A
|
|
3848
|
+
"""
|
|
3849
|
+
if sys.platform != 'emscripten' and not self._swarm:
|
|
3850
|
+
return self._move_upward_desktop(distance, units, speed)
|
|
3851
|
+
else:
|
|
3852
|
+
return asyncio.create_task(self._move_upward_emscripten(distance, units, speed))
|
|
3853
|
+
|
|
3854
|
+
def _move_upward_desktop(self, distance, units="cm", speed=0.5):
|
|
3855
|
+
if units == "cm":
|
|
3856
|
+
distance_meters = distance / 100
|
|
3857
|
+
elif units == "ft":
|
|
3858
|
+
distance_meters = distance / 3.28084
|
|
3859
|
+
elif units == "in":
|
|
3860
|
+
distance_meters = distance / 39.37
|
|
3861
|
+
elif units == "m":
|
|
3862
|
+
distance_meters = distance * 1
|
|
3863
|
+
else:
|
|
3864
|
+
print(Fore.RED + "Error: Not a valid unit." + Style.RESET_ALL)
|
|
3865
|
+
return
|
|
3866
|
+
|
|
3867
|
+
# cap the speed
|
|
3868
|
+
if speed > 2:
|
|
3869
|
+
speed = 2
|
|
3870
|
+
elif speed < 0:
|
|
3871
|
+
speed = 0
|
|
3872
|
+
|
|
3873
|
+
self.sendControlPosition(positionX=0,
|
|
3874
|
+
positionY=0,
|
|
3875
|
+
positionZ=distance_meters,
|
|
3876
|
+
velocity=speed,
|
|
3877
|
+
heading=0,
|
|
3878
|
+
rotationalVelocity=0)
|
|
3879
|
+
|
|
3880
|
+
delay = distance_meters / speed
|
|
3881
|
+
|
|
3882
|
+
time.sleep(0.1)
|
|
3883
|
+
|
|
3884
|
+
while self.get_movement_state() != ModeMovement.Moving:
|
|
3885
|
+
self.sendControlPosition(positionX=0, positionY=0, positionZ=distance_meters, velocity=speed,
|
|
3886
|
+
heading=0,
|
|
3887
|
+
rotationalVelocity=0)
|
|
3888
|
+
time.sleep(0.1)
|
|
3889
|
+
|
|
3890
|
+
time.sleep(delay + 1.0)
|
|
3891
|
+
|
|
3892
|
+
async def _move_upward_emscripten(self, distance, units="cm", speed=0.5):
|
|
3893
|
+
if units == "cm":
|
|
3894
|
+
distance_meters = distance / 100
|
|
3895
|
+
elif units == "ft":
|
|
3896
|
+
distance_meters = distance / 3.28084
|
|
3897
|
+
elif units == "in":
|
|
3898
|
+
distance_meters = distance / 39.37
|
|
3899
|
+
elif units == "m":
|
|
3900
|
+
distance_meters = distance * 1
|
|
3901
|
+
else:
|
|
3902
|
+
print("Error: Not a valid unit.", color="error")
|
|
3903
|
+
return
|
|
3904
|
+
|
|
3905
|
+
# cap the speed
|
|
3906
|
+
if speed > 2:
|
|
3907
|
+
speed = 2
|
|
3908
|
+
elif speed < 0:
|
|
3909
|
+
speed = 0
|
|
3910
|
+
|
|
3911
|
+
await self.sendControlPosition(positionX=0,
|
|
3912
|
+
positionY=0,
|
|
3913
|
+
positionZ=distance_meters,
|
|
3914
|
+
velocity=speed,
|
|
3915
|
+
heading=0,
|
|
3916
|
+
rotationalVelocity=0)
|
|
3917
|
+
|
|
3918
|
+
delay = distance_meters / speed
|
|
3919
|
+
|
|
3920
|
+
await asyncio.sleep(0.1)
|
|
3921
|
+
|
|
3922
|
+
while (await self.get_movement_state()) != ModeMovement.Moving:
|
|
3923
|
+
await self.sendControlPosition(positionX=0, positionY=0, positionZ=distance_meters, velocity=speed,
|
|
3924
|
+
heading=0,
|
|
3925
|
+
rotationalVelocity=0)
|
|
3926
|
+
await asyncio.sleep(0.10)
|
|
3927
|
+
|
|
3928
|
+
await asyncio.sleep(delay + 1.0)
|
|
3929
|
+
|
|
3930
|
+
def move_downward(self, distance, units="cm", speed=0.5):
|
|
3931
|
+
"""
|
|
3932
|
+
:param distance: the numerical value of the value to move
|
|
3933
|
+
:param units: can either be in inches, centimeters, meters, feet.
|
|
3934
|
+
:param speed: default 0.5 meter per second. Max is 2 meters/second.
|
|
3935
|
+
:return: N/A
|
|
3936
|
+
"""
|
|
3937
|
+
if sys.platform != 'emscripten' and not self._swarm:
|
|
3938
|
+
return self._move_downward_desktop(distance, units, speed)
|
|
3939
|
+
else:
|
|
3940
|
+
return asyncio.create_task(self._move_downward_emscripten(distance, units, speed))
|
|
3941
|
+
|
|
3942
|
+
def _move_downward_desktop(self, distance, units="cm", speed=0.5):
|
|
3943
|
+
if units == "cm":
|
|
3944
|
+
distance_meters = distance / 100
|
|
3945
|
+
elif units == "ft":
|
|
3946
|
+
distance_meters = distance / 3.28084
|
|
3947
|
+
elif units == "in":
|
|
3948
|
+
distance_meters = distance / 39.37
|
|
3949
|
+
elif units == "m":
|
|
3950
|
+
distance_meters = distance * 1
|
|
3951
|
+
else:
|
|
3952
|
+
print(Fore.RED + "Error: Not a valid unit." + Style.RESET_ALL)
|
|
3953
|
+
return
|
|
3954
|
+
|
|
3955
|
+
# cap the speed
|
|
3956
|
+
if speed > 2:
|
|
3957
|
+
speed = 2
|
|
3958
|
+
elif speed < 0:
|
|
3959
|
+
speed = 0
|
|
3960
|
+
|
|
3961
|
+
self.sendControlPosition(positionX=0,
|
|
3962
|
+
positionY=0,
|
|
3963
|
+
positionZ=-distance_meters,
|
|
3964
|
+
velocity=speed,
|
|
3965
|
+
heading=0,
|
|
3966
|
+
rotationalVelocity=0)
|
|
3967
|
+
|
|
3968
|
+
delay = distance_meters / speed
|
|
3969
|
+
|
|
3970
|
+
time.sleep(0.1)
|
|
3971
|
+
|
|
3972
|
+
while self.get_movement_state() != ModeMovement.Moving:
|
|
3973
|
+
self.sendControlPosition(positionX=0, positionY=0, positionZ=-distance_meters, velocity=speed,
|
|
3974
|
+
heading=0,
|
|
3975
|
+
rotationalVelocity=0)
|
|
3976
|
+
time.sleep(0.1)
|
|
3977
|
+
|
|
3978
|
+
time.sleep(delay + 1.0)
|
|
3979
|
+
|
|
3980
|
+
async def _move_downward_emscripten(self, distance, units="cm", speed=0.5):
|
|
3981
|
+
if units == "cm":
|
|
3982
|
+
distance_meters = distance / 100
|
|
3983
|
+
elif units == "ft":
|
|
3984
|
+
distance_meters = distance / 3.28084
|
|
3985
|
+
elif units == "in":
|
|
3986
|
+
distance_meters = distance / 39.37
|
|
3987
|
+
elif units == "m":
|
|
3988
|
+
distance_meters = distance * 1
|
|
3989
|
+
else:
|
|
3990
|
+
print("Error: Not a valid unit.", color="error")
|
|
3991
|
+
return
|
|
3992
|
+
|
|
3993
|
+
# cap the speed
|
|
3994
|
+
if speed > 2:
|
|
3995
|
+
speed = 2
|
|
3996
|
+
elif speed < 0:
|
|
3997
|
+
speed = 0
|
|
3998
|
+
|
|
3999
|
+
await self.sendControlPosition(positionX=0,
|
|
4000
|
+
positionY=0,
|
|
4001
|
+
positionZ=-distance_meters,
|
|
4002
|
+
velocity=speed,
|
|
4003
|
+
heading=0,
|
|
4004
|
+
rotationalVelocity=0)
|
|
4005
|
+
|
|
4006
|
+
delay = distance_meters / speed
|
|
4007
|
+
|
|
4008
|
+
await asyncio.sleep(0.1)
|
|
4009
|
+
|
|
4010
|
+
while (await self.get_movement_state()) != ModeMovement.Moving:
|
|
4011
|
+
await self.sendControlPosition(positionX=0, positionY=0, positionZ=-distance_meters, velocity=speed,
|
|
4012
|
+
heading=0,
|
|
4013
|
+
rotationalVelocity=0)
|
|
4014
|
+
await asyncio.sleep(0.10)
|
|
4015
|
+
|
|
4016
|
+
await asyncio.sleep(delay + 1.0)
|
|
4017
|
+
|
|
3761
4018
|
def send_absolute_position(self, positionX, positionY, positionZ, velocity, heading, rotationalVelocity):
|
|
3762
4019
|
"""
|
|
3763
4020
|
drone movement command
|
|
@@ -3813,7 +4070,7 @@ class Drone:
|
|
|
3813
4070
|
# store current position and z_angle
|
|
3814
4071
|
pos_data = None
|
|
3815
4072
|
z_angle = None # angle offset between G_new and L
|
|
3816
|
-
if self.information_data[1]
|
|
4073
|
+
if is_jrotc_drone(self.information_data[1]):
|
|
3817
4074
|
for _ in range(3):
|
|
3818
4075
|
pos_data = self.get_position_data()
|
|
3819
4076
|
z_angle = self.get_angle_z()
|
|
@@ -3948,7 +4205,7 @@ class Drone:
|
|
|
3948
4205
|
# store current position and z_angle
|
|
3949
4206
|
pos_data = None
|
|
3950
4207
|
z_angle = None # angle offset between G_new and L
|
|
3951
|
-
if self.information_data[1]
|
|
4208
|
+
if is_jrotc_drone(self.information_data[1]):
|
|
3952
4209
|
for _ in range(3):
|
|
3953
4210
|
pos_data = await self.get_position_data()
|
|
3954
4211
|
z_angle = await self.get_angle_z()
|
|
@@ -4528,7 +4785,7 @@ class Drone:
|
|
|
4528
4785
|
"""
|
|
4529
4786
|
A looped method that makes the drone fly forward until it reaches
|
|
4530
4787
|
a desired distance. The drone will keep that distance.
|
|
4531
|
-
The range of front sensor is from 0cm-
|
|
4788
|
+
The range of front sensor is from 0cm-150cm
|
|
4532
4789
|
|
|
4533
4790
|
:param timeout: duration in seconds that function will run
|
|
4534
4791
|
:param distance: distance in cm the drone will maintain in front of object
|
|
@@ -4580,7 +4837,7 @@ class Drone:
|
|
|
4580
4837
|
def detect_wall(self, distance=50):
|
|
4581
4838
|
"""
|
|
4582
4839
|
Returns True when a distance below the threshold is reached.
|
|
4583
|
-
The range of front sensor is from 0cm-
|
|
4840
|
+
The range of front sensor is from 0cm-150cm
|
|
4584
4841
|
|
|
4585
4842
|
:param distance: threshold in millimeters that returns True
|
|
4586
4843
|
:return: Boolean
|
|
@@ -7117,7 +7374,7 @@ class Drone:
|
|
|
7117
7374
|
return image
|
|
7118
7375
|
|
|
7119
7376
|
async def _controller_create_canvas_emscripten(self, color="white"):
|
|
7120
|
-
if (await self.get_information_data())[
|
|
7377
|
+
if is_jrotc_drone((await self.get_information_data())[1]):
|
|
7121
7378
|
warnings.warn(
|
|
7122
7379
|
"This function is not currently supported for CoDrone EDU (JROTC ed.).",
|
|
7123
7380
|
RuntimeWarning,
|
|
@@ -7230,7 +7487,7 @@ class Drone:
|
|
|
7230
7487
|
raise InvalidDrawColorError("Invalid color. Color value must be 'white' or 'black'")
|
|
7231
7488
|
|
|
7232
7489
|
async def _controller_draw_line_emscripten(self, x1, y1, x2, y2, image, color, pixel_width):
|
|
7233
|
-
if (await self.get_information_data())[
|
|
7490
|
+
if is_jrotc_drone((await self.get_information_data())[1]):
|
|
7234
7491
|
warnings.warn(
|
|
7235
7492
|
"This function is not currently supported for CoDrone EDU (JROTC ed.).",
|
|
7236
7493
|
RuntimeWarning,
|
|
@@ -7288,7 +7545,7 @@ class Drone:
|
|
|
7288
7545
|
raise InvalidDrawColorError("Invalid color. Color value must be 'white' or 'black'")
|
|
7289
7546
|
|
|
7290
7547
|
async def _controller_draw_rectangle_emscripten(self, x, y, width, height, image, color, fill_in, pixel_width):
|
|
7291
|
-
if (await self.get_information_data())[
|
|
7548
|
+
if is_jrotc_drone((await self.get_information_data())[1]):
|
|
7292
7549
|
warnings.warn(
|
|
7293
7550
|
"This function is not currently supported for CoDrone EDU (JROTC ed.).",
|
|
7294
7551
|
RuntimeWarning,
|
|
@@ -7346,7 +7603,7 @@ class Drone:
|
|
|
7346
7603
|
raise InvalidDrawColorError("Invalid color. Color value must be 'white' or 'black'")
|
|
7347
7604
|
|
|
7348
7605
|
async def _controller_draw_square_emscripten(self, x, y, width, image, color, fill_in, pixel_width):
|
|
7349
|
-
if (await self.get_information_data())[
|
|
7606
|
+
if is_jrotc_drone((await self.get_information_data())[1]):
|
|
7350
7607
|
warnings.warn(
|
|
7351
7608
|
"This function is not currently supported for CoDrone EDU (JROTC ed.).",
|
|
7352
7609
|
RuntimeWarning,
|
|
@@ -7394,7 +7651,7 @@ class Drone:
|
|
|
7394
7651
|
raise InvalidDrawColorError("Invalid color. Color value must be 'white' or 'black'")
|
|
7395
7652
|
|
|
7396
7653
|
async def _controller_draw_point_emscripten(self, x, y, image, color):
|
|
7397
|
-
if (await self.get_information_data())[
|
|
7654
|
+
if is_jrotc_drone((await self.get_information_data())[1]):
|
|
7398
7655
|
warnings.warn(
|
|
7399
7656
|
"This function is not currently supported for CoDrone EDU (JROTC ed.).",
|
|
7400
7657
|
RuntimeWarning,
|
|
@@ -7426,7 +7683,7 @@ class Drone:
|
|
|
7426
7683
|
self.sendDisplayClearAll(pixel)
|
|
7427
7684
|
|
|
7428
7685
|
async def _controller_clear_screen_emscripten(self, pixel=DisplayPixel.White):
|
|
7429
|
-
if (await self.get_information_data())[
|
|
7686
|
+
if is_jrotc_drone((await self.get_information_data())[1]):
|
|
7430
7687
|
warnings.warn(
|
|
7431
7688
|
"This function is not currently supported for CoDrone EDU (JROTC ed.).",
|
|
7432
7689
|
RuntimeWarning,
|
|
@@ -7481,7 +7738,7 @@ class Drone:
|
|
|
7481
7738
|
|
|
7482
7739
|
|
|
7483
7740
|
async def _controller_draw_polygon_emscripten(self, point_list, image, color, fill_in, pixel_width):
|
|
7484
|
-
if (await self.get_information_data())[
|
|
7741
|
+
if is_jrotc_drone((await self.get_information_data())[1]):
|
|
7485
7742
|
warnings.warn(
|
|
7486
7743
|
"This function is not currently supported for CoDrone EDU (JROTC ed.).",
|
|
7487
7744
|
RuntimeWarning,
|
|
@@ -7548,7 +7805,7 @@ class Drone:
|
|
|
7548
7805
|
raise InvalidDrawColorError("Invalid color. Color value must be 'white' or 'black'")
|
|
7549
7806
|
|
|
7550
7807
|
async def _controller_draw_ellipse_emscripten(self, ellipse_list, image, color, fill_in=None, pixel_width=1):
|
|
7551
|
-
if (await self.get_information_data())[
|
|
7808
|
+
if is_jrotc_drone((await self.get_information_data())[1]):
|
|
7552
7809
|
warnings.warn(
|
|
7553
7810
|
"This function is not currently supported for CoDrone EDU (JROTC ed.).",
|
|
7554
7811
|
RuntimeWarning,
|
|
@@ -7613,7 +7870,7 @@ class Drone:
|
|
|
7613
7870
|
raise InvalidDrawColorError("Invalid color. Color value must be 'white' or 'black'")
|
|
7614
7871
|
|
|
7615
7872
|
async def _controller_draw_arc_emscripten(self, arc_list, start_angle, end_angle, image, color, pixel_width):
|
|
7616
|
-
if (await self.get_information_data())[
|
|
7873
|
+
if is_jrotc_drone((await self.get_information_data())[1]):
|
|
7617
7874
|
warnings.warn(
|
|
7618
7875
|
"This function is not currently supported for CoDrone EDU (JROTC ed.).",
|
|
7619
7876
|
RuntimeWarning,
|
|
@@ -7679,7 +7936,7 @@ class Drone:
|
|
|
7679
7936
|
raise InvalidDrawColorError("Invalid color. Color value must be 'white' or 'black'")
|
|
7680
7937
|
|
|
7681
7938
|
async def _controller_draw_chord_emscripten(self, chord_list, start_angle, end_angle, image, color, fill_in, pixel_width):
|
|
7682
|
-
if (await self.get_information_data())[
|
|
7939
|
+
if is_jrotc_drone((await self.get_information_data())[1]):
|
|
7683
7940
|
warnings.warn(
|
|
7684
7941
|
"This function is not currently supported for CoDrone EDU (JROTC ed.).",
|
|
7685
7942
|
RuntimeWarning,
|
|
@@ -7735,7 +7992,7 @@ class Drone:
|
|
|
7735
7992
|
raise InvalidDrawColorError("Invalid color. Color value must be 'white' or 'black'")
|
|
7736
7993
|
|
|
7737
7994
|
async def _controller_draw_string_emscripten(self, x, y, string, image, color):
|
|
7738
|
-
if (await self.get_information_data())[
|
|
7995
|
+
if is_jrotc_drone((await self.get_information_data())[1]):
|
|
7739
7996
|
warnings.warn(
|
|
7740
7997
|
"This function is not currently supported for CoDrone EDU (JROTC ed.).",
|
|
7741
7998
|
RuntimeWarning,
|
|
@@ -7809,7 +8066,7 @@ class Drone:
|
|
|
7809
8066
|
raise InvalidDrawColorError("Invalid color. Color value must be 'white' or 'black'")
|
|
7810
8067
|
|
|
7811
8068
|
async def _controller_draw_string_align_emscripten(self, x_start, x_end, y, string, image, color, alignment):
|
|
7812
|
-
if (await self.get_information_data())[
|
|
8069
|
+
if is_jrotc_drone((await self.get_information_data())[1]):
|
|
7813
8070
|
warnings.warn(
|
|
7814
8071
|
"This function is not currently supported for CoDrone EDU (JROTC ed.).",
|
|
7815
8072
|
RuntimeWarning,
|
|
@@ -7896,7 +8153,7 @@ class Drone:
|
|
|
7896
8153
|
return
|
|
7897
8154
|
|
|
7898
8155
|
async def _controller_draw_image_emscripten(self, pixel_list):
|
|
7899
|
-
if (await self.get_information_data())[
|
|
8156
|
+
if is_jrotc_drone((await self.get_information_data())[1]):
|
|
7900
8157
|
warnings.warn(
|
|
7901
8158
|
"This function is not currently supported for CoDrone EDU (JROTC ed.).",
|
|
7902
8159
|
RuntimeWarning,
|