Tips for loiter/Poshold tuning with Optical flow

Hey friends,

I’m working on the final tune for our inspection quad. It uses a px4flow, LeddarONE rangefinder, and a Zubax GNSS. I’ve noticed that it holds position decently well, but I feel like it could be better. I especially notice that it tends to drift a bit in my back yard which doesn’t get great GPS reception. I figured that the flow sensor would help it in situations where the HDOP is less than ideal. Does anyone have advice on a tuning procedure to get the most stable position hold in a variety of environments? Is it best to tune the flowhold mode first and then tune loiter/poshold? I’m open to any ideas and suggestions.

I’m using a black cube on the latest master.

Tuning of the EKF2 might help…

http://ardupilot.org/dev/docs/ekf2-estimation-system.html#tuning-parameters

I don’t quite understand. Turn off EKF2 and then enable EKF3 instead? From my understanding it needs the EKF to work at all.

I think you read it too quickly…
He said “Tuning of”, not “Turning off”.
But I’d imagine you’re looking for more specific advice than that.

1 Like

That is something i would like to understand too. A while ago i asked if flow and gps cohoperate during loiter but i really didn’t get a precise answer or i didn’t understand. I’d rather not use EKF3 because from what i understand is not as trustable as EKF2.

I guess base question is, on EKF2 the system uses both flow and gps to hold position and transitions smoothly to flow whenever GPS is obstructed?

I had quite good succes in GPS denied using PX4FLOW qith EK3, as usual, the FLOW SCALER X Y and te FLOW delay must be tuned to match the coeersponfing IMU axes. The lens and focus should be adjusted to the operating altitude, the surface where you fly over must be textured and non reflective.

As for the EKF fusion of GPS-OF, look at this clear answer from Mr. EKF = Paul Riseborough here:

1 Like

The developer wiki has a good description of the ekf, how it works and the settings that effect performance. It is worth reading the entire section.

I read there and how it should continue navigation if gps goes down, but than another user commented that in real life when the gps is jammed the system goes into failsafe and doesn’t continue navigation on flow.
Than the discussion didn’t go on and left me with 2 different and contrastating infos, one say that it should continue working (from the dev of EKF) and one saying that goes into failsafe (from a very experienced user). So i guess my doubts are not gone yet.

Well , I am more prone to believe the guy who wrote the code and backed it up with documented facts.
Anyway, you know what they say … "when in doubt , just test it yourself ''

Actually i briefly tested it and disconnected the gps in flight (took off power remotely from a little elec device just to the gps) and it went into failsafe. I was on EKF2. Didn’t dare to test it again on larger/different aircraft.
If i recall correctly it was on an early 3.6.x release. So it didn’t fall back to flow but maybe i did something wrong in the setup.
For the test i was not using external gps magnetometer, i was using internal and disabled external so that nothing would happen to mag when i swithed off gps.
I configured both flow and gps and used ekf2, maybe should have done something special that i don’t know or yet understand.
The strange thing is that i think it used flow during landing (failsafe) because it held position fine while doing it, just didn’t let me fly it :slight_smile:

Interesting, was it in Loiter or auto (or guided) ?
I have not checked on the state machine but I guess it would be logical to failsafe to landing as the positionning gets from global to local reference

It has been tested in loiter.
“This test showed that each time GPS was gained the EKF’s local position reset to match the GPS, but when GPs was lost it continued to dead-reckon using optical flow”
This is what the dev says, does it mean that dead-reckon works just to land the aircraft or should i still be able to fly it?
I am confused :slight_smile:

Dead reckon work auto in plane only , in quad it is categorized as failsafe

So now it makes sense, once gps is gone the system uses flow as a dead-reckon just to accomplish fail safe manouvers. That is exactly what mine did during test. I guess i didn’t understand correctly what was written.
It would be very nice to have the option of continue flying in loiter manually if gps is gone and flow works. We do a lot of BVLOS missions in FPV and it would have been very very useful in a couple of occasions.
Flying stabilize in bvlos is very difficult so a fall back to flow loiter would be the best option.

I highly recommend everyone flying drones, especially professionally, learn to fly in stab! I made myself fly every day for a year, and am great now! I crashed every time the first couple months, but can now weave in between tree branches and through buildings and can deal w/ snow and brief cutouts in my FPV feed w/out getting scared and doing something stupid. It’s scary at first. Gets to be fun. And is a skill people really should have if they’re flying these things! Stab/Acro is like driving a car now… No problem at all.

Sorry for the OT, but I see it mentioned at least weekly here… Someone complains about maintaining altitude in stab or says they crashed in stab, or just otherwise refuses to use stab… It’s simply a matter of practice. (and maybe building yourself a small inexpensive drone if all you have is a big working ship)

2 Likes

Technically you can switch manually to back to Loiter , but you might have to regress to a lower level mode like Stabilize prior to switch back to Loiter
And this is where I confirm @wicked1 assertion that you have to practice this mode change on a regular basis as regressing back to stabilize is quite tricky when you are not ready to do so… the most common error is forgetting to set throttle and watch the vehicle falling from the sky and try to understand that you have NOT MOVED the throttle stick to middle :wink:

I can fly stab in FPV during BVLOS operations but my point is that with a 25Kg aircraft and very strong winds with GPS that comes and go it would be a bit more relaxing to count on flow to help out. But if i understand correctly what you say, if it goes in fail safe due to gps blackout i can go to stab than back to loiter and it’ll stay in loiter using flow?

Yes this should work but you can test it with simulator SITL to prove it

Ok thanks, will try.