Developer

ACRO for ArduPilot 3.1

3689532793?profile=original

Hi all,

My motivation to get involved in the development team was to bring a good ACRO mode to ArduCopter. Three or four months ago Robert Lefebvre suggested that we could integrate the rate error and use it to correct the platform in the body frame. He went on to demonstrate this on Heli's. We have since learned that MultiWii use a similar approach and code was developed by Bob Dorion based on MultiWii and discussed here http://www.diydrones.com/forum/topics/flipping-arducopter.

I have taken Robert's approach and integrated it with the current ACRO trainer aids with the help of Robert and Bob. Here is the result:

ArduCopterACRO.zip

This code is based on ArduCopter 3.01rc1 so if you haven't got this flying yet, don't bother with this code.

Changes:

Replace Earth Frame ACRO with Body Frame ACRO

Reduce the dead band on the roll and pitch inputs

In the same way as you could before you can disable all trainer functions by setting
ACRO_BAL_PITCH,0
ACRO_BAL_ROLL,0
ACRO_TRAINER,0

For my flight testing I have been using:
ACRO_BAL_PITCH,50
ACRO_BAL_ROLL,50
ACRO_P,4.5
ACRO_TRAINER,0

Things to discuss are:

Is the performance acceptable?

What additional features are needed? (switched trainer functions, zero throttle doesn't stop motors)

Is there a better algorithm?

Do you see any problems with the code?

How does the performance and feel compare with other systems? (please only comment if you have flown those systems and this system on a well set up copter, anything less is a waist of every bodies time)

I have spent at least 20 minutes doing nothing but flips and rolls of various combinations and mixtures and a similar amount of time doing yank and bank maneuvers. I have not found a problem or any bad habits.

I look forward to your feedback and ideas.

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • Developer

    No problem Markus! This is noob code that is why I haven't put anything in the wiki yet.

    When ACRO_TRAINER = 0 it doesn't use ACRO_BAL_PITCH and ACRO_BAL_ROLL at all. The idea is CH7/8 to toggle between 2 (just starting), 1 (rolling and flipping but with some leveling) and 0 (no leveling of any type).

  • Thanks, Leonard! Sorry for adding another noob question: If you set ACRO_TRAINER to 0, does that mean that the values of ACRO_BAL_PITCH and ACRO_BAL_ROLL are irrelevant? Are they "overwritten" by the TRAINER setting? This would be great, so I could set both ACRO_BAL... to 1 and use CH7/8 to toggle between 1 (just starting) and 0 (experienced)...

  • Developer

    Markus:

    Yes we changed them to go from 0 to 3. Initially I had a bit of a brain fart and made it a percentage but all this really does is add a divide by 100 into the code.

    Christoffer:

    You will be able to do flips with ACRO_TRAINER = 0 or 1. When set to 0 it will be like having ACRO_BAL_PITCH and ACRO_BAL_ROLL set to 0.

    If you are an experienced ACRO pilot I would set everything to 0 because you probably don't want anything messing with your ACRO. If you are just starting out I would use settings like this (assuming you still want to do flips)
    ACRO_BAL_PITCH,1
    ACRO_BAL_ROLL,1
    ACRO_TRAINER,1

    You can set a three position switch using ch7 or ch8 to switch between the three trainer modes by setting ch7 or ch8 to 14. This changes the trainer from OFF to slow leveling to angle limiting.

    Just remember that you can always switch to STABILIZE and give it maximum throttle to save yourself.

    ACRO is a great way to crash your multi so make sure you have an escape plan!!

    Good luck and have fun :)

  • Another question: Does the range of ACRO_BAL_ROLL and ACRO_BAL_PITCH go from 0 to 200 (as it is mentioned here: http://copter.ardupilot.com/wiki/acro-mode/) or from 0 to 3 as it says this wiki page: http://copter.ardupilot.com/wiki/arducopter-parameters/#Acro_Balanc...?

  • Thank you for your quick answer.
    I just got a quck followup (noob) question
    Do I still need to have the parameters set to 0? (To do both flips and rolls)
    ACRO_BAL_PITCH,0
    ACRO_BAL_ROLL,0
    ACRO_TRAINER,0

    If not, do anyone have a suggestion to good starting settings.
    I've set the to 0 for now, and will probably be hading out in a couple og hours to try it out.
    And thanks for all the help.

  • Developer

    Yep, you should be able to make acro do flips without any problems. The only thing that will stop you if you have the three position switch activated and have set it to limited.

  • Is these changes implemented in V3.1 -rc2?
    If I in mission planner chooses to use beta V3.1 -rc2, do I need to change anything to try flips and rolls?

  • Yes - poking at this some more, it seems under load the voltage drop due to current can take the curve out of the thrust profile. Instead of looking quadratic, it's more cubic with a mostly linear region through the middle. I guess I'll look into what Randy did for the throttle curve and adjust my min/max values to see if that helps with my low throttle wobbles. 

  • Developer

    Nice pickup Bob,

    This has already been handled though. The way we do it is we scale each motor output to make them more approximately linear. (this was a feature added by Randy) 

    The response isn't perfectly quadratic because of the way the ESC and motors interact. Randy tested a bunch of ESC's/Motor/Prop combinations and came up with a curve that was a good compromise.

    I have kept this in mind with my tuning and always compare the stability of my tune at low throttle and near maximum throttle. Randy's throttle curve seems to keep everything pretty well right as I don't see any change in stability.

  • Hey Leonard, 

    Have you or Randy ever experimented with dynamic rate controller scaling based on throttle position?

    Here's what I'm thinking:

      - Thrust vs Throttle (PWM) is quadratic in nature and we generally tune our rate controllers to behave properly at hover throttle.

      -  When the throttle moves away from hover, the slope (dThrust/dThrottle) changes, effectively changing the gain of the rate controllers. So at 20% throttle, we have detuned the rate controller by about 2.5x assuming a perfect quadratic thrust curve and a hover point at 50%. 

     So what I'm thinking is taking the output of the rate controller and multiplying it by a factor like (THR_MID/throttle)  to compensate for the non-linear thrust curve. To avoid the singularity at zero and to make it variable I was considering the form::

    Gcomp = ((1-CompF) + ((THR_MID/ThComp)*CompF))

    Where ThComp is some limited range version of the current throttle: e.g.  max(min(throttle, 80%), 20%),

    CompF is a tuning factor to go from no compensation (0.0) to full compensation (1.0)

    and Gcomp is then used to boost/cut the rate controller outputs (Pitch/Roll only?)

    I'm hoping this would reduce the vertical descent wobbles by giving the controllers more authority at low throttle and also carry over into acro maneuvers where the throttle is reduced during flips and rolls.

    Any thoughts?

This reply was deleted.