From Mission mode to Offboard mode and back

Hi, everyone!

I have a PixHawk 5x (PX4), Raspberry Pi4 and quadrocopter.

I am planning to implement a transition from mission mode to offboard mode and back using the MAVSDK.

It will look like this: In mission mode, GPS is used, and in offboard mode, a tracking system (like ArUco). The drone flies using GPS, a co-computer recognizes the tracking system, switches the drone to offboard mode, flies into the building, executes the offboard program, then flies back out-door and switches to the mission mode, continuing the flight further to the next building, where everything is repeated.

To ensure a smooth transition from one coordinate system to another, I assume that I need to link them. I read: “PX4 do always correspondent transformation between global and local frames on the Firmware side.”

To pass the coordinates of the tracking system, I use:
mocap.set_vision_position_estimate (…);
for control in Offboard mode -
offboard.set_position_ned (…);

At the moment, in offboard mode in-door, everything works great…

And now some problems:

At: struct VisionPositionEstimate · MAVSDK Guide i see: PositionBody position_body {} - Global position (m)
But! In MAVSDK source code…

I see that the set_vision_position_estimate function refers to:

MAVSDK / src / third_party / mavlink / include / mavlink / v2.0 / common / mavlink_msg_vision_position_estimate.h with ID = 102 where local coordinates are used in meters.

102 != 101

ID = 101 global coordinates are used in meters.

MAVSDK/src/third_party/mavlink/include/mavlink/v2.0/common/mavlink_msg_global_vision_position_estimate.h

And so I have several questions:

  1. position_body {} - Global position (m). Does this mean Global postition = GPS (lat / lon-> to_meters)?

  2. Should I fix the bug (ID 102 to 101), or it doesn’t matter, or use mavsdk :: MavlinkPassthrough?

  3. What is the best way to implement the transition from GPS to LocalNED? I noticed that when EKF2_AID_MASK = 24 GPS does not work, and when GPS is working set_vision_position_estimate does not work. Change EKF2_AID_MASK in flight? I think it’s not safe.

  4. Perhaps the best way is to implement fakegps, with set parameter MAV_USEHILGPS?

  5. Are there any links to completed projects with similar tasks?

Thank you for your attention!
Sorry for the english, this is google translator. )

Hello @Artem_Borisov ,

Just for having more info to try to help you… are you using the MAVSDK offboard_position_ned function? Does it work properly for you?

Greetings

Hello @JuSevRo !
Yes. I’m using “offboard.set_position_ned(target)” C++ MAVSDK.
It work properly for me.
At the moment in-door + offboard mode works great.

Hi @Artem_Borisov !

Have you then checked all the parameters related to the GPS in the QGC?

HI @JuSevRo!

I have not checked all parameters.
Is your question related to my third point?
Do you know the parameters linking GPS and vision_position_estimate in local coordinates?

Thanks for your interest in my post.

Hello @Artem_Borisov

Firstly sorry for the late answer. And yes, my question is related to the third point of your first post. Its something you shall study on your own (because only you know your necessities), but there are some parameters whose value adjusts the drone behaviour as you’d probably know. Parameter Reference | PX4 User Guide
Maybe for your GPS to offboard transition you could create a waypoint where the drone stops and changes its navigation mode (by changing the value of the parameters).

I am currently working on something similar to your case, so we may keep in contact if you wish. And if you let me ask you a question…when I try to run the takeoff_and_land.cpp and building the libraries, the following mistake appears:

In file included from /home/MAVSDK/examples/takeoff_and_land/takeoff_and_land.cpp:8:
/usr/include/mavsdk/plugins/action/action.h:16:10: fatal error: plugin_base.h: No such file or directory
16 | #include “plugin_base.h”
| ^~~~~~~~~~~~~~~
Do you know how to fix it?

Regards Artem

@JuSevRo sorry for the late answer too.

If you have not solved so far the indicated error…
As far as I remember the solution was:
1)First of all building MAVSDK from source Building library from Source · MAVSDK Guide(I work in Linux system).
2) In CMakeLists - file should be like this:
target_link_libraries(takeoff_and_land
MAVSDK::mavsdk_telemetry
MAVSDK::mavsdk_action
MAVSDK::mavsdk
)

or in qmake file *.pro

LIBS += /usr/local/lib/libmavsdk.so
LIBS += /usr/local/lib/libmavsdk_telemetry.so
LIBS += /usr/local/lib/libmavsdk_action.so
LIBS += /usr/local/lib/libmavsdk_mocap.so
LIBS += /usr/local/lib/libmavsdk_offboard.so

Hello @Artem_Borisov nothing to be sorry about.
I solved that problem, but when i try to compile the offboard.cpp some errors appear. Did you do anything else apart from compiling? Did you need to change some drone parameters in the QGC?

@JuSevRo I did so much in QGS…

What exactly are the errors with offboard.cpp? When compiling or when flying a drone?
What is the configuration of your drone other than px4?
Do you fly with or without GPS?

As far as I remember, offboard.cpp was not able to properly control the drone in the jMAVSim with SITL simulation.

Hello @Artem_Borisov and thanks for your answers.
This is the error that appears once compiled offboard.cpp and trying to fly the drone.

And answering to your questions, I am simulating the drone in Gazebo, and the drone is not supposed to have GPS, so I would like to make it fly without GPS.

@JuSevRo I see: “Failsafe enabled: No manual control stick in put”. You can change parameter in the QGC COM_RC_IN_MODE to joystick/No RC Checks. Maybe it helps.

Unfortunately I don’t work in Gazebo or any simulators. Only with a real drone.

I don’t know how to fly Gazebo without GPS.

Perhaps this will help you:

These videos use Gazebo with ArUCo. And COEX company have education programm COEX Education. But they use ROS not MAVSDK.

Thank you so much for your answer @Artem_Borisov ,

I’ll keep searching for a solution!