Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't connect to QGC via UDP connection using mavsdk #714

Open
hilaelb opened this issue Jun 27, 2024 · 3 comments
Open

can't connect to QGC via UDP connection using mavsdk #714

hilaelb opened this issue Jun 27, 2024 · 3 comments

Comments

@hilaelb
Copy link

hilaelb commented Jun 27, 2024

I want to connect to QGC, i using this code, but QGC still shows on the main screen disconnected. why is this happen?

import asyncio
from mavsdk import System

async def run():
# Create a MAVSDK system object
drone = System()

# Connect to the drone via QGC's UDP port (assuming QGC is configured to listen on 14550)
await drone.connect(system_address="udp://192.168.168.95:14550")

print("Waiting for drone to connect...")
async for state in drone.core.connection_state():
    if state.is_connected:
        print(f"Drone discovered with UUID: {state.uuid}")
        break

print("Drone connected!")

# Listen for heartbeat messages
async for heartbeat in drone.telemetry.heartbeat():
    print(f"Heartbeat: {heartbeat}")

if name == "main":
loop = asyncio.get_event_loop()
loop.run_until_complete(run())

image
image

@JonasVautherin
Copy link
Collaborator

JonasVautherin commented Jun 27, 2024

Can you elaborate on your use-case? Do you want MAVSDK to behave like an autopilot? Because your code above tries to connect MAVSDK as a ground station to QGC, which probably won't work.

@hilaelb
Copy link
Author

hilaelb commented Jun 29, 2024

Can you elaborate on your use-case? Do you want MAVSDK to behave like an autopilot? Because your code above tries to connect MAVSDK as a ground station to QGC, which probably won't work.

Yes, I want that MAVSDK behave like a generic autopilot and I want to connect the QGC, in another words - what do I require for a connection to be established with a generic autopilot?

@julianoes
Copy link
Collaborator

You need to create the autopilot as a plugin. I don't think this has been attempted using a language wrapper (like Python) yet. I'm not certain it will work. I would suggest to do it using MAVSDK in C++ and start with this example:
https://github.com/mavlink/MAVSDK/tree/main/examples/autopilot_server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants