LibrePilot Forum

Users => Vehicles - MultiRotors => Topic started by: octavvian on June 20, 2017, 12:24:56 am

Title: INS13 indoor
Post by: octavvian on June 20, 2017, 12:24:56 am
Hello,
revo mini FC, in complementary+mag - horizon is steady when sitting on the ground, INS13 indoor -  the horizon is balancing 2-3 degree.
Any idea? Normal behaviour? I'm kind afraid to try a flight. Thanks!
Title: Re: INS13 indoor
Post by: f5soh on June 20, 2017, 12:40:20 am
INS13 Indoor is only used for testing purposes and should not be used for flight.
Title: Re: INS13 indoor
Post by: TheOtherCliff on June 20, 2017, 03:30:00 am
In INS13 (both Indoor and Outdoor=Navigation) it is normal for "Flight Data page" horizon to wobble a few degrees.  This is because compass sensor has a lot of noise, and INS13 uses full 3D of compass, including for leveling.
Title: Re: INS13 indoor
Post by: Mateusz on June 20, 2017, 04:09:44 am
Small deviation 1-2 deg is ok I guess, but before flight

Title: Re: INS13 indoor
Post by: octavvian on June 20, 2017, 08:02:08 am
Thanks all for answers, system health all green, I'll try re-calibrate everything and see where is going.
Title: Re: INS13 indoor
Post by: octavvian on June 24, 2017, 09:03:24 am
Hi, no luck for me yet... I attached 3 photos,
1 complementary+mag alg. watch what happen when I switch to INS13 (indoor), 2 the transition between and 3 the INS13 (indoor), look at the attitude scope (right up corner).
Any toughs about the oscillations? Thanks!

PS I forgot to say, in complementary+mag, flies perfect, no drift.... and it's a tricopter (Tcopter :-)
Title: Re: INS13 indoor
Post by: Mateusz on June 24, 2017, 03:58:41 pm
Bottom right scope is not informative.
It is not informative because you just show MagState.x which is internal magnetometer. You don't see "x" from AuxMag here. And you should move copter a bit too see changes in all x,y,z axis for both magnetometers.
Title: Re: INS13 indoor
Post by: octavvian on June 24, 2017, 04:48:35 pm
OK, so what should I do? The copter is on the ground in both situations. On INS13 attitude scope (up right) looks weird and copter isn't flying. What I'm missing? Thanks!
Title: Re: INS13 indoor
Post by: TheOtherCliff on June 24, 2017, 08:05:47 pm
That oscillation is an EKF divergence that only happens when the model is motionless for many minutes.  It shouldn't happen if you are moving it around or flying it.  It should go away (for many more minutes) if you rotate the model around on all axes.

Look at the flight data page and if the PFD/HUD looks reasonable (only a few degrees of jitter) and health is green it should be OK.
Title: Re: INS13 indoor
Post by: octavvian on June 24, 2017, 08:32:37 pm
Hi, unfortunately the oscillations appears few dozen seconds  after siting on ground, I try to fly it but, it yaws and not stabe at all.
All green but it look like it have more than few degree of jitter. I'll try making a short movie. Thanks for ideas. 
Title: Re: INS13 indoor
Post by: TheOtherCliff on June 24, 2017, 08:40:15 pm
What does FlightData -> PFD look like, after GPS is green and you rotated it around and then set it on ground?

Another cause of this oscillation is aux mag misalignment by a large amount (say > 20 degrees).

Your first tests with INS13 should be with Attitude mode (Stab1).
Title: Re: INS13 indoor
Post by: octavvian on June 24, 2017, 08:52:02 pm
Hi, physically the aux mag is optically aligned, so it could be a misalignment by few degrees, I'll try that soon. I always start with stabilized...
Thanks.
Title: Re: INS13 indoor
Post by: octavvian on June 24, 2017, 10:02:03 pm
What I'm really frustrated is the fact that the copter fly's very well in complementary+mag alg. and switching to INS13 alg. everything goes haywire ... I do known that is a complex algorithm but never the less this should add security and reliability to it.
I'm sure it's my fault, but don't seems to find the error. To summarize when switching from complementary to INS13 it goes from flat virtual horizon to dancing Mary  ;D.
Title: Re: INS13 indoor
Post by: TheOtherCliff on June 25, 2017, 06:39:00 am
Dancing Mary...  Would you say that the PFD dances just a few degrees (less than 10) or a lot like flipping upside down etc.

Flipping upside down is caused by aug mag rotation problem.  If you are running an I2C aux mag, you probably need the attitude->magnetometer->auxmagrotation (whatever it is called...) to be 0,180,0 or 180,0,180 (they are the same).
Title: Re: INS13 indoor
Post by: octavvian on June 25, 2017, 09:47:17 am
Hi, is not flipping... The aux mag is a stand alone board so the mag IC position is exactly like on board one.
Thanks.
Title: Re: INS13 indoor
Post by: TheOtherCliff on June 25, 2017, 10:23:22 am
What numbers do you have your aux mag board orientation set to?  Test for correct board orientation on Attitude -> Magnetometer page.  All three bars must be centered within say +-3 no matter how you rotate the quad.  Did you try 0,180,0 yet?
Title: Re: INS13 indoor
Post by: Mateusz on June 25, 2017, 10:43:43 am
OK, so what should I do? The copter is on the ground in both situations. On INS13 attitude scope (up right) looks weird and copter isn't flying. What I'm missing? Thanks!

Why not to configure scopes to show MagSensor and AuxMagSensor ? Both sensors should behave the same on scopes if you rotate aircraft. See attached screenshot.


    ...
    • Make sure external magnetometer behaves the same way as internal one on scopes
    ...
Title: Re: INS13 indoor
Post by: octavvian on June 25, 2017, 10:57:40 am
Hi, after loading a next fw r335 (25.05.2017) and recalibrate everything (except temp drift), things got better, see pictures
1. mag settings page
2. scopes in complementary+mag (aux mag used)
3. scopes in INS13indoor (aux mag used)
Looks better isn't it?
Now PFD is stable.
Title: Re: INS13 indoor
Post by: octavvian on June 26, 2017, 07:08:13 pm
Switching to next branch solved some issues, but now:
1. WS281x Led not working anymore
2. When flying in stabilized and switching to althold, bird falls out of the sky
any ideas?
Appreciated.
Title: Re: INS13 indoor
Post by: f5soh on June 26, 2017, 10:11:00 pm
WS281x led works perfectly here using a Revo flashed with current Next branch and connected to the FlexiIOpin3

Double check your config, same for AltitudeHold
Title: Re: INS13 indoor
Post by: octavvian on June 26, 2017, 10:20:22 pm
On servo 6 is not working, on 16.09 fw WS281x led works fine, no flexiIOpin3 on mini revo clone.
Thanks for you're answers.
Title: Re: INS13 indoor
Post by: mr_w on June 27, 2017, 12:12:48 am
This seems to be caused by servo pin driver changes for dshot mode. ws2811 switches to gpio, but servo driver switches it back later to timer output (this was not the case in 16.09). Anyway, can you try switching bank mode for servo 6 out to dshot, given it does not conflict with your esc setup?

That will make servo driver also use gpio instead of timer out for that pin? That should be just workaround :)
Title: Re: INS13 indoor
Post by: octavvian on June 27, 2017, 12:53:11 am
This seems to be caused by servo pin driver changes for dshot mode. ws2811 switches to gpio, but servo driver switches it back later to timer output (this was not the case in 16.09). Anyway, can you try switching bank mode for servo 6 out to dshot, given it does not conflict with your esc setup?

That will make servo driver also use gpio instead of timer out for that pin? That should be just workaround :)
Hi, I just tried that, it light's up but only some white and yellow colors, far from what was showing in 16.09, dshot is set to 150khz.
Title: Re: INS13 indoor
Post by: mr_w on June 27, 2017, 01:17:07 am
I'm pretty sure I get short white blinks for disarmed and slightly longer yellow for input error such as when I leave the tx off.

https://librepilot.atlassian.net/wiki/display/LPDOC/Setup+WS281x+Led
Title: Re: INS13 indoor
Post by: octavvian on June 27, 2017, 01:31:38 am
Exactly!  :) But none of the rest warnings. Gues is something, better then nothing.
Title: Re: INS13 indoor
Post by: mr_w on June 27, 2017, 01:41:04 am
What are the other warnings you actually have?
Title: Re: INS13 indoor
Post by: octavvian on June 27, 2017, 08:41:59 am
What are the other warnings you actually have?

GPS -red
MAG - orange
INPUT - orange
led is showing yellow with white flashes.
 see vid
{https://youtu.be/zYBVIhZvHBs}
Title: Re: INS13 indoor
Post by: TheOtherCliff on June 27, 2017, 04:02:35 pm
GPS -red
MAG - orange
INPUT - orange
led is showing yellow with white flashes.
 see vid
{https://youtu.be/zYBVIhZvHBs}

GPS is the one thing that INS13Indoor doesn't use.
I would recalibrate mag.  It should be green, but sitting on ground sometimes it is not.
Input orange says your transmitter was switched off.
Title: Re: INS13 indoor
Post by: octavvian on June 27, 2017, 07:00:06 pm
GPS -red
MAG - orange
INPUT - orange
led is showing yellow with white flashes.
 see vid
{https://youtu.be/zYBVIhZvHBs}

GPS is the one thing that INS13Indoor doesn't use.
I would recalibrate mag.  It should be green, but sitting on ground sometimes it is not.
Input orange says your transmitter was switched off.

Hi, all that are true, but the problem here is that using last |next branch| fw, a mini revo clone (no FlexiIOpins) and a WS2812 LED connected on servo 6 output, the led doesn't show messages like {https://librepilot.atlassian.net/wiki/display/LPDOC/Setup+WS281x+Led}.
In fact with servo bank set to PWM is not showing anything, but with bank set to dshot, the LED is working like in the vid {https://youtu.be/zYBVIhZvHBs} mostly yellow with some white flashes....
Title: Re: INS13 indoor
Post by: TheOtherCliff on June 27, 2017, 07:29:16 pm
I recall seeing an issue with the 2811 LED support in next.  @Mr_w provided a work around.

Edit:  Ahhh...  Just above, here in this thread.  It doesn't work around your issue well enough?  Maybe go back to an older version for now?
https://forum.librepilot.org/index.php?topic=3576.msg24594#msg24594
Title: Re: INS13 indoor
Post by: octavvian on June 27, 2017, 07:58:55 pm
 :), no problem, I price more the advantages gain by the next branch over the diagnostic led (sincerely if you have telemetry, the need for WS281x led is kinda redundant and less clear for a true diagnostic), but was nice to see it work.
The second issue that I had was that with next 335 fw, after calibrating and everything, no orange/red, the copter fly nicely
but switched to alt hold, with all setting default, it drops from the sky. Any idea about that kind of behavior?
Title: Re: INS13 indoor
Post by: octavvian on July 05, 2017, 03:27:15 pm
Tested with next 423, stabilized OK, INS13 indoor OK as long the mag warnings don't kick in, althold drops from the sky 1 m or so, is recovering, is twitching....?! so back to 16.09, disappointed. 
Title: Re: INS13 indoor
Post by: TheOtherCliff on July 05, 2017, 05:58:18 pm
Help me understand what I need to set up to get this to happen.  Can I just set up Attitude with Manual thrust and Attitude with AltitudeHold thrust and see this happen?  I don't often use AltitudeHold, I usually use AltitudeVario.
Title: Re: INS13 indoor
Post by: TheOtherCliff on July 05, 2017, 06:09:57 pm
If you have time to test, here are the commits that are related to this and might have broken it.

A quick glance at the code and it looks like the last one of three (most recent) is the one that broke it.  Try that commit (should be broken) and the one before it (should work OK).  You can just back out that commit from your recent next and have everything working well.

I would also treat the first two commits as one, that is, don't bother to test each separately.  Test the commit before the first one and the commit of the second one.

commit 814a882a1dc0d8d938759cef5e7e902eb568c1e1
Date:   Sat Dec 10 09:09:53 2016 +0100
    LP-289 Manage kp=0 in PIDControlDown::UpdateParameters()

commit edd3b8689ba48a7d9c12d56ee344b3a79ee15769
Date:   Sat Dec 10 12:43:50 2016 +0100
    LP-289 Further clean up of PIDControlDown::UpdateParameters()

commit fb5f9034eab3ba32f8408b2f4b1a7a5a40ecf644
Date:   Thu Mar 9 18:48:36 2017 +0100
    LP-289 prevent initialization with non-zero pid->I accumulator (dangerous if kI is low)
Title: Re: INS13 indoor
Post by: octavvian on July 05, 2017, 06:16:17 pm
Hi, please understand, I didn't modify much the settings when moved from 16.06 to next branch, maybe a few adjustment, but nothing major.
I attached the 2 files containing settings. Further more altitude hold tuning is left default in the next branch just to see the difference between the two fw. In 16.09, altitude hold is tuned down because the copter is jumping.
Title: Re: INS13 indoor
Post by: TheOtherCliff on July 05, 2017, 08:33:50 pm
You didn't comment...

It looks like this commit is what broke it:
fb5f9034eab3ba32f8408b2f4b1a7a5a40ecf644

$ git diff ebc4b16d9a613ad48037a567554dccbbdc327a43 dcb3d760db41665584fa1497a65693158203e152 flight/libraries/math/pid.c
diff --git a/flight/libraries/math/pid.c b/flight/libraries/math/pid.c
index 4fba369..32f386f 100644
--- a/flight/libraries/math/pid.c
+++ b/flight/libraries/math/pid.c
@@ -6,7 +6,7 @@
  * @{
  *
  * @file       pid.c
- * @author     The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016.
+ * @author     The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
  *             The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
  * @brief      Methods to work with PID structure
  *
@@ -221,7 +221,10 @@ float pid2_apply(
         pid->D    = 0.0f;
 
         // t=0, u=u0, y=y0, v=u
-        pid->I    = (pid->u0 - pid->va) / pid->vb - pid->kp * (pid->beta * r - y);
+        // pid->I = (pid->u0 - pid->va) / pid->vb - pid->kp * (pid->beta * r - y);
+        // this is dangerous, if pid->I starts nonzero with very low or zero kI, then
+        // it will never settle!
+        pid->I = 0.0f;
     }
 
     // compute proportional part
Title: Re: INS13 indoor
Post by: octavvian on July 05, 2017, 08:49:20 pm
Thanks, I'll try it. For now I'm back to 16.09.