Autonomous flight using Python MAVLink library

Hello,
I am making a drone that has a pixhawk 6c and plan to add a Jetson Orin Nano on top to connect to the pixhawk and control its movement based on input from a camera.
For this, I need to write a python script that will get the distance to an object from a depth camera(i will figure this part out) and then tell the pixhawk to travel that distance while maintaining altitude.

First, Is this possible? And if yes, then what resources might be helpful?

Second, I asked chatGPT to write me a script to make the drone go 3 meters forward and 2 meters left at 1 meter altitude, and I wanted someone who is experienced with MAVLink and the python library to verify if the script would actually work.
Here is the script:
DroneTEST.txt (2.2 KB)

Finally, how accurate would the speed be based on the Pixhawk 6C’s accelerometer? Can I at least trust that it will always go the same distance every time?(As in it always goes 1.8m when you tell it to go 2m rather than varying randomly)

Please help me with this. Thank you in advance

1 Like

You plan to fly it indoors or outdoors, secondly, with GPS or without GPS.

1 Like

I plan to fly it outdoors but not too far, the drone will probably move a max of 10 meters from the start location.
I have an M10 GPS connected to the Pixhawk 6C

1 Like

Movement trigger is mentioned, what will the UA be doing outside of the no camera input? Hover forever?

Hello,

The Drone will have a set path(see image below) that it will follow. When the camera detects an object on the ground, the drone will receive a message that interrupts the set path and saves the current location. Then, based on the camera data, the drone will move towards the object on the ground and land over it and pick it up with a claw mechanism attached to the bottom of the drone. Next, the drone will return to the start location, drop the item, and then return to the saved location and resume on the original path.

This can probably be achieved using waypoint flying with the Copter Mission Command List.
You can take a look at Do-Gripper and Do-Winch to see if they simplify things.

Separately, waypoint flying from a companion computer is also possible. This project begins with the PX4 Flight stack, improving to support the Ardupilot flight stack. I had done a simple test and it works with Ardupilot. Some users feedback that they still facing compatibility with Ardupilot.

They have some examples like goto.py, gripper.py, mission_import.py, etc. API documentation.

I do not recommend Dronekit because it is no longer in maintenance, does not support multiple serial connections, and stops at Python 2.X.

Hello,

I was looking through the command list and found “Attitude Time” to be a potential solution to my original problem. However, that command takes Pitch, Roll, Yaw, and Time as inputs. How can I convert pitch and time to distance traveled? For example, how far would the drone travel if I applied -20 Pitch for 5 seconds?
Thanks

Here is an example in the simulator.
It could have the effect from these waypoint parameters set. Remember in the real world there is a headwind or tailwind.

I have not tried that before, we usually fly waypoint by GPS positions.