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

  • well almost...the tumble works now...almost...as it pass 90deg, yaw flips also since we are in earth frame in stabilized modes...so it starts to correct the yaw as the tumble goes 90 to -90 ...winds up a little cocked...I tried to fix it by setting yaw mode to ACRO_YAW during the tumble...it works! but after the tumble, setting yaw mode back (I stored it in the beginning...which would be for example YAW_HOLD if in stabilize mode),but it wont accept rc yaw inputs...in permanent heading lock....almost like its in a nav mode...have to land it because I dont have yaw control...so close, yet so far away...

  • Got it working....thanks!...really have to think thru how the roll and pitch are varying as you progress thru the tumble so as to let the flight controllers take over at the right point...got some interesting never ending tumbles to earth today until I figured out the correct algorithm for the state machine...

    Also,I added the SPORT style mode to the MPng 3.0.1 port with your body/earth mix ACRO code from the front of this pose, but using YAW_HOLD  like it does in 3.1 code and like STABILIZE mode results in permanent heading lock in this mode...no yaw stick control...going to just use ACRO_YAW and see if that works...just want ACRO+ALT_HOLD...sounds simple, but evidently not...

  • Was all I need I think...roll goes +/-180...pitch +/- 90...explains it neatly...thanks!

  • Developer

    Hi Henry,

    I am sorry but I have spent very little time looking at the flip mode. I really can't help you without looking at your code and 3.0.1 is an eternity ago for me. :)

    The only helpful suggestion I may be able to make is pitch is measured up from horizontal so it gets to 90 degrees and comes back down again. As pitch passes through vertical, roll jumps by 180 degrees and the copter goes from right way up to upside down. If you have not handled this transition correctly the copter will roll 180 degrees as it goes past vertical. This may explain what you are seeing.

    Sorry I can't help more.

  • Thinking back through what I saw, I think that the pitch flip is stopping in all flight modes at inverted...in STAB it then rolls out upright and is facing 180deg from start...in ACRO there is no leveling so it just stays inverted and falling for the last 1sec long phase of the tumble in which its expected the normal flight controllers finish the move...hence hits earth...so I should prevent flips or tumbles when in ACRO since it wont finish the move without autoleveling...

    but still doesnt answer why it moves to the last stage of the auto-aerobatic sequence before getting past -90 in pitch...actually it must be happening between  90 and -90 for it to autolevel facing the opposite direction...still stumped...it works great in the roll axis...

  • Leonard, I have a bit of a unique situation...I have an AIOP V2 board...the latest stable port to that board from Arducopter is  3.0.1...it flies well and I am NOT using a GPS (an FPV miniquad for bashing!)....

    but...1) I wanted a true ACRO mode...so I ported the code at the beginning of this post into the MPng code...all that was involved was a few minor changes to Arducopter.pde, a new define, and replaced the Attitude.pde code with yours....although I have not extensively tested it...it seems to work great! thanks!..

    2) I love the auto-flip switch! but, I wanted a tumble switch also!!...so I cloned the flip code so it will work on ch7/8...

    and testing it today was a limited success...perhaps you can point in the right direction in the code to fix the anomalous behaviour...

    in STAB or ALTHOLD, the tumble completes but winds up facing 180deg opposite direction...the yaw appears so fast I cant really tell when it occurs...also in ACRO it flips back or forward inverted and hangs until it crashes...at least I wasnt quick enough to flip it back over before mother earth ate it...

    any suggestions....  3.1 is not stable on the AIOP and progress is occuring slowly

    PS I disable logging to avoid cpu cycles...dont know if this really helps or not since its not in the fast loops...

  • Thats excellent information :)

    exactly what I was after.

    Thanks Leonard

  • Developer

    Hi HAK,

    Yes you can change maximum angle with the ANGLE_MAX parameter. This affects the maximum angle in stabilize and sport mode.

    The difference between sports mode and acro mode can be best demonstrated using yaw and pitch as an example. When you have the nose of the copter down at 45 degrees (pitch angle = -45 degrees) and you apply a yaw command.

    In sport mode the nose will rotate around with the nose down at 45 degrees ie. the pitch angle won't change from -45 degrees. Stabilize does this too if you hold the pitch stick forward. So Sport mode is basicly a rate controlled stabilize mode.

    In ACRO mode when you apply a yaw command the pitch angle with initially be -45 degrees. After we have yawed by 90 degrees the pitch angle will be 0 degrees. After yawing by 180 degrees, the pitch angle becomes 45 degrees. After yawing by 270 degrees the pitch angle will be 0 degrees again. And finally after yawing 360 degrees the pitch angle will become -45 degrees again.

    Does that make it clear?

  • Leornard - just wanted to check if there is a way to change max angle. It was mentioned it might be implemented in sports mode?

    What is the real difference (flight characteristic) between sport and acro?

  • Developer

    Sorry 2 helps stop you from going inverted making it easier for a beginner to fly ACRO safely and still get used to rate only control.

This reply was deleted.