-
-
Notifications
You must be signed in to change notification settings - Fork 491
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
grpc: Support multiple device handling
Updates Dronecore Server, grpc plugin api's to consider UUID Updates Python Client examples to take UUID as a parameter for distinguishing between devices Adds a serive in dronecore plugin to fetch the list of UUID's discovered by dronecore server Adds multiple_device_handling.py to illustrate an example for handling multiple devices
- Loading branch information
Showing
13 changed files
with
148 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env python | ||
|
||
from __future__ import print_function | ||
import grpc | ||
import time | ||
import action_pb2 as dc_action | ||
import action_pb2_grpc | ||
import dronecore_pb2 as dronecore | ||
import dronecore_pb2_grpc | ||
from google.protobuf import empty_pb2 | ||
|
||
def run(): | ||
channel = grpc.insecure_channel('0.0.0.0:50051') | ||
action_stub = action_pb2_grpc.ActionRPCStub(channel) | ||
dronecore_stub = dronecore_pb2_grpc.DroneCoreRPCStub(channel) | ||
response=dronecore_stub.Get_UUID_List(empty_pb2.Empty()) | ||
size=len(response.uuid_list) | ||
print("Devices registered : {}".format(size)) | ||
print(response.uuid_list[0].uuid) | ||
|
||
for i in range(size): | ||
uuid_item=dronecore.UUID() | ||
uuid_item.uuid=response.uuid_list[i].uuid | ||
print(uuid_item.uuid) | ||
arm_result = action_stub.Arm(uuid_item) | ||
if arm_result.result == dc_action.ActionResult.SUCCESS: | ||
print("arming ok") | ||
else: | ||
print("arming failed: " + arm_result.result_str) | ||
|
||
time.sleep(2) | ||
|
||
takeoff_result = action_stub.TakeOff(uuid_item) | ||
if takeoff_result.result == dc_action.ActionResult.SUCCESS: | ||
print("takeoff ok") | ||
else: | ||
print("takeoff failed: " + takeoff_result.result_str) | ||
|
||
time.sleep(5) | ||
|
||
land_result = action_stub.Land(uuid_item) | ||
if land_result.result == dc_action.ActionResult.SUCCESS: | ||
print("landing ok") | ||
else: | ||
print("landing failed: " + land_result.result_str) | ||
|
||
|
||
if __name__ == '__main__': | ||
run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.