I’d like to implement a following feature, with MAVSDK-Python and PX4:
- switch FC to offboard mode with RC switch (I configured it with QGC)
- in a pythion script that’s running on the companion computer, detect that FC went into offboard mode, to start controlling it afterwards
Is it possible? Currently my attempts do not work. I’m using this code:
import asyncio
from mavsdk import System
from mavsdk.offboard import (OffboardError, VelocityBodyYawspeed)
async def run():
# Init the drone
drone = System(mavsdk_server_address='localhost', port=50051)
await drone.connect()
async for state in drone.core.connection_state():
print("connecting")
if state.is_connected:
print(f"-- connected to drone!")
break
await drone.offboard.set_velocity_body(
VelocityBodyYawspeed(0.0, 0.0, 0.0, 0.0))
while True:
offboard = await drone.offboard.is_active()
print("check offboard", offboard)
await asyncio.sleep(1)
As an effect, after I switch to offboard mode with RC switch:
- the mode switch fails with “No offboard signal”,
drone.offboard.is_active()
always returnsFalse
.
When I try to switch to offboard mode from a python script with drone.offboard.start()
, that works fine, and offboard examples from MAVSDK-Python work fine.