Offboard control of latest stable PX4


Hi Everyone,

I’m trying to control a pixhawk equiped drone using via Mavlink v2 by a “companion board” connected to the the Pixhawk. I am currently using PX4 stable release version 1.8. and EKF2 as position estimator (which is the default one since 1.8 and the others are not supported anymore as I remember). I am trying to get the system running for indoor (using Optitrack) as well as outdoor (using GPS).

Now I have a few Questions on how to do some things via Mavlink:

1st Question:
When flying outdoors, the PX4 initializes it’s local origin at startup to the first valid GPS position. As the offboard control is only possible via setting the “SET_POSITION_TARGET_LOCAL_NED”, I would need to know the position of the local origin to transform global target waypoints (latitude and longitude of the target waypoint) into local coordinates. The problem is, that neither one of the Mavlink messages for getting or setting the local origin global position is currently implemented in PX4 as I saw after some code-digging. What I am now doing is using the local and global home position information for calculating the global position of the local origin (which is much more acurate than I thought) but will never reach the exact value as the alignment of local and global home position are sensor error dependent.

My question now, is there another way to get the local origin’s global position using only mavlink? As i know the messages “SET_GPS_GLOBAL_ORIGIN” and “GPS_GLOBAL_ORIGIN” are not implemented. In case of using other positioning systems where I tell the done where it is, the global position of the origin will me managed by myself.

This leads to my second question:
When flying indoors, I forward the position of the drone which I track via Optitrack using the Mavlink message “VISION_POSITION_ESTIMATE”. In EKF2, only the “vision position estimate” is implemented which I recently found out after several tests and via a post in the forum. The official documentation statest that also the ATT_POS_MOCAP message can and should be used for systems like Optitrack. What I do now, is just putting the information I would normally put into the “ATT_POS_MOCAP” message into the “VISION_POSITION_ESTIMATE” message as the post suggested ( Is this even the correct way? Or are there other ways to forward optitrack like tracking data to the PX4 via Mavlink?

The methodes I currently implemented, are working but there are still some issues like loosing local position from time to time when forwarding the optitrack data via “VISION_POSITION_ESTIMATE”. And in general I wonder if I use the correct approach. I wold appreciate any kind of help or feedback to get the PX4 running smoothly.

1 Like