Is this possible to invoke the method of QGroundControl from a Django(Python) web application?

I have a Django web application hosted on Ubuntu 18.04 and on the same machine I have installed the QGroundControl.

In my Django Web Application there are two buttons ( Take Off & Return to Land ).

Is this possible that when I press the Take Off button from my Web Application, it should invoke the Take Off method of QGroundControl?

How can I connect the Django (Python) Web Application & QGroundControl?

There will be some API or Web Service etc? Any idea?

I don’t think you want it to connect it to a UI application such as QGroundControl but rather use an API/SDK like MAVSDK.

Since you’re in the Python world, you might consider https://github.com/mavlink/MAVSDK-Python/.

I am using QGroundControl because I want to use the features of QGC (Like Take Off, Land, Create Way Points, Save Missions, Capture Images, etc).
I can still use those features if I use MAVSDK?

I will have to lose the QGroundControl if I use MAVSDK?
FYI: I am using PixHawk 4 and PX4 over that.

image

Yes you can, see: http://mavsdk-python-docs.s3-website.eu-central-1.amazonaws.com/

1 Like

Thanks for the documentation. I got it.

I tried the following and they all worked fine without any problem.

1- Got the docker in Ubuntu by using the following, it ran successfully
docker run --rm -it jonasvautherin/px4-gazebo-headless:1.10.1

2- Ran the QGroundControl setup by downloading, it ran successfully and connected to PX4.

3- Taking off from MAVSDK-Python. (This also ran successfully)

apython
from mavsdk import System
drone = System()
await drone.connect()
await drone.action.arm()
await drone.action.takeoff()
await drone.action.land()

Above commands worked and I can see the status changes on the QGroundControl and Docker terminal.

HERE IS THE PROBLEM NOW
After finishing all of the above, I restarted my system and done the following.
1- Connected PixHawk 4 (I installed PX4 on it with QGroundControl, connected with USB port of my machine via cable).

2- Ran the QGroundControl setup by downloading, it ran successfully and connected to PX4.

3- Taking off from MAVSDK-Python. (problem came here)

Ok, you need to tell MAVSDK that you want to connect via USB. So this means you need to exit QGGroundControl, so it releases the USB port and then use this to connect:

drone.connect(system_address="serial:///dev/ttyACM0:57600") # or whatever you're using
1 Like