# Flying drone with VIO and GPS

**URL:** <https://discuss.px4.io/t/flying-drone-with-vio-and-gps/30640>\
**Category:** PX4 Autopilot\
**Created:** [January 31, 2023, 11:45pm UTC](https://discuss.px4.io/t/flying-drone-with-vio-and-gps/30640 "2023-01-31T23:45:15Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![blazejg](https://discuss.px4.io/letter_avatar_proxy/v4/letter/b/b19c9b/32.png) [@blazejg](https://discuss.px4.io/u/blazejg)\
**Post date:** [January 31, 2023, 11:45pm UTC](https://discuss.px4.io/t/flying-drone-with-vio-and-gps/30640/1 "2023-01-31T23:45:15Z")

</div>

Hi,

I have an issuse to fly drone with VIO and GPS. Am I able to set proper value of the mask EKF\_AID\_MASK to turn off the GPS signal during the flight and navigate only by VIO system or on the other hand to fly drone with GPS with deacitvated the vision system. I want to deactivate GPS or VIO during the flight of the drone.  
If yes what would be the EKF\_AID\_MASK value ? Or maybe there is other solution to my issue.

Any hints or help would be appreciated.

Greets  
Błażej

---

<div class="post-metadata">

**Author:** ![Artem\_Borisov](https://discuss.px4.io/user_avatar/discuss.px4.io/artem_borisov/32/9999_2.png) [@Artem\_Borisov](https://discuss.px4.io/u/Artem_Borisov)\
**Post date:** [February 3, 2023, 10:01am UTC](https://discuss.px4.io/t/flying-drone-with-vio-and-gps/30640/2 "2023-02-03T10:01:28Z")

</div>

Hi!  
EKF\_AID\_MASK for GPS + VIO I gess

 ![image](https://discuss.px4.io/uploads/default/original/2X/5/5e7ef5d0abe0bdab93b7d3f57ed8d6f15aa36124.png)

**+ 1**

In flight you can’t change EKF\_AID\_MASK, because it change only be reboot vechile.

MAVSDK have [Failure plugin](https://mavsdk.mavlink.io/main/en/cpp/api_reference/classmavsdk_1_1_failure.html) by using it you can do something like this:

> failure.inject(SensorVio, Ok, int32\_t instance);  
> failure.inject(SensorGps, Off, int32\_t instance);  
> …  
> failure.inject(SensorVio, Off, int32\_t instance);  
> failure.inject(SensorGps, Ok, int32\_t instance);

I think it can do by Mavlink console in QGC like “gps stop” / “gps run”.

If you check my solution, and it help, please tell me about it.

I’m sometimes working with tasks like this, but this task I didn’t try yet.

---

<div class="post-metadata">

**Author:** ![Artem\_Borisov](https://discuss.px4.io/user_avatar/discuss.px4.io/artem_borisov/32/9999_2.png) [@Artem\_Borisov](https://discuss.px4.io/u/Artem_Borisov)\
**Post date:** [February 6, 2023, 9:04am UTC](https://discuss.px4.io/t/flying-drone-with-vio-and-gps/30640/3 "2023-02-06T09:04:37Z")

</div>

Hi!  
I tried Failure plugin, it didn’t want to work.  
I’m trying to use [serial control message](https://mavlink.io/en/messages/common.html#SERIAL_CONTROL), with [MavlinkPassthrough plugin](https://mavsdk.mavlink.io/main/en/cpp/api_reference/classmavsdk_1_1_mavlink_passthrough.html) MAVSDK C++. I think it wil be work, but I have no result, yet.

---

<div class="post-metadata">

**Author:** ![hamishwillee](https://discuss.px4.io/user_avatar/discuss.px4.io/hamishwillee/32/3469_2.png) [@hamishwillee](https://discuss.px4.io/u/hamishwillee)\
**Post date:** [February 8, 2023, 1:01am UTC](https://discuss.px4.io/t/flying-drone-with-vio-and-gps/30640/4 "2023-02-08T01:01:41Z")

</div>

In main, couldn’t you set **EKF2\_GPS\_CTRL** to zero?

---

<div class="post-metadata">

**Author:** ![Artem\_Borisov](https://discuss.px4.io/user_avatar/discuss.px4.io/artem_borisov/32/9999_2.png) [@Artem\_Borisov](https://discuss.px4.io/u/Artem_Borisov)\
**Post date:** [February 8, 2023, 9:19am UTC](https://discuss.px4.io/t/flying-drone-with-vio-and-gps/30640/5 "2023-02-08T09:19:23Z")

</div>

Wow, it’s so simple? Big thanks!

Directly set EKF2\_GPS\_CTRL to zero by [Param plugin](https://mavsdk.mavlink.io/main/en/cpp/api_reference/classmavsdk_1_1_param.html) imposible.

But posible to set EKF2\_AID\_MASK. But what about [this]?([Parameter Reference | PX4 User Guide (main)](https://docs.px4.io/main/en/advanced_config/parameter_reference.html)):  
 ![image](https://discuss.px4.io/uploads/default/original/2X/6/613a0fab5fede7601940a65a849969da6954f476.png)

I see that it work:

> auto get = param-\>get\_param\_int(“EKF2\_AID\_MASK”);  
> std::cout \<\< “int\_32:\t” \<\< get.second \<\< std::endl;  
> param-\>set\_param\_int(“EKF2\_AID\_MASK”,24);  
> get = param-\>get\_param\_int(“EKF2\_AID\_MASK”);  
> std::cout \<\< “int\_32:\t” \<\< get.second \<\< std::endl;  
> param-\>set\_param\_int(“EKF2\_AID\_MASK”,1);  
> get = param-\>get\_param\_int(“EKF2\_AID\_MASK”);  
> std::cout \<\< “int\_32:\t” \<\< get.second \<\< std::endl;

![image](https://discuss.px4.io/uploads/default/original/2X/5/5ba1c7868bfcc7d02cd291ab94fa611a44839a28.png)

But this will need to be checked when the drone is in flight.

I’ll tell you when I check.

Cheked with Gazemo, look pretty good. 😊

---

<div class="post-metadata">

**Author:** ![hamishwillee](https://discuss.px4.io/user_avatar/discuss.px4.io/hamishwillee/32/3469_2.png) [@hamishwillee](https://discuss.px4.io/u/hamishwillee)\
**Post date:** [February 8, 2023, 11:09pm UTC](https://discuss.px4.io/t/flying-drone-with-vio-and-gps/30640/6 "2023-02-08T23:09:28Z")

</div>

Why won’t mavsdk allows EKF2\_GPS\_CTRL to be set? Perhaps it is not in the version of PX4 you are using?

Because setting EKF2\_GPS\_CTRL to zero is the “right” think to do what you want in main as far as I know. So if it is in the version of PX4 you are using, worth finding out why MAVSDK won’t set it.

---

<div class="post-metadata">

**Author:** ![Artem\_Borisov](https://discuss.px4.io/user_avatar/discuss.px4.io/artem_borisov/32/9999_2.png) [@Artem\_Borisov](https://discuss.px4.io/u/Artem_Borisov)\
**Post date:** [February 9, 2023, 10:06am UTC](https://discuss.px4.io/t/flying-drone-with-vio-and-gps/30640/7 "2023-02-09T10:06:20Z")

</div>

Don’t know why 😢

Device: PX4 FMU V5X (Pixhawk 5x Holybor)  
Flight Stack: PX4 Pro Stable Release v1.13.2 (px4\_fmu-v5x-default.px4) (last)  
MAVSDK v1.4.0

> ```
> auto get = param->get_param_int("EKF2_GPS_CTRL");
> std::cout <<"1.1) Result get:\t"<< get.first <<"\tint_32:\t" << get.second << std::endl;
> 
> auto set = param->set_param_int("EKF2_GPS_CTRL",0);
> std::cout <<"2.1) Result set:\t"<< set << std::endl;
> 
> get = param->get_param_int("EKF2_GPS_CTRL");
> std::cout <<"2.2) Result get:\t"<< get.first <<"\tint_32:\t" << get.second << std::endl;
> 
> set = param->set_param_int("EKF2_GPS_CTRL",1);
> std::cout <<"3.1) Result set:\t"<< set << std::endl;
> 
> get = param->get_param_int("EKF2_GPS_CTRL");
> std::cout <<"3.2) Result get:\t"<< get.first <<"\tint_32:\t" << get.second << std::endl;
> 
> ```

 ![image](https://discuss.px4.io/uploads/default/original/2X/a/ada910a735c61c092377a7460773f58da4f0f53b.png)

Always Result = Timeout.

EK2\_GPS\_CTRL no in QGC

 ![image](https://discuss.px4.io/uploads/default/original/2X/4/4489a626d2bde051ffcc61e4201a4e6cd23fc319.png)

You may have made a mistake in your suggestion to set EKF2\_GPS\_CTRL to zero, because ‘0’ is not turning off GPS:

![image](https://discuss.px4.io/uploads/default/original/2X/b/b3deb571e30b562d20034acd0b23a4b518af79d1.png)

But thanks a lot for the tips anyway. 🥳

---

<div class="post-metadata">

**Author:** ![blazejg](https://discuss.px4.io/letter_avatar_proxy/v4/letter/b/b19c9b/32.png) [@blazejg](https://discuss.px4.io/u/blazejg)\
**Post date:** [February 27, 2023, 3:38pm UTC](https://discuss.px4.io/t/flying-drone-with-vio-and-gps/30640/8 "2023-02-27T15:38:57Z")

</div>

Hi, my main purpose was navigating the drone with fusion of GPS and VIO system. I want to start flying the drone using fusion of GPS and VIO. I want to use VIO as backup in case of GPS noise. I don’t want to land the drone and change the ekf2\_aid\_mask and continue the flight with the mask set for vio.  
Is there any solution to my problem?

Now I am testing the vio system in the simulation. The drone is flying with VIO with EKF\_AID\_MASK = 24. From starting the flight to landing the drone is using only VIO system.

The EKF\_AID\_mask values that was shown in previous reply don’t have bitmask 0: use GPS set bit to 1. Does it mean that I don’t have to use bitmask 0 to use GPS with VIO?

 ![Przechwytywanie2](https://discuss.px4.io/uploads/default/original/2X/e/e5c88324eba63ee283ce95d33896ac5ca1e1efe2.png)

---

<div class="post-metadata">

**Author:** ![Artem\_Borisov](https://discuss.px4.io/user_avatar/discuss.px4.io/artem_borisov/32/9999_2.png) [@Artem\_Borisov](https://discuss.px4.io/u/Artem_Borisov)\
**Post date:** [February 27, 2023, 4:00pm UTC](https://discuss.px4.io/t/flying-drone-with-vio-and-gps/30640/9 "2023-02-27T16:00:41Z")

</div>

And me again! 🙂

“set to true to use GPS” it is mean bitmask = 1.

If you whant to use GPS + VIO bitmask = 25.

But there are promblem if you feed PX4 by pose from VIO, it can conflict with pose from GPS, and drone can crushed.  
So if you use GPS + VIO you can feed PX4 speed from VIO. (I read about it on this forum. Don’t remember where exatly ☹ ) And then PX4 fusing data correctly.

Any way if you testing in the simulation use EKF2\_AID\_MASK = 25.

---

<div class="post-metadata">

**Author:** ![darshan](https://discuss.px4.io/letter_avatar_proxy/v4/letter/d/e47774/32.png) [@darshan](https://discuss.px4.io/u/darshan)\
**Post date:** [December 5, 2023, 9:20am UTC](https://discuss.px4.io/t/flying-drone-with-vio-and-gps/30640/10 "2023-12-05T09:20:20Z")

</div>

Hi @Artem_Borisov, I’m also facing same issue in my pixhawk device EKF2\_GPS\_CTRL paramater is not listing. Did you get any luck to solve this error.

---

<div class="post-metadata">

**Author:** ![payemo](https://discuss.px4.io/letter_avatar_proxy/v4/letter/p/ce7236/32.png) [@payemo](https://discuss.px4.io/u/payemo)\
**Post date:** [January 25, 2025, 5:09pm UTC](https://discuss.px4.io/t/flying-drone-with-vio-and-gps/30640/11 "2025-01-25T17:09:27Z")

</div>

What’s wrong with Failure plugin? What result did you expect but it worked in another way? Right now, I am trying to turn on/off GPS. So the only way I found it by sending command that instantiate mavlink shell and pass `gps stop/start` command. Don’t like it, any ideas to solve that in a more elegabt way?
