Skip to content

Commit

Permalink
winch and gripper examples
Browse files Browse the repository at this point in the history
  • Loading branch information
potaito authored and julianoes committed Mar 7, 2024
1 parent 8e6e693 commit 5bfe7d4
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
32 changes: 32 additions & 0 deletions examples/gripper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python3

import asyncio
from mavsdk import System

async def run():
drone = System()
await drone.connect(system_address="udp://:14540")

print("Waiting for drone to connect...")
async for state in drone.core.connection_state():
if state.is_connected:
print(f"-- Connected to drone!")
break

print(f"-- Gripper Grab")
await drone.gripper.grab(instance=1)

await asyncio.sleep(1)

print(f"-- Gripper Release")
await drone.gripper.release(instance=1)

while True:
print("Staying connected, press Ctrl-C to exit")
await asyncio.sleep(1)


if __name__ == "__main__":
# Run the asyncio loop
asyncio.run(run())

27 changes: 27 additions & 0 deletions examples/winch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python3

import asyncio
from mavsdk import System

async def run():
drone = System()
await drone.connect(system_address="udp://:14540")

print("Waiting for drone to connect...")
async for state in drone.core.connection_state():
if state.is_connected:
print(f"-- Connected to drone!")
break

print(f"-- Winch action: load payload")
await drone.winch.load_payload(instance=1)

while True:
print("Staying connected, press Ctrl-C to exit")
await asyncio.sleep(1)


if __name__ == "__main__":
# Run the asyncio loop
asyncio.run(run())

0 comments on commit 5bfe7d4

Please sign in to comment.