Altitude Hold improvement solution

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
jpeti29
Posts: 22
Joined: Wed Mar 07, 2012 9:19 am
Location: Hungary

Re: Altitude Hold improvement solution

Post by jpeti29 »

Why should the copter descend so quick (50cm/s)? DJI Naza only descend about 20-25cm/s. I thing, it will be good for us too at first time.

Eric
Posts: 38
Joined: Thu Nov 08, 2012 7:08 am

Altitude Hold improvement solution

Post by Eric »

Is it possible to check the if the BaroPID is always very small, say -200 in 5 seconds?

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: Altitude Hold improvement solution

Post by nhadrian »

Eric wrote:Is it possible to check the if the BaroPID is always very small, say -200 in 5 seconds?


Hi. It is possible, but I found an interresting phenomenon, if BaroPIB reach small enough parameter (around -250), it resets, and gets 0 again. Till now I couldn't find the origin of this. BTW, -200 is small enough as I described in the previous posts, to disarm.
Also, I'd like to let the Failsafe as simple as it can be, since it is not a pleasure function but an EMERGENCY solution, not a controlled autolanding!!!!!

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: Altitude Hold improvement solution

Post by nhadrian »

jpeti29 wrote:Why should the copter descend so quick (50cm/s)? DJI Naza only descend about 20-25cm/s. I thing, it will be good for us too at first time.


FAILSAFE_VARIO is a user-definable parameter in config.h ... ;) ... You can set what you want, the lower limit is 25 cm/s.

User avatar
dramida
Posts: 473
Joined: Mon Feb 28, 2011 12:58 pm
Location: Bucharest
Contact:

Re: Altitude Hold improvement solution

Post by dramida »

About a long range digital PAL video link in 433 Mhz open source project

viewtopic.php?f=7&t=2903&p=28701#p28701

User avatar
dramida
Posts: 473
Joined: Mon Feb 28, 2011 12:58 pm
Location: Bucharest
Contact:

Re: Altitude Hold improvement solution

Post by dramida »

Hi Adrian, any news about vario altitude mode and auto-landing? Can we put a new release based on your work? I built a new dji style quad and i am ready test some landings :)

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: Altitude Hold improvement solution

Post by nhadrian »

I'm ready with new release, only some final tests are pending....
And yes, the autolanding in failsafe_RTH and also a 2-step descending in failsafe_ALT is ready. And, other small improvements...
Also I made several major changes in code structure to be more clear and universal. Please be patient for 2-3 more days.

BR
Adrian

subaru4wd
Posts: 316
Joined: Sat Dec 08, 2012 2:16 am

Re: Altitude Hold improvement solution

Post by subaru4wd »

I cant wait to see what you come up with next Adrian :)

I have a problem though. I am trying to use your R9 and when I load it on my flight controller, my GUI (and i assume the board as well) does not see any RX input. My Transmitter has no effect on the board and the GUI shows all channels at 1500 as if the TX was turned off. I am not able to arm the board or anything :(

When I load 2.1 everything works as normal. Is there something I am overlooking in the code?

Thanks :)

User avatar
Leon11t
Posts: 38
Joined: Thu Sep 27, 2012 12:24 pm

Re: Altitude Hold improvement solution

Post by Leon11t »

What's your transmitter?
If the transmitter type like Turnigy 9x, then leave all defines in "PPM Sum Reciver" commented. For example: //#define SERIAL_SUM_PPM

Code: Select all

/****************************    PPM Sum Reciver    ***********************************/
      /* The following lines apply only for specific receiver with only one PPM sum signal, on digital PIN 2
         Select the right line depending on your radio brand. Feel free to modify the order in your PPM order is different */
      //#define SERIAL_SUM_PPM         PITCH,YAW,THROTTLE,ROLL,AUX1,AUX2,AUX3,AUX4,8,9,10,11 //For Graupner/Spektrum
      #define SERIAL_SUM_PPM         ROLL,PITCH,THROTTLE,YAW,AUX1,AUX2,AUX3,AUX4,8,9,10,11 //For Robe/Hitec/Futaba
      //#define SERIAL_SUM_PPM         ROLL,PITCH,YAW,THROTTLE,AUX1,AUX2,AUX3,AUX4,8,9,10,11 //For Multiplex
      //#define SERIAL_SUM_PPM         PITCH,ROLL,THROTTLE,YAW,AUX1,AUX2,AUX3,AUX4,8,9,10,11 //For some Hitec/Sanwa/Others

      // Uncommenting following line allow to connect PPM_SUM receiver to standard THROTTLE PIN on MEGA boards (eg. A8 in CRIUS AIO)
      #define PPM_ON_THROTTLE

subaru4wd
Posts: 316
Joined: Sat Dec 08, 2012 2:16 am

Re: Altitude Hold improvement solution

Post by subaru4wd »

thank you, i will try that. I am using a Turnigy9X TX with a FrSky DHT module & RX.

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: Altitude Hold improvement solution

Post by nhadrian »

Hi all,

********UPDATE**********
A have just noticed that an official r1311 is released. I checked and there were some small changes (ie. log values or governor or LCD changes) wich were not included in my r12 since I made my merge from _shared previously.
So I merged my code with the official r1311 now, and replaced the attachments!!!!
**********END*************

it's time to introduce my r12 code, based on r1311 Multiwii release!
I have included the autoland in Failsafe_RTH mode too, I even tested it! After landing, RPM will decrease than motors stops.

I completelly reworked the code, removed many redundant parts and also solved some major problems (many thanks to Alexinparis for pointing on them), now all my mods can be used independently too!!!

I have attached two zip files:
1) the COMPLETE code contains all my mods and should be used.
2) 5 more files for developers, with independent functions it is more easy to understand my changes and codes:
- BASIC - only minor changes but nothing new functions (only some led-flasher addons)
- FAILSAFE_ALT - only this function is included
- FAILSAFE_RTH - only this function is included
- VARIO_ALT_MODE - only this function is included
- RTH_ALT_MODE - only this function is included

I tried to explain all parametes correctly in config.h so please read carefully before use any of my mods.
Also please note that even if I made many-many flights during this period, hidden BUGs could be remained, especially with different setups (ie. I2C_GPS) so first test functions with EXTREME CAUTION!
For FAILSAFE functions please take time for previously described Failsafe testing procedure before first take-off!
Please keep in mind that all my functions assumes a well-tuned configuration with all important PIDs tuned (incl. GPS HOLD, BARO, ANGLE, etc...)

I hope you'll enjoy my code, I wish you all safe landings, and looking for any experiences!

BR
Adrian
Attachments
Multiwii_r1311_NHA_r13_VARIO_ALT_MODE.zip
(155.13 KiB) Downloaded 1281 times
Multiwii_r1311_NHA_r13_RTH_ALT_MODE.zip
(155.34 KiB) Downloaded 1307 times
Multiwii_r1311_NHA_r13_FAILSAFE_RTH.zip
(156.58 KiB) Downloaded 1235 times
Multiwii_r1311_NHA_r13_FAILSAFE_ALT.zip
(155.2 KiB) Downloaded 1282 times
Multiwii_r1311_NHA_r13_COMPLETE.zip
(159.16 KiB) Downloaded 1368 times
Multiwii_r1311_NHA_r13_BASIC.zip
(153.9 KiB) Downloaded 1258 times
Last edited by nhadrian on Sat Jan 12, 2013 8:56 am, edited 2 times in total.

Mystic3D
Posts: 31
Joined: Sat Jan 12, 2013 2:33 am

Altitude Hold improvement solution

Post by Mystic3D »

Amazing work!
Please forgive a noob question.
How do code changes like this get into "official" releases from a process/approval perspective?

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: Altitude Hold improvement solution

Post by nhadrian »

Hi,

************UPDATE**************
viewtopic.php?f=8&t=2371&p=29042#p29042
*************END*****************

It depends on the developers.
I sent all of these to Alexinparis, if he decides that any part of my job is stable/good/safety enough and also the resource consumption (memory/cycle time/etc) is good enough, he'll put it in.

BR
Adrian

ps.: since I'm not a qualified programmer, I'm sure some of my changes could be written on a more "elegant" way... but the idea itself looks like works!

User avatar
dramida
Posts: 473
Joined: Mon Feb 28, 2011 12:58 pm
Location: Bucharest
Contact:

Re: Altitude Hold improvement solution

Post by dramida »

Adrian, in latest MWC R13_complete, in config.h, confuses me:

I might be wrong, but i see two sets of configs regarding RTH:

firstly:

Code: Select all

    //#define FAILSAFE_RTH_MODE             // if GPS present and ready, copter starts RTH when signal lost. When signal is back, control is back again. 
    #define FAILSAFE_RTH_VARIO    100     // in cm/s - vario for RTH function for failsafe 
    #define FAILSAFE_RTH_ALT      700     // in cm   - minimum RTH altitude for failsafe. If copter is higher than this, it will keep altitude.
    #define FAILSAFE_RTH_HOME     300     // in cm   - home altitude for RTH, copter will descend to this altitude and wait.
    #define FAILSAFE_RTH_DELAY    15      // in s    - safety delay, after reaching HOME altitude, it'll land in FAILSAFE_ALT_MODE when safety delay terminates.


and at the end

Code: Select all

 

    //#define RTH_ALT_MODE             // define RTH custom approach height 
    //#define RTH_KEEP_ALT             // if the altitude is higher than the RTH_ALT, copter maintains that altitude instead of descending to target - according to Dramida's request
    #define RTH_VARIO      100       // in cm/s  - vario used for reaching target altitudes during RTH - lower limit is 25 cm/s!
    #define RTH_ALT        700       // in cm    - altitude during approach
    #define HOME_ALT       350       // in cm    - altitude after reaching home position   

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: Altitude Hold improvement solution

Post by nhadrian »

Yes, because the failsafe rth can be set up independently...;)
Ie. You can set higher altitude for failsafe rth than for normal. Or different vario...

Br
Adrian

subaru4wd
Posts: 316
Joined: Sat Dec 08, 2012 2:16 am

Re: Altitude Hold improvement solution

Post by subaru4wd »

I downloaded and setup this build for my Board. I connected using the GUI & went to setup my flight modes and noticed there were already flight modes programmed. So I tried to clear them and it would not let me. I was able to add to the flight mode programming, but I could not remove what was originally there.

I also had this issue when I flashed your R9, but I was able to resolve by just clearing EEPROM, reflashing R9, and the flight modes were gone... it let me load my custom configuration file & saved parameters to EEPROM. However flying with your R9 i noticed HeadFree mode did not work at all. I really did not have time to test anything else... after finding out about Heads Free I flashed my working copy of 2.1

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: Altitude Hold improvement solution

Post by nhadrian »

subaru4wd wrote:I downloaded and setup this build for my Board. I connected using the GUI & went to setup my flight modes and noticed there were already flight modes programmed. So I tried to clear them and it would not let me. I was able to add to the flight mode programming, but I could not remove what was originally there.

I also had this issue when I flashed your R9, but I was able to resolve by just clearing EEPROM, reflashing R9, and the flight modes were gone... it let me load my custom configuration file & saved parameters to EEPROM. However flying with your R9 i noticed HeadFree mode did not work at all. I really did not have time to test anything else... after finding out about Heads Free I flashed my working copy of 2.1


Hi,

could you please share a screenshot about these flight modes? I can't understand clearly what you are talking about. You mean BOX items are already checked?
also, please give me the type of your controller (MEGA, 328p), the copter type and the sensor board. I didn't modified any part of the EEPROM file, so it is really strange.

There is one more thing. If you power on multiwii only without RX, and connect to gui, and Failsafe is uncommented (enabled), the ANGLE and MAG will shown as active (green), that's because when in failsafe, these functions are enabled automatically. That is because there is no valid RX data. If you turn on RX too, they must disappear in case are not selected by BOXes.

Regarding ro r9, that was much less completed than r13, although the part of headfree was not touched in the code. You wrote it didn't worked at all, that means you couldn't activate the function, or activated but not worked as it should?

BR
Adrian

subaru4wd
Posts: 316
Joined: Sat Dec 08, 2012 2:16 am

Re: Altitude Hold improvement solution

Post by subaru4wd »

Sorry Adrian. I should have provided you with all the information :)

I am using this board here: http://witespyquad.gostorego.com/flight ... oller.html (easier than typing a list of spec's) flying on my X-Quad

I can't understand clearly what you are talking about. You mean BOX items are already checked?

Yes exactly. I should have got a screenshot, but the last 4 flight modes (BEEPER, LEDMAX, LANDLIGHT, HEADADJ) all had boxes marked at random. They all had multiple boxes checked for all 4 AUX channels too. I tried to uncheck them and write to the board, and the boxes remained marked. I could mark unmarked boxes, and successfully write to the board, but I could not remove the originally marked boxes.

This was all done with the board powered by a LiPo, so the RX was powered and my TX was active. And I have failsafe commented out in config.h, I am more interested in your improvements to AltHold right now, and not so much RTH.

With R9 & Heading Hold I was activating the function with my TX Switch but the aircraft did not act as if it were in headsfree mode. I Tried a couple times by orientating the board in different positions and booting it up. However I did not look at my 3DR telemetry while flying, so I am not 100% the board had activated HeadsFree mode.

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: Altitude Hold improvement solution

Post by nhadrian »

Thanks for detailed description.

That's really interresting indeed. I never had anything like this. Today I tested my code on a small arduino nano board (328p) with a 10DOF panel attached temporarily.
I uploaded many variations and tested to write/read EEPROM many times but I still couldn't reproduce this issue.
And this also presents with my r13? If yes, could you please try the official r1311 from download page on MWI repo?
Also, could you send your config.h in PM? I'd check, maybe you use something which I never had uncommented before and there is something interference...

I had once a similar behaviour with my older config on a Quadrino board around MWI 1.9-2.0 long time go, I don't know the reason till now, but I made a full EEPROM reset with an EEPROM reset sketch and disappeared.

If you can disconnect ESCs, you can test hearfree in your hand, arm the copter, apply some throttle, push roll or pitch. So you will see the motor outputs on GUI like they're trying to moce copter (2 of 4 motors will increase other will decrease). Now rotate copter around z axis (yaw) by 90 degrees, apply the same stick movement, and if headfree is active indeed, you will see that different motor outputs will increase or decrease...

BR
Adrian

Mystic3D
Posts: 31
Joined: Sat Jan 12, 2013 2:33 am

Altitude Hold improvement solution

Post by Mystic3D »

Tried 2.2 r1311 on a Avatar Tri., Alt Hold works great with default PID's. POS hold also works much better. High winds like 15 mph and held its own within a few meters

jgrouse
Posts: 5
Joined: Thu Jun 14, 2012 12:20 am

Re: Altitude Hold improvement solution

Post by jgrouse »

Really liking the way the baro alt hold works now.

On a separate line of code, there is a working baro/sonar alt hold. Using my MaxBotix MB1200 sonar this works really well when the alt is in sonar range. Anywhere out of that range and the baro code is really erratic. Probably does not help that there are trees around me and the sonar is probably bouncing lower than actual cm to the code as the hexacopter floats above the trees.

So two separate code bases which do great jobs for either sonar or baro alt hold, just not both.

I did try Multiwii_r1311_NHA_r13_COMPLETE with just baro and that is great, but then I thought I would try to replace the BaroAlt value with the sonarAlt value when BaroAlt < 300 and sonarAlt < 300 -

Code: Select all

  // pressure relative to ground pressure with temperature compensation (fast!)
  // baroGroundPressure is not supposed to be 0 here
  // see: https://code.google.com/p/ardupilot-mega/source/browse/libraries/AP_Baro/AP_Baro.cpp
  BaroAlt = log( baroGroundPressure / (baroPressureSum/(float)(BARO_TAB_SIZE - 1)) ) * (baroTemperature+27315) * 29.271267f; // in cemtimeter
  #if SONAR
    if ((BaroAlt < 300) && (sonarAlt < 300))
    {
       BaroAlt = sonarAlt;
    }
  #endif
  debug[0] = (int16_t)BaroAlt;
  debug[1] = sonarAlt;
  EstAlt = (EstAlt * 6 + BaroAlt * 2) >> 3; // additional LPF to reduce baro noise (faster by 30 µs)


But as soon as I enable BARO mode, the hexacopter goes ballistic regardless of the alt being < 300 or > 300. The altitude read from wireless telemetry is spot on across the whole range from the ground to 10+m so I cannot see how feeding BaroAlt the sonarAlt value would cause the max throttle condition when the only difference is that the sonar is more accurate at < 300cm. Even stranger when only the original BaroAlt value is being used when I am sitting at 10m, and it still wants to go ballistic. If I comment out the extra if test, the baro alt hold goes back to normal. I thought the issue might be that sonarAlt is int16_t, however EstAlt is showing the correct value and the debug[0] is showing the sonarAlt correctly.

Has anyone managed to meld sonar values into this offshoot of the 1311 code? I know there was talk about using sonar on the last few meters of a RTH auto landing.

jgrouse
Posts: 5
Joined: Thu Jun 14, 2012 12:20 am

Re: Altitude Hold improvement solution

Post by jgrouse »

Just dug a little deeper and it looks like the Multiwii_r1311_NHA_r13_COMPLETE baro alt hold code is time critical - if I comment out the analogRead(2) call for the sonar, baro alt hold behaves itself. I'm only calling it at the same frequency the baro sensor is read. Just looks like it's too much extra time for the alt hold to work reliably. I wanted the sonarAlt to be read in before the BaroAlt is set. This is where my analogRead sub is called (case 1)-

Code: Select all

  } else { // not in rc loop
    static uint8_t taskOrder=0; // never call all functions in the same loop, to avoid high delay spikes
    if(taskOrder>5) taskOrder-=6;
    switch (taskOrder) {
      case 0:
        taskOrder++;
        #if MAG
          if (Mag_getADC()) break; // max 350 µs (HMC5883) // only break when we actually did something
        #endif
      case 1:
        taskOrder++;
        #if SONAR
          MaxSonar_update();
        #endif       
      case 2:
        taskOrder++;
        #if BARO
          if (Baro_update() != 0 ) break;
        #endif
      case 3:
        taskOrder++;
        #if BARO
          if (getEstimatedAltitude() !=0) break;
        #endif   
      case 4:
        taskOrder++;
        #if GPS
          if(GPS_Enable) GPS_NewData();
          break;
        #endif
      case 5:
        taskOrder++;
//        #if SONAR
//          Sonar_update();debug[2] = sonarAlt;
//        #endif
        #ifdef LANDING_LIGHTS_DDR
          auto_switch_landing_lights();
        #endif
        #ifdef VARIOMETER
          if (f.VARIO_MODE) vario_signaling();
        #endif
        break;
    }
  }


Looks like a single analogRead eats up 100us. Is that a lot in the scheme of things?
Might need to go back to using the SRF02 I2C sonar. Bit more noise in the values, but far less processing time to get a value out of it.

subaru4wd
Posts: 316
Joined: Sat Dec 08, 2012 2:16 am

Re: Altitude Hold improvement solution

Post by subaru4wd »

nhadrian wrote:
If you can disconnect ESCs, you can test hearfree in your hand, arm the copter, apply some throttle, push roll or pitch. So you will see the motor outputs on GUI like they're trying to moce copter (2 of 4 motors will increase other will decrease). Now rotate copter around z axis (yaw) by 90 degrees, apply the same stick movement, and if headfree is active indeed, you will see that different motor outputs will increase or decrease...

BR
Adrian



I will try this tonight or tomorrow. I took my quad out to fly after completely rebuilding my motors (new bearings, perfectly balanced bells) and I had a silly grub screw vibrate loose sending my quad crashing into the pavement. Turned my new frame into a mess of broken plastic. Just needs 2 arms and a new set of props... hopefully my electronics survived the impact. I will have the frame on the bench and will do some further tests and send you a config.h

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: Altitude Hold improvement solution

Post by nhadrian »

subaru4wd wrote:I will try this tonight or tomorrow. I took my quad out to fly after completely rebuilding my motors (new bearings, perfectly balanced bells) and I had a silly grub screw vibrate loose sending my quad crashing into the pavement. Turned my new frame into a mess of broken plastic. Just needs 2 arms and a new set of props... hopefully my electronics survived the impact. I will have the frame on the bench and will do some further tests and send you a config.h


And what about EEPROM issue? Could you overcome on it? Do you have the same behaviour with the untouched official r1311 too?

BR
Adrian

wilco1967
Posts: 156
Joined: Thu Aug 18, 2011 6:04 pm
Location: Winterswijk, Netherlands

Re: Altitude Hold improvement solution

Post by wilco1967 »

Tried failsafe RTH with autoland with the 1311 R13 yesterday with my BMP085 equipped tricopter, with mixed results....

after turning off the transmitter, the copter started heading back... it went to RTH altitude correctly.
when it arrived at home, it started descending.... but after a few seconds, while still up at approx 10 meters, it decided, it had landed, and it disarmed.... :roll: :shock:

quite funny to see how it decided to quit, and it fell down like a brick..... :lol: however, I don't think this was intended behaviour...
only some props broken, and a stripped gear of the tail servo.... all repaired already... 8-)

I guess the issue could be my BMP-085 not being very acurate... alt holt works reasonable, but has always been a bit bumpy... when decending, it always overshoots, and climbs back up before making another drop that overshoots.....
I suspect the alt PID output reached -200 (or whatever it max value is), causing it to think it landed, thus causing the motors to disarm.... actual 'landing' then happened a few seconds later, but with slightly higher vertical velocity... :lol:

Perhaps adding a few seconds delay after reaching max alt PID output could prevent it from disarming while still in the air ?
tuning of the the alt PID controller could also be helpfull, but I don't want to risk it like this..... I only have limited supply of props :roll:

It did the same thing some time back with rev 9 (i think)... when decending after reaching home....

Anyone else using this with a BMP-085 baro ?

Overall it seems to work quite well..... just some minor 'tweaking' required
Thanks !

schott1984
Posts: 9
Joined: Tue Jan 15, 2013 4:56 am

Re: Altitude Hold improvement solution

Post by schott1984 »

Anyone notice the AP_MODE define is commented out of nhadrian's uploaded code? I

What gives here?

I'm new here. Nice to meet you all.

I could use a little bit of explanation regarding this deadspan and how it works. I know it's off-topic... Sorry.

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: Altitude Hold improvement solution

Post by nhadrian »

schott1984 wrote:Anyone notice the AP_MODE define is commented out of nhadrian's uploaded code? I
What gives here?


Hi, this is a deadspan for roll/pitch. If you apply mode roll/pitch during hold mode, it will release from hold mode and once stick is back to centre, it'll save the new position as home. It must be uncommented, unless Arduino gives a compilation error.

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: Altitude Hold improvement solution

Post by nhadrian »

wilco1967 wrote:Tried failsafe RTH with autoland with the 1311 R13 yesterday with my BMP085 equipped tricopter, with mixed results....

after turning off the transmitter, the copter started heading back... it went to RTH altitude correctly.
when it arrived at home, it started descending.... but after a few seconds, while still up at approx 10 meters, it decided, it had landed, and it disarmed.... :roll: :shock:

quite funny to see how it decided to quit, and it fell down like a brick..... :lol: however, I don't think this was intended behaviour...
only some props broken, and a stripped gear of the tail servo.... all repaired already... 8-)

I guess the issue could be my BMP-085 not being very acurate... alt holt works reasonable, but has always been a bit bumpy... when decending, it always overshoots, and climbs back up before making another drop that overshoots.....
I suspect the alt PID output reached -200 (or whatever it max value is), causing it to think it landed, thus causing the motors to disarm.... actual 'landing' then happened a few seconds later, but with slightly higher vertical velocity... :lol:

Perhaps adding a few seconds delay after reaching max alt PID output could prevent it from disarming while still in the air ?
tuning of the the alt PID controller could also be helpfull, but I don't want to risk it like this..... I only have limited supply of props :roll:

It did the same thing some time back with rev 9 (i think)... when decending after reaching home....

Anyone else using this with a BMP-085 baro ?

Overall it seems to work quite well..... just some minor 'tweaking' required
Thanks !


Hi,

I'm happy to hear that code works, and sad to hear your crash!!!
The BaroPID off-condition is raised to -250 in r13, so it can't be the reason.

BUT! For safety reasons, FAILSAFE_OFF_DELAY condition is still active in all my FAILSAFE modes, that means, once this time ends, it will disarm!!! (I mentioned somewhere earlier, maybe should highlihgt again...).
So, it must be set high enough to allow get home before this time ends. In my code it is 500 by default, it means only 50s. I suggest to raise this value to the neccessary extent!
I'll highlight this fact in my config.h, sorry for that!!!

Regarding to bumpy behaviour, first of all, you should fine-tune alt hold PIDs during hovering. If you have already stable and good enough hovering behaviour but still very bumpy in raising/descending, I'll think on how to setup the correction values.

BR
Adrian

Eric
Posts: 38
Joined: Thu Nov 08, 2012 7:08 am

Altitude Hold improvement solution

Post by Eric »

nhadrian wrote:
wilco1967 wrote:Tried failsafe RTH with autoland with the 1311 R13 yesterday with my BMP085 equipped tricopter, with mixed results....

after turning off the transmitter, the copter started heading back... it went to RTH altitude correctly.
when it arrived at home, it started descending.... but after a few seconds, while still up at approx 10 meters, it decided, it had landed, and it disarmed.... :roll: :shock:

quite funny to see how it decided to quit, and it fell down like a brick..... :lol: however, I don't think this was intended behaviour...
only some props broken, and a stripped gear of the tail servo.... all repaired already... 8-)

I guess the issue could be my BMP-085 not being very acurate... alt holt works reasonable, but has always been a bit bumpy... when decending, it always overshoots, and climbs back up before making another drop that overshoots.....
I suspect the alt PID output reached -200 (or whatever it max value is), causing it to think it landed, thus causing the motors to disarm.... actual 'landing' then happened a few seconds later, but with slightly higher vertical velocity... :lol:

Perhaps adding a few seconds delay after reaching max alt PID output could prevent it from disarming while still in the air ?
tuning of the the alt PID controller could also be helpfull, but I don't want to risk it like this..... I only have limited supply of props :roll:

It did the same thing some time back with rev 9 (i think)... when decending after reaching home....

Anyone else using this with a BMP-085 baro ?

Overall it seems to work quite well..... just some minor 'tweaking' required
Thanks !


Hi,

I'm happy to hear that code works, and sad to hear your crash!!!
The BaroPID off-condition is raised to -250 in r13, so it can't be the reason.

BUT! For safety reasons, FAILSAFE_OFF_DELAY condition is still active in all my FAILSAFE modes, that means, once this time ends, it will disarm!!! (I mentioned somewhere earlier, maybe should highlihgt again...).
So, it must be set high enough to allow get home before this time ends. In my code it is 500 by default, it means only 50s. I suggest to raise this value to the neccessary extent!
I'll highlight this fact in my config.h, sorry for that!!!

Regarding to bumpy behaviour, first of all, you should fine-tune alt hold PIDs during hovering. If you have already stable and good enough hovering behaviour but still very bumpy in raising/descending, I'll think on how to setup the correction values.

BR
Adrian


Why don't you think BaroPID is not the reason about crash?

The Baro drifts in about 3m.

As I suggested before, check if the BaroPID is contiguously very low in 5 seconds.

And we do not know how long the failsafe delay will be enough. Even if we set an very big value, we do not know if the battery can last that long.

So we'd better to calc a speed for it to go home in about 10 seconds.

The longer the quad stays in air without RC, the more chance for it to crash.

Hope you think about it. That was how I implemented my quad.

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: Altitude Hold improvement solution

Post by nhadrian »

Hi,

The BaroPID is between +-80-100 during normal altitude working. Just test out what's happening when you reduce the throttle from hovering position by 250 during manual mode. It will fell down from the sky...
The drift in alt reading is not important unless it drifts 3m between two baro sensor readings. (Because drift is relative drift, so the only caused by sensor drift is that it will hover 2-3 m away from target altitude)

The reason why I dont have any timer after BaroPID gets under -250 is to aovid further damages when copter couldn't land perfectly. (Ie. Burning ESCs caused by stucked props, when landing in high grass)

Failsafe_off_delay can be set to high enough (ie. if you know your flight time is 8 min, set it to 8000).
Anyway, it must be kept in mind that Failsafe is a safety function, not a leisure one, the only function of faisafe rth is to bring the copter back if possible inside RC range or near take-off zone and prevent crashes from high altitude, not to make a perfect auto landing. (At least this is my oppinion).

Br Adrian
Last edited by nhadrian on Tue Jan 15, 2013 4:20 pm, edited 2 times in total.

schott1984
Posts: 9
Joined: Tue Jan 15, 2013 4:56 am

Re: Altitude Hold improvement solution

Post by schott1984 »

nhadrian wrote:
Hi, this is a deadspan for roll/pitch. If you apply mode roll/pitch during hold mode, it will release from hold mode and once stick is back to centre, it'll save the new position as home. It must be uncommented, unless Arduino gives a compilation error.

Thank you for the reply!

wilco1967
Posts: 156
Joined: Thu Aug 18, 2011 6:04 pm
Location: Winterswijk, Netherlands

Re: Altitude Hold improvement solution

Post by wilco1967 »

nhadrian wrote:BUT! For safety reasons, FAILSAFE_OFF_DELAY condition is still active in all my FAILSAFE modes, that means, once this time ends, it will disarm!!! (I mentioned somewhere earlier, maybe should highlihgt again...).
So, it must be set high enough to allow get home before this time ends. In my code it is 500 by default, it means only 50s. I suggest to raise this value to the neccessary extent!
BR
Adrian


That must be the 50 seconds setting that caused it to fall..... checked it was indeed set at 500 (50s).... :roll:
raised it to 5000, so should not interfere anymore.... will try again next time if weather allows...

User avatar
dramida
Posts: 473
Joined: Mon Feb 28, 2011 12:58 pm
Location: Bucharest
Contact:

Re: Altitude Hold improvement solution

Post by dramida »

Here is how it flies R13 with Crius AIOP

http://www.youtube.com/watch?v=BdaN-ddVmi8

Last edit:

I activated RTH function with altitude control during RTH. I found out that copter starts moving immediately twards home, even the RTH altitude is not achieved. Practically, before reaching RTH altitude, the copter makes about half of distance back. In this case trees and houses could not be avoided. A more healthy approach for failsafe RTH is when altitude is below RTH altitude, first position hold until safe altitude is reached, then continue with RTH and autoland...

albertoLG
Posts: 57
Joined: Fri Sep 07, 2012 8:14 am

Re: Altitude Hold improvement solution

Post by albertoLG »

with latest revisions my altitude hold is messed.... when I switch on the BARO the quad just shoot in the air at full throttle like a rocket... if i revert back to my latest working (r1298, haven't tried others) then it's fine... happened to somebody else?

CRIUS AIO PRO V1.1

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: Altitude Hold improvement solution

Post by nhadrian »

dramida wrote:Here is how it flies R13 with Crius AIOP

http://www.youtube.com/watch?v=BdaN-ddVmi8

Last edit:

I activated RTH function with altitude control during RTH. I found out that copter starts moving immediately twards home, even the RTH altitude is not achieved. Practically, before reaching RTH altitude, the copter makes about half of distance back. In this case trees and houses could not be avoided. A more healthy approach for failsafe RTH is when altitude is below RTH altitude, first position hold until safe altitude is reached, then continue with RTH and autoland...


It is much harder to solve this problem, and takes a lot of time. I'll try to figure something out.
Last edited by nhadrian on Thu Jan 17, 2013 7:19 pm, edited 1 time in total.

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: Altitude Hold improvement solution

Post by nhadrian »

albertoLG wrote:with latest revisions my altitude hold is messed.... when I switch on the BARO the quad just shoot in the air at full throttle like a rocket... if i revert back to my latest working (r1298, haven't tried others) then it's fine... happened to somebody else?

CRIUS AIO PRO V1.1


Hi, could you please describe what release did you try? Perhaps the official r1315 from multiwii repo?

For me the latest change for MS5611-01 (in official r1315) isn't working, perhaps there is something around dT calculations (in latest r1315 the dT is changed from 32 to 64 bit integer).

albertoLG
Posts: 57
Joined: Fri Sep 07, 2012 8:14 am

Re: Altitude Hold improvement solution

Post by albertoLG »

nhadrian wrote:
albertoLG wrote:with latest revisions my altitude hold is messed.... when I switch on the BARO the quad just shoot in the air at full throttle like a rocket... if i revert back to my latest working (r1298, haven't tried others) then it's fine... happened to somebody else?

CRIUS AIO PRO V1.1


Hi, could you please describe what release did you try? Perhaps the official r1315 from multiwii repo?

For me the latest change for MS5611-01 (in official r1315) isn't working, perhaps there is something around dT calculations (in latest r1315 the dT is changed from 32 to 64 bit integer).


Yes, tested 1315 and don't work, 1310 wasn't working too... tomorrow i can try all the revisions, from 1298 to 1310, and I'll try to find where is the problem... the only changes I can see right now are in the IMU.ino and Multiwii.ino, rev1303
http://code.google.com/p/multiwii/sourc ... ed/IMU.ino

http://code.google.com/p/multiwii/sourc ... ltiWii.ino

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: Altitude Hold improvement solution

Post by nhadrian »

in r1315 there are changes in the MS5611 code.
You should try the official r1313 from multiwii repo download site.

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: Altitude Hold improvement solution

Post by Alexinparis »

nhadrian wrote:
albertoLG wrote:with latest revisions my altitude hold is messed.... when I switch on the BARO the quad just shoot in the air at full throttle like a rocket... if i revert back to my latest working (r1298, haven't tried others) then it's fine... happened to somebody else?

CRIUS AIO PRO V1.1


Hi, could you please describe what release did you try? Perhaps the official r1315 from multiwii repo?

For me the latest change for MS5611-01 (in official r1315) isn't working, perhaps there is something around dT calculations (in latest r1315 the dT is changed from 32 to 64 bit integer).


Hi,

There was effectively a bug in r1315 about the last change on baro MS.
I've just corrected it and made a new dev release.

subaru4wd
Posts: 316
Joined: Sat Dec 08, 2012 2:16 am

Re: Altitude Hold improvement solution

Post by subaru4wd »

Alexinparis wrote:There was effectively a bug in r1315 about the last change on baro MS.
I've just corrected it and made a new dev release.


"giggity giggity"

Mystic3D
Posts: 31
Joined: Sat Jan 12, 2013 2:33 am

Re: Altitude Hold improvement solution

Post by Mystic3D »

Alexinparis wrote:
nhadrian wrote:
albertoLG wrote:with latest revisions my altitude hold is messed.... when I switch on the BARO the quad just shoot in the air at full throttle like a rocket... if i revert back to my latest working (r1298, haven't tried others) then it's fine... happened to somebody else?

CRIUS AIO PRO V1.1


Hi, could you please describe what release did you try? Perhaps the official r1315 from multiwii repo?

For me the latest change for MS5611-01 (in official r1315) isn't working, perhaps there is something around dT calculations (in latest r1315 the dT is changed from 32 to 64 bit integer).


Hi,

There was effectively a bug in r1315 about the last change on baro MS.
I've just corrected it and made a new dev release.


There is some timing problem with Baro and r1316, when I first take off, it will either give full power, or seems like 30% power, it's random, as to which way. If I land, disarm,rearm, then it seems to "correct" itself. It does not matter if default PID, on Alt Hold, or not, Positive/Negative values, no difference. same behavoir in r1311.

When it does "hold" , it's like you san hear it "switch"
Sorry just a noob, 3 weeks into Multi's, if I am not following protocol, please advise.

albertoLG
Posts: 57
Joined: Fri Sep 07, 2012 8:14 am

Re: Altitude Hold improvement solution

Post by albertoLG »

Alexinparis wrote:
nhadrian wrote:
albertoLG wrote:with latest revisions my altitude hold is messed.... when I switch on the BARO the quad just shoot in the air at full throttle like a rocket... if i revert back to my latest working (r1298, haven't tried others) then it's fine... happened to somebody else?

CRIUS AIO PRO V1.1


Hi, could you please describe what release did you try? Perhaps the official r1315 from multiwii repo?

For me the latest change for MS5611-01 (in official r1315) isn't working, perhaps there is something around dT calculations (in latest r1315 the dT is changed from 32 to 64 bit integer).


Hi,

There was effectively a bug in r1315 about the last change on baro MS.
I've just corrected it and made a new dev release.


Thanks Alex, today I'll try the 1316 and report back

regards

albertoLG
Posts: 57
Joined: Fri Sep 07, 2012 8:14 am

Re: Altitude Hold improvement solution

Post by albertoLG »

Tested the 1316 and the problem is still the same... BARO ON my quad is launched like a rocket :-(

as I said the problem is earlier than 1315

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: Altitude Hold improvement solution

Post by Alexinparis »

Mystic3D wrote:
There is some timing problem with Baro and r1316, when I first take off, it will either give full power, or seems like 30% power, it's random, as to which way. If I land, disarm,rearm, then it seems to "correct" itself. It does not matter if default PID, on Alt Hold, or not, Positive/Negative values, no difference. same behavoir in r1311.

When it does "hold" , it's like you san hear it "switch"
Sorry just a noob, 3 weeks into Multi's, if I am not following protocol, please advise.


Hi,

In all current releases including the last r1316, the default baro mode is alt hold.

In this mode, the baro switch must not be enable on the ground, but only once in the air to "lock" the current alt.

If you enable it on the ground before the take off, you could encounter high variations of throttle at the beginning and think it doesn't work.

albertoLG
Posts: 57
Joined: Fri Sep 07, 2012 8:14 am

Re: Altitude Hold improvement solution

Post by albertoLG »

Alexinparis wrote:
Mystic3D wrote:
There is some timing problem with Baro and r1316, when I first take off, it will either give full power, or seems like 30% power, it's random, as to which way. If I land, disarm,rearm, then it seems to "correct" itself. It does not matter if default PID, on Alt Hold, or not, Positive/Negative values, no difference. same behavoir in r1311.

When it does "hold" , it's like you san hear it "switch"
Sorry just a noob, 3 weeks into Multi's, if I am not following protocol, please advise.


Hi,

In all current releases including the last r1316, the default baro mode is alt hold.

In this mode, the baro switch must not be enable on the ground, but only once in the air to "lock" the current alt.

If you enable it on the ground before the take off, you could encounter high variations of throttle at the beginning and think it doesn't work.


I don't enable it on the ground, I fly around, then when I switch it on, the quad shoot in the air like a rocket... as I said with previous version (1298) it is perfect... maybe 20 cm. up or down, and when I switch it on the copter just stay there, no full throttle is given.

P.S.
I can make a video when the weather will be better

Mystic3D
Posts: 31
Joined: Sat Jan 12, 2013 2:33 am

Re: Altitude Hold improvement solution

Post by Mystic3D »

I do not enable ALT_HOLD on the ground, I take off, flip to Angle Mode, Hover, then flip to ALT_HOLD = Baro+Angle+Mag.

Other note: I do clear EEPROM before I load new code, I do have Sirius and it's got a tube over the baro sensor with cotton as a "buffer" inside
Not sure if this matters, but expo on throttle 30% and Midpoint of TH is 70%

Deet
Posts: 129
Joined: Sun Jul 08, 2012 1:54 am

Re: Altitude Hold improvement solution

Post by Deet »

Mystic3D wrote:I do not enable ALT_HOLD on the ground, I take off, flip to Angle Mode, Hover, then flip to ALT_HOLD = Baro+Angle+Mag.

Other note: I do clear EEPROM before I load new code, I do have Sirius and it's got a tube over the baro sensor with cotton as a "buffer" inside
Not sure if this matters, but expo on throttle 30% and Midpoint of TH is 70%



Why do you have midpoint of throttle @70%, that may be your problem

User avatar
dramida
Posts: 473
Joined: Mon Feb 28, 2011 12:58 pm
Location: Bucharest
Contact:

Re: Altitude Hold improvement solution

Post by dramida »

Please consider that mid point for alt hold is 1500us for throttle, regardless where your copter hovers. If you like to hold altitude in a undefined position of your throttle, you should comment this line:

Code: Select all

#define ALT_HOLD_THROTTLE_MIDPOINT        1500  // in us    - if uncommented, this value is used in ALT_HOLD for throttle stick middle point instead of initialThrottleHold parameter.


This could be the cause of " jumps"when activating Alt Hold with throttle more than 1550 with #define ALT_HOLD_THROTTLE_NEUTRAL_ZONE 50

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Altitude Hold improvement solution

Post by copterrichie »

A really Good Throttle Curve is required here, over and out.

Mystic3D
Posts: 31
Joined: Sat Jan 12, 2013 2:33 am

Altitude Hold improvement solution

Post by Mystic3D »

Good Info, I will reset the midpoint TC from .7 to .5. I had it set to .5 in 2.1 without this behavoir.

Post Reply