Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import asyncio
- import websockets
- import subprocess
- async def client():
- async with websockets.connect('ws://localhost:8765') as websocket:
- id = input("Enter id:")
- id = "connect " + id
- await websocket.send(id)
- while True:
- rcvd_data = await websocket.recv()
- if rcvd_data == "take-off":
- # command to execute
- cmd_command = "type A:\\Desktop\\test.txt"
- cmd_command = "rosservice call /dji_sdk/drone_task_control \"task: 4\""
- elif rcvd_data == "land":
- cmd_command = "rosservice call /dji_sdk/drone_task_control \"task: 6\""
- process = subprocess.Popen(cmd_command.split(), shell=True, stdout=subprocess.PIPE)
- output, error = process.communicate()
- print(output.decode('utf-8'))
- # data = input()
- # await websocket.send(data)
- asyncio.get_event_loop().run_until_complete(client())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement