Skip to content

Commit 8ffed39

Browse files
Merge pull request #236 from mavlink/pr-offboard-attitude-enhancement
Examples: improve offboard attitude
2 parents f03730a + 1accab1 commit 8ffed39

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

examples/offboard_attitude.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/usr/bin/env python3
22

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

48
import asyncio
59

@@ -35,6 +39,10 @@ async def run():
3539
await drone.action.disarm()
3640
return
3741

42+
print("-- Go up at 70% thrust")
43+
await drone.offboard.set_attitude(Attitude(0.0, 0.0, 0.0, 0.7))
44+
await asyncio.sleep(2)
45+
3846
print("-- Roll 30 at 60% thrust")
3947
await drone.offboard.set_attitude(Attitude(30.0, 0.0, 0.0, 0.6))
4048
await asyncio.sleep(2)
@@ -43,7 +51,7 @@ async def run():
4351
await drone.offboard.set_attitude(Attitude(-30.0, 0.0, 0.0, 0.6))
4452
await asyncio.sleep(2)
4553

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

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

65+
await drone.action.land()
66+
5767

5868
if __name__ == "__main__":
5969
loop = asyncio.get_event_loop()

0 commit comments

Comments
 (0)