Horizon mode only when horizontal? - fun idea?

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
ctzsnooze3
Posts: 11
Joined: Thu Aug 07, 2014 7:23 am

Horizon mode only when horizontal? - fun idea?

Post by ctzsnooze3 »

Hi - and my apologies for cross-posting...

I fly a lot in Horizon mode and I really enjoy it. I do quick flips, rolls etc and have a great time. To whoever made it - thank you!

I've noticed, however, that when near-vertical (i.e. nose pointing to sky), the quad is very uncomfortable - with hardly any throttle at all, it very strongly wants to level out. And of course it's impossible to overcome the levelling while inverted (can't fly straight down for example) in Horizon mode.

So.. I had an idea... to make Horizon mode 'fade out' the further away the quad gets from horizontal and correct side up (i.e. 100% acro when inverted or near-vertical)

Basically I was wondering if it was possible in code to reduce the levelling tendency the further away the quad is from actually being horizontal (level and correct side up)?

Kind of like applying the Horizon mode algorithm based not only on stick position but also on the actual angle of the quad as well? The idea is that as the angle away from horizontal increases, levelling is proportionally reduced, so that when vertical or inverted, the quad enters 100% acro mode.

This would allow the inverted phase of a slow loop to proceed smoothly, just like a slow loop in acro mode, without having to fight the levelling during the inverted period. And one could go high, invert and fly downwards with control. Currently that's impossible in Horizon mode.

The downside would be that the quad would not try to self-level while inverted, the user would have to get it closer to horizontal (and correct side up), centre the sticks, and Horizon mode would do it's magic as usual.

I reckon this could be a very fun modification to Horizon mode for advanced Horizon mode pilots. Horizon mode would now be active only around the Horizontal plane. For people keeping the quad basically level and right side up, there would be no change. But for people doing Acro moves like flips and loops, it would be much more fun, maybe?

Hope this tweaks some interest in people who know how to do these things... if I knew how to do it, I would! :-)

Cheers - Chris

PatrikE
Posts: 1976
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: Horizon mode only when horizontal? - fun idea?

Post by PatrikE »

The function already exists (Kind of..)
//#define ACROTRAINER_MODE 200 // viewtopic.php?f=16&t=1944#p17437

Based on the stick position.
If you lower to 50 you will have autoleveling only around midstick.
Otherwise it will be in full acro.
Use it as it is or experiment and change it from RC to ACC data for control.

ctzsnooze3
Posts: 11
Joined: Thu Aug 07, 2014 7:23 am

Re: Horizon mode only when horizontal? - fun idea?

Post by ctzsnooze3 »

Hi Patrick

Thanks to your advice I found the AcroTrainer code. It seems to be an all or none switch, operable in Angle mode, that disables all modes (i.e. puts you into Acro) when the sum of the roll and pitch sticks add up to a value exceeding the AcroTrainer value.

It could be useful as a testing method for the idea I had above. As you noted, it’s stick based, so I’d need to know how to test if the current angle of the quad was either upside down, or more angled of horizontal than say 60 degrees, and then switch Horizon mode off.

Is accZ from IMU.cpp a realtime Z-axis orientation indicator? At the moment I don’t know how to get that kind of info into the AcroTrainer code.

Any help you could provide me with here would be gratefully appreciatedfpv.

Thanks

Chris

ctzsnooze3
Posts: 11
Joined: Thu Aug 07, 2014 7:23 am

Re: Horizon mode only when horizontal? - fun idea?

Post by ctzsnooze3 »

I also wondered what would happen if you over-wrote the 50 degrees max inclination to say 90 degrees?
C

PatrikE
Posts: 1976
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: Horizon mode only when horizontal? - fun idea?

Post by PatrikE »

Change to this if.
Then the copter will disable stab modes over 60 degrees if sticks is Off center.
Sounds ok?

Code: Select all

  #if defined(ACROTRAINER_MODE)
    //if(f.ANGLE_MODE){
   if(f.HORIZON_MODE && ( abs(att.angle[ROLL]) >600 || abs(att.angle[PITCH]) >600)){
It will still recover from inverted if sticks is centered.

Max inclination only limits max allowed tilt in angle mode if i understand correct.

ctzsnooze3
Posts: 11
Joined: Thu Aug 07, 2014 7:23 am

Re: Horizon mode only when horizontal? - fun idea?

Post by ctzsnooze3 »

Try this?

in multiwii.cpp, at

#if PID_CONTROLLER == 1 // evolved old school


comment out the default so it's like this:

//if ( f.HORIZON_MODE ) prop = min(max(abs(rcCommand[PITCH]),abs(rcCommand[ROLL])),512);


then put this in its place:
// this uses equal angle and horizon mode corrections - limited to 425 empirically
// when vertical is half acro even with centred sticks
// needs better inverted code doesn't know its inverted
if ( f.HORIZON_MODE ) {
prop = min(max(abs(att.angle[PITCH]),abs(att.angle[ROLL])),900); // prop is 0 when level 900 when vertical if 10 per degree
prop = prop + (min(max(abs(rcCommand[PITCH]),abs(rcCommand[ROLL])),500)<<1); // prop plus 2x borizon ie up to 1900
prop = min(prop>>2,425); // divide by 4 so max practically 475 limit to 425 bc it works best like this I think
}


Here's a video of what it does in hand testing:

https://www.youtube.com/watch?v=-eKqtMAei4Y

I've found this code to give much better control with acro-type qualities in Horizon mode - even when the quad is vertical to slightly inverted, it's smooth all the way. Additionally, it will self-level in nearly all orientations if you want it to.

Please give it a try and compare it to the default Horizon code at near-vertical quad orientations.

Cheers

C

Post Reply