# Advice on Vision based Position control

**URL:** <https://discuss.px4.io/t/advice-on-vision-based-position-control/14537>\
**Category:** Flight Testing & Log Analysis\
**Created:** [January 4, 2020, 7:37am UTC](https://discuss.px4.io/t/advice-on-vision-based-position-control/14537 "2020-01-04T07:37:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shashank\_Bhushan](https://discuss.px4.io/user_avatar/discuss.px4.io/shashank_bhushan/32/5365_2.png) [@Shashank\_Bhushan](https://discuss.px4.io/u/Shashank_Bhushan)\
**Post date:** [January 4, 2020, 7:37am UTC](https://discuss.px4.io/t/advice-on-vision-based-position-control/14537/1 "2020-01-04T07:37:06Z")

</div>

Goal of the testing is to fuse visual odometry from ZED stereo camera and GPS data with the PX4 flight stack .  
I have written a small snippet that subscribes to /mavros/global\_position/global and /zed/pose\_cov and does the following

1. convert the ZED stereo camera odometer to PX4 NED frame by using static transform
2. If /mavros/global\_position/global cov is less than a threshold increase covariance value of camera pose to a very high value or else leave the camera pose as it is.

My flight stack details are as follow

1. Version : 1.9
2. Estimator : EKF2
3. EKf2\_aid\_mask : GPS+VISION\_position+Optical\_flow+Multirotor\_drag\_fusion

Type of Platform: Hexcopter

My question is

1. What is the difference between the topics /vision/pose and /vision/pose\_cov. is it not essential to have a covariance while fusion with ekf . Can someone share some insites onto how things happens inside flight stack ?
2. Any comment / modification in my approach ?

thanks

---

<div class="post-metadata">

**Author:** ![kamilritz](https://discuss.px4.io/user_avatar/discuss.px4.io/kamilritz/32/4787_2.png) [@kamilritz](https://discuss.px4.io/u/kamilritz)\
**Post date:** [January 6, 2020, 5:00pm UTC](https://discuss.px4.io/t/advice-on-vision-based-position-control/14537/2 "2020-01-06T17:00:09Z")

</div>

GPS+VISION\_position is not recommended. Does your VIO odometry also includes velocities? That would be the better approach at the moment. Look [here](https://docs.px4.io/master/en/advanced_config/tuning_the_ecl_ekf.html#external-vision-system).

---

<div class="post-metadata">

**Author:** ![Shashank\_Bhushan](https://discuss.px4.io/user_avatar/discuss.px4.io/shashank_bhushan/32/5365_2.png) [@Shashank\_Bhushan](https://discuss.px4.io/u/Shashank_Bhushan)\
**Post date:** [January 8, 2020, 10:11am UTC](https://discuss.px4.io/t/advice-on-vision-based-position-control/14537/3 "2020-01-08T10:11:59Z")

</div>

@kamilritz Thanks a lot for your replay .  
I don’t have VIO only VO .

1. If I understand your solution we shouldn’t fuse position odometer from multiple sources ? but velocity can be fused.
2. How is an external vision sensor different from a onboard VO sensor ?  
I will update to VIO sensor soon .

---

<div class="post-metadata">

**Author:** ![kamilritz](https://discuss.px4.io/user_avatar/discuss.px4.io/kamilritz/32/4787_2.png) [@kamilritz](https://discuss.px4.io/u/kamilritz)\
**Post date:** [January 8, 2020, 10:57am UTC](https://discuss.px4.io/t/advice-on-vision-based-position-control/14537/4 "2020-01-08T10:57:30Z")

</div>

Unfortunately, the naming is not very consistent. external\_vision, vision and VIO are all different names used for some source of odometry.  
The issue is that if you provide 2 sources of position, such as GPS and vision, you would either need to estimate offset of the origins or do some kind of incremental change fusion. The later is currently implemented, but I did not achieved good results with it. You may try if you want.  
If you provide velocities you don’t need to estimate the offset of the origins.

---

<div class="post-metadata">

**Author:** ![Shashank\_Bhushan](https://discuss.px4.io/user_avatar/discuss.px4.io/shashank_bhushan/32/5365_2.png) [@Shashank\_Bhushan](https://discuss.px4.io/u/Shashank_Bhushan)\
**Post date:** [January 8, 2020, 3:15pm UTC](https://discuss.px4.io/t/advice-on-vision-based-position-control/14537/5 "2020-01-08T15:15:04Z")

</div>

@kamilritz Thanks and appreciation for your support .

1. I would continue with my experimentation. Meanwhile if possible can you share relevant paper/ strategy/codes/materiel of the incremental change fusion of position estimate . I will start going through them and find out the issues/ limitation of the approach .

2. Understanding wagely the incremental change fusion . So we estimate position using GPS +pixhawk Imus everything work fine useless we enter a place without GPS (when co-variance falls below a threshold) . Now i switch on my VIO/VO/External position estimation. The change between the consecutive time stamp is given to estimator ( ECL-EKF) which is then updates the position estimate. Am I correct ? If i am correct can you tell GPS threshold so that i take care of them while experimenting.  
Thanks a lot .  
Appreciate you help and time .

---

<div class="post-metadata">

**Author:** ![kamilritz](https://discuss.px4.io/user_avatar/discuss.px4.io/kamilritz/32/4787_2.png) [@kamilritz](https://discuss.px4.io/u/kamilritz)\
**Post date:** [January 8, 2020, 3:35pm UTC](https://discuss.px4.io/t/advice-on-vision-based-position-control/14537/6 "2020-01-08T15:35:20Z")

</div>

You can find the implementation here: [https://github.com/PX4/ecl/blob/master/EKF/control.cpp#L284-L318](https://github.com/PX4/ecl/blob/master/EKF/control.cpp#L284-L318) . I did not find any literature about this.

At the moment there is no logic in place that we switch from GPS position to vision position if we loose GPS position.
