LibrePilot Forum

Users => Applications - Autonomous Flight => Topic started by: TheOtherCliff on January 30, 2017, 10:24:38 pm

Title: East West oscillation with authentic DJI Naza GPS & maybe even with some clones
Post by: TheOtherCliff on January 30, 2017, 10:24:38 pm
You may find a slow oscillation (oscillation period is about 4 seconds or so) in GPS flight modes if you are using an authentic DJI GPS.  The DJI clone I have doesn't have this issue.
Edit: but there is at least one report of the issue happening with a clone and the fix helping.

It appears that the cause is that DJI smooths their GPS data more than LP expects, and the smoothing causes delays.

You can see the smoothing in the size of the pattern of the GPS trail displayed in OpMap (enable diagnostics and watch the green trail) when the quad is motionless on the ground.  Do this for the authentic DJI GPS, then compare the size of that pattern with the size of a pattern produced by any other supported GPS.

You can reproduce the effect with an OP GPS or other Ublox based GPS by setting GPSSettings->UbxDynamicModel to Pedestrian (really bad) or Automotive.  You need a large open area (at least 50mx50m) to test this.  Flying Velocity Roam mode, get up to speed flying east or west, release the stick, and notice that the oscillations do not die down.  Switch back to Attitude mode to recover from the oscillations.  Make sure you have a non-GPS mode to recover with.

Link to the issue tracking details:
https://librepilot.atlassian.net/browse/LP-450
Title: Re: East West oscillation with authentic DJI GPS but not with DJI clone
Post by: TheOtherCliff on February 01, 2017, 07:34:32 pm
Anybody have LibrePilot with a DJI Naza GPS currently flying in VelocityRoam mode?  I would appreciate some feedback on this, :) as to whether it happens for you or not.

This issue is fairly easy to recreate.  Fly east (or west) and just before it gets to full speed (when the bank angle is still high) release the sticks and let it hover.  It will oscillate east-west and won't stop oscillating.  For me, it does it worst when pointing north and flying east-west.  For me, other directions oscillate less or do not oscillate.  When pointing north, it gets worse and worse and I have to change modes to recover.
Title: Re: East West oscillation with authentic DJI GPS but not with DJI clone
Post by: HighAltitude on February 03, 2017, 12:56:55 am
It finally warmed up enough to venture outside and test whether my quads exhibit the same behavior, which they do. 
My GPS/Mag modules appear to be genuine DJI units, rather than clones. 
The oscillation is east/west, regardless of the heading of the aircraft, and increases amplitude until the GPS assisted flight mode is switched off.  This includes RTB mode.  It appears that the vehicle overshoots, corrects, overshoots the other direction, etc., etc., which seems consistent with delays caused by data smoothing.
I've read the issue tracking details, but I don't have the experience or expertise to even understand the discussion there.
As long as I can switch off the GPS modes and regain manual control, it's more of an annoyance than a serious problem, but I hope this info helps. 
Title: Re: East West oscillation with authentic DJI GPS but not with DJI clone
Post by: TheOtherCliff on February 03, 2017, 02:22:48 am
Thanks for the recreate!

I have a 16.09 compatible firmware that helps or fixes it.  I need to tune it more and maybe you can beta test after I fly it.  :)

I don't know whether it will be before or after this weekend.
Title: Re: East West oscillation with authentic DJI GPS but not with DJI clone
Post by: TheOtherCliff on February 04, 2017, 09:16:38 pm
Here is the firmware for this issue.  It's compatible with 16.09 so just flash the firmware and leave the settings as they were in stock 16.09 although it never hurts to back up your settings before messing with things you have not messed with before.  I've test flown the Sparky2 version and it seems to completely fix the issue for me.

This only helps for the DJI/Naza GPS type.

Anybody that has this issue and tests this firmware, please report back with your findings.  :)

I thought this was only needed for authentic DJI GPS's but there are reports of clones with the issue too.  The authentic version looks exactly like the attached picture.  This issue does not happen with some DJI GPS clones because they do not smooth (and thus delay) the GPS data as much.
Title: Re: East West oscillation with authentic DJI GPS but not with DJI clone
Post by: HighAltitude on February 05, 2017, 01:44:16 pm
Weather permitting, I'll try it with my "development" quad this afternoon and let you know.
Title: Re: East West oscillation with authentic DJI GPS but not with DJI clone
Post by: HighAltitude on February 05, 2017, 04:03:16 pm
Since my quad is flying very nicely (except for the oscillations), and I don't want to have to start from scratch setting it up again, is this the appropriate procedure for trying out the firmware fix?
1. Export UAV settings.
2. Download and save the firmware.
3. Upgrade (? and Erase?).
4. Import UAV settings.
5. Test fly
Title: Re: East West oscillation with authentic DJI GPS but not with DJI clone
Post by: TheOtherCliff on February 05, 2017, 05:50:34 pm
If you are currently running 16.09:
Download firmware to some known place like Desktop.
Run GCS.
Plug in just FC USB (doesn't work via OpLink).
Press Firmware -> Halt (and wait for up to 30 seconds for Open / Flash / Retrieve buttons to appear)
Press Open.
Navigate the "Select Firmware File" file chooser to Desktop or where ever you have the new fw_revolution.opfw
Select the opfw file and press Open in the file chooser.
Chooser closes itself.
Press Flash on the main Firmware page (and wait for it to erase then flash, takes over 30 seconds)
Title: Re: East West oscillation with authentic DJI GPS but not with DJI clone
Post by: TheOtherCliff on February 05, 2017, 05:52:25 pm
It's a good idea to back up your settings with export, but it isn't necessary when the new firmware is the same as or compatible with your current firmware.
This firmware is completely compatible with 16.09
Title: Re: East West oscillation with authentic DJI GPS but not with DJI clone
Post by: HighAltitude on February 06, 2017, 02:21:01 am
Thanks for the detailed instructions on installing the firmware fix.  All other settings were unaltered.  The oscillations are much improved.
Title: Re: East West oscillation with authentic DJI GPS but not with DJI clone
Post by: Tongala on March 24, 2017, 04:16:02 am
Hi just found this thread.
Recently upgraded from RC2 and after upgrade and erase now have these oscillations in position hold, worse when facing south. Don't know if facing south is because I live in southern hemisphere Australia.
Have authentic DJI gps.
Did not have any gps problems with RC2,PH was rock solid as was auto land, so wondering what has changed from RC2 to final release?
Will try the firmware posted.
If that doesn't work might have to go back to RC2.
Any thoughts?
Thanks
Title: Re: East West oscillation with authentic DJI GPS but not with DJI clone
Post by: Tongala on March 25, 2017, 02:46:08 am
Just a follow up.

Installed firmware, re-calibrated mags, oscillations almost gone but still unusable for gps modes.
Quad continually drifts around and up and down until it becomes unstable, the longer it stays in PH the worse it gets.
 
Before I upgraded to Black Rhino the quad just sat in the air with no more than about +- 500mm variation.

Went back to RC2 (erase and upgrade), imported UAV file from that release (when gps worked), re-calibrated mags,same problem as new firmware. Go figure.

The Uav file I loaded into RC2 was from when gps PH worked perfectly.

Am about to give up on ever getting this authentic DJI gps to work again.

Any ideas or advice before I bin my DJI gps units (2 No.) and go to clones?

Thanks in advance.
Title: Re: East West oscillation with authentic DJI GPS but not with DJI clone
Post by: TheOtherCliff on March 28, 2017, 12:55:24 am
Before this fix, I had the issue come and go too, but now I don't have any of the "gets worse and worse".  There still is some damped oscillation though.

Good position hold requires a good mag calibration.  I also always set "Rotate Virtual" for perfect driftless hover in Basic mode Attitude mode and then switch to INS13 and tweak mag board rotation to get driftless hover in INS13 mode Attitude mode.  It is explained in the section titled: Fine Tuning Your Hover To Stop Drift
Search for that title in:
https://librepilot.atlassian.net/wiki/display/LPDOC/Aux+Mag+Setup+and+Calibration
Title: Re: East West oscillation with authentic DJI GPS but not with DJI clone
Post by: bgiannes on April 10, 2017, 04:52:46 pm
I do have a DJI clone GPS, with the oscillation problem.  however my 450 size drone is solid in none GPS modes.

This firmware fixed my issue, the quad PH's very well now.  v happy with this fix, thank you.
Title: Re: East West oscillation with authentic DJI GPS but not with DJI clone
Post by: TheOtherCliff on April 10, 2017, 05:53:19 pm
Thank you for your post.  That is good information to know.  The DJI/Naza GPS clone I tested with did not have the oscillation problem, but now we know that some clones do have this issue.
Title: Re: East West oscillation with authentic DJI Naza GPS & maybe even with some clones
Post by: TheOtherCliff on June 28, 2017, 03:39:40 pm
Thoughts about this fix:

I do wonder if this (firmware change) is the best way to fix this problem.  The fix doesn't seem to be needed for at least some versions of DJI/Naza GPS clone, so some testing needs to be done to see if it hurts those versions.  Or we could put a switch in the UAVO to turn it on/off.  There doesn't seem to be a way to detect whether the GPS is authentic or clone.

Also, it would seem that this is a simple delay that could be fixed by adjusting some PID, yet I haven't been very successful adjusting VTOLPF horizontal PIDs in place of using this code fix.  Maybe there is even an interaction between horizontal and vertical PIDs.

Also, it is possible that this GPS has an issue such that when you just tilt it, it reports a different location even though you didn't move it horizontally.  This seems unlikely though because you can recreate the issue or a similar one with a Ublox GPS set to Pedestrian.  Also, I forget whether the Ublox recreation is just east west.  I suspect it is not, and thus may not be the same issue.

I remember doing experiments to mount a GPS higher to make sure it is not a local electro-magnetic field affect where the extra field causes a request for attitude change that makes that motor work harder that makes the field stronger... and finally reverses making the field change weaker and weaker as the motor is slower and slower.  This needs to be recreated/retested.

Conceptually there is an issue where tilting east west affects causes less mag field change than tilting north south.  Imagine rotating around the mag field vector where there is zero change.  This may require a change to the EKF to have a different correlation for north south tilting than for east west.  Do we have any users that are close to the Earth's equator?  This problem might be really bad for them because their mag vector is horizontal.

Also, one user (Tongala) reports that for him, the problem did not happen in RC2, but did happen in RELEASE.  Is it this simple to find the issue, or is it a tuning issue that randomly happened to this tune (his release tune) but not to that tune (his rc2 tune).

Here I remark that it did happen to me in RC1:
"Yesterday I was flying 16.09RC1 and noticed a slow east west oscillation..."
https://forum.librepilot.org/index.php?topic=382.msg17846#msg17846
Title: Re: East West oscillation with authentic DJI Naza GPS & maybe even with some clones
Post by: andyp on May 08, 2018, 09:14:11 pm
I have got the same problem with a clone NAZA GPS. Were can I download the fix? Is there a fix in the new FW, which is beta?
Title: Re: East West oscillation with authentic DJI Naza GPS & maybe even with some clones
Post by: TheOtherCliff on May 08, 2018, 09:52:02 pm
Earlier in this thread there are FC firmwares.
https://forum.librepilot.org/index.php?topic=3012.msg21154#msg21154

That firmware helps the issue, but there may be a better way, EKF settings changes or VTOLPF PID changes (although I experimented with VTOLPF PID changes with no success).  So it's not clear that this fix needs to be ported to next.  If you want it in next, the source code is also at that link; you can just put it in your local 'next' build, to put it in your own build of next.
Title: Re: East West oscillation with authentic DJI Naza GPS & maybe even with some clones
Post by: andyp on May 09, 2018, 07:34:55 pm
Now it works.

You answered my next question, whether it will be included in next or not and is available in the next downloads.
Title: Re: East West oscillation with authentic DJI Naza GPS & maybe even with some clones
Post by: TheOtherCliff on September 13, 2018, 04:57:14 pm
Just a reminder that this may be caused by some code changes between RC2 (16.09 RC2?) and prior to 16.09 release,  Is that when the EKF configuration was changed?
https://forum.librepilot.org/index.php?topic=3012.msg22422#msg22422
seems to be inconsistent with
https://forum.librepilot.org/index.php?topic=382.msg17846#msg17846
as one says it did not happen in RC2 (started later) and the other says it did happen in RC1

... and the work around code
https://forum.librepilot.org/index.php?topic=3012.msg21154#msg21154
is a fix for the symptom, not the cause.