Skip to content

Commit

Permalink
Merge pull request #236 from mavlink/pr-offboard-attitude-enhancement
Browse files Browse the repository at this point in the history
Examples: improve offboard attitude
  • Loading branch information
JonasVautherin authored Jul 23, 2020
2 parents f03730a + 1accab1 commit 8ffed39
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion examples/offboard_attitude.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env python3

# Warning: Only try this in simulation!
# The direct attitude interface is a low level interface to be used
# with caution. On real vehicles the thrust values are likely not
# adjusted properly and you need to close the loop using altitude.

import asyncio

Expand Down Expand Up @@ -35,6 +39,10 @@ async def run():
await drone.action.disarm()
return

print("-- Go up at 70% thrust")
await drone.offboard.set_attitude(Attitude(0.0, 0.0, 0.0, 0.7))
await asyncio.sleep(2)

print("-- Roll 30 at 60% thrust")
await drone.offboard.set_attitude(Attitude(30.0, 0.0, 0.0, 0.6))
await asyncio.sleep(2)
Expand All @@ -43,7 +51,7 @@ async def run():
await drone.offboard.set_attitude(Attitude(-30.0, 0.0, 0.0, 0.6))
await asyncio.sleep(2)

print("-- Roll 0 at 60% thrust")
print("-- Hover at 60% thrust")
await drone.offboard.set_attitude(Attitude(0.0, 0.0, 0.0, 0.6))
await asyncio.sleep(2)

Expand All @@ -54,6 +62,8 @@ async def run():
print(f"Stopping offboard mode failed with error code: \
{error._result.result}")

await drone.action.land()


if __name__ == "__main__":
loop = asyncio.get_event_loop()
Expand Down

0 comments on commit 8ffed39

Please sign in to comment.