Airplane RTH BaseFlight

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

Re: Airplane RTH BaseFlight

Post by PatrikE »

It seems i deleted my files.
But Schugabe keeps a copy.
https://github.com/schugabe/baseflight/tree/plane-rth/

ardufriki
Posts: 88
Joined: Thu Dec 13, 2012 4:47 pm

Re: Airplane RTH BaseFlight

Post by ardufriki »

Hi Patrik, I see this thread id old, and I dont know if this development is dead o not. I want to try your 32bits code for another airplane project I have (the main one is running CRIUS SE I2C GPS Multiwii -Patrik code ;) ).

The question is that I will start with a CC3D board (no BARO, no MAG), so I dont know if adding a GPS is enought to have RTH. AFAIK, the 8 bits code doesnt use BARO or MAG for airplane RTH if I`m correct. Im sure is neccesary for quadcopter, but not sure if I can use the simple CC3D board for this airplane project. Thx.

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

Re: Airplane RTH BaseFlight

Post by PatrikE »

The Fixed wing RTH is integrated in Baseflight official now.
It does RTH and Pos hold.
I have a unofficial version with the Cruise mode too.
BF Dev version
I'm not sure if Baseflight can run on a CC3D board.

I have started a Guide for Baseflight setup to.
http://fotoflygarn.blogspot.se/2015/01/ ... dwing.html

User avatar
Gaijin
Posts: 82
Joined: Sat Jan 14, 2012 8:00 am

Re: Airplane RTH BaseFlight

Post by Gaijin »

Hey Patrick,

A question, I now have the latest base flight in a retro fixed wing (we are exploring the idea of stabilised free flight that can return to you), normal flight with horizon / angle works well but when I activate alt hold it either goes vertical or dives very steeply, I have no idea if it relates to PIDs or how to tune them on fixed wing.

The fc is a new afromini, until I crack this I can't even test the RTH or pos hold, any ideas?

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

Re: Airplane RTH BaseFlight

Post by PatrikE »

The original AltHold code is written for copters and have been modified for Airplanes by someone.
But i'm not sure if it ever been verified as working.
It seems it even use throttle position to change Alt.
I have not looked at it since I use a different Althold in gps modes.

Maybe some PID tweaks can help?
It sounds like the P value is way too high to start with.

You have to experiment a bit with it.
And if you get it to work please report.
I doubt it will work good....

User avatar
Gaijin
Posts: 82
Joined: Sat Jan 14, 2012 8:00 am

Re: Airplane RTH BaseFlight

Post by Gaijin »

Thanks for the reply,

but to be clear GPS functions won't work without Alt hold, correct?

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

Re: Airplane RTH BaseFlight

Post by PatrikE »

Gps functions don't use the standard althold.
Just enable Angle and RTH.
It have alt hold integrated in the function.

ardufriki
Posts: 88
Joined: Thu Dec 13, 2012 4:47 pm

Re: Airplane RTH BaseFlight

Post by ardufriki »

Hi Patrik, I have installed an Airplane with Cleanflight in a CC3D board and it flies nicely. As I understand, baseflight will never be compiled for others targets than Naze32, so I cant wait for baseflight to be compiled for my CC3D boards.

Are you going to make a "pull request" for airplane RTH in cleanflight? It would be great, as Cleanflight is working in many diferent boards than naze....

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

Re: Airplane RTH BaseFlight

Post by PatrikE »

Basflight is still very similar to the MWii code.
Cleanflight is too clean for me...
To many files in the structure.
But anyone who have better knowledge about cleanflight can merge it.

Sorry

ardufriki
Posts: 88
Joined: Thu Dec 13, 2012 4:47 pm

Re: Airplane RTH BaseFlight

Post by ardufriki »

So...a Naze32 is mandatory here.

Is a Naze32 Acro (no baro/no mag) suitable for baseflight airplane RTH? Thx

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

Re: Airplane RTH BaseFlight

Post by PatrikE »

All Naze32 Acro/Full, Afronini or a Afromini Amaze or any clone will work fine.
Afromini Amaze rev3 seems like a really nice FC.
The code uses GPS data for altitude and heading on Airplanes.

Latest dev code for planes
https://dl.dropboxusercontent.com/u/975 ... 150711.rar

ardufriki
Posts: 88
Joined: Thu Dec 13, 2012 4:47 pm

Re: Airplane RTH BaseFlight

Post by ardufriki »

Thank you Patrik. I have bought one Naze32 right now to test your code !! I won't wait to the developement of RTH in Cleanflight.

User avatar
leocopter
Posts: 101
Joined: Mon Jan 27, 2014 7:29 pm

Re: Airplane RTH BaseFlight

Post by leocopter »

Hi Patrik,
airplane mode is broken in (August) Baseflight : no output to servos ...
Also, can we bring back the CLI in the GUI ... it is needed for gyro_lpf and softserial settings on the new afromini board and flip32 ...
Airplane mode flies very well on a number of my machines. Thanks !
Chris

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

Re: Airplane RTH BaseFlight

Post by PatrikE »

There was some changes made in servomixer recently.
Unfortunately it broke most of the servo functions.
Hopefully it will be fixed soon.

Use my Dev version instead of the stable Baseflight
https://dl.dropboxusercontent.com/u/975 ... 150711.rar

ardufriki
Posts: 88
Joined: Thu Dec 13, 2012 4:47 pm

Re: Airplane RTH BaseFlight

Post by ardufriki »

Hi,
I am already flying with baseflight RTH airplane !!

How can I change the radius when the plane circles? It seems toooo big and I dont see anything in the docs.

May be I have to adjust the mag_declination parameter? (I have afronaze amaze with baro, no mag).

Thx

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

Re: Airplane RTH BaseFlight

Post by PatrikE »

fw_gps_maxcorr is the maximum banking allowed.

Increase to 30 - 35 for tighter turns.
35 should give a radius around 25-30 meters.

Baseflight fixed wing Howto
http://fotoflygarn.blogspot.com/2015/01 ... dwing.html

ardufriki
Posts: 88
Joined: Thu Dec 13, 2012 4:47 pm

Re: Airplane RTH BaseFlight

Post by ardufriki »

thx Patrik, so I dont't have to touch mag_declination, isn't it?

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

Re: Airplane RTH BaseFlight

Post by PatrikE »

ardufriki wrote:thx Patrik, so I dont't have to touch mag_declination, isn't it?

If you don't have a mag leave it on zero.
The code uses data from GPS if you don't have a MAG.

ardufriki
Posts: 88
Joined: Thu Dec 13, 2012 4:47 pm

Re: Airplane RTH BaseFlight

Post by ardufriki »

Now I have set

fw_gps_corr = 45
fw_gps_rudd = 45
I_Yaw = 0

The plane is 800 mm wingspan, 298gr, and I have to say that in the tests I have had some strong wind.

RTH still does too big curves, far away , so I have to take manual control. And in PH the plane goes too far away so I have to take manual control too.

Any other parameters to tweak?

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

Re: Airplane RTH BaseFlight

Post by PatrikE »

NavR.
Increase P to maybe double.
I think it is 1.4 default.

And maybe increase I term to later.

Does the plane bank 45 degree?
It should with this settings you have.

ardufriki
Posts: 88
Joined: Thu Dec 13, 2012 4:47 pm

Re: Airplane RTH BaseFlight

Post by ardufriki »

Yes it does 45º perfectly.

I will try to change "gps_nav_p", it seems it is what you said as NAVR:

Code: Select all

{ "gps_nav_p", VAR_UINT8, &cfg.P8[PIDNAVR], 0, 200 },


The fact is that in my Easystar 2 with multiwii RTH crius 8 bits code, the behaviuor is diferent. When there is a RTH event, the plane comes back inmediatly, but with baseflight it goes far, far away...

I will try that and report.

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

Re: Airplane RTH BaseFlight

Post by PatrikE »

If the banking is 45 degree and the plane don't turn.
Then you must apply more elevator compensation.
There's a cli setting and standard is 1.0.
Max is 2.0
Try to play with it.

ardufriki
Posts: 88
Joined: Thu Dec 13, 2012 4:47 pm

Re: Airplane RTH BaseFlight

Post by ardufriki »

Wow !! I have tested the same plane with "fw_roll_comp" = 2 and "gps_nav_p = 28" (both parameters double from defaults). Less wind than yesterday, but now it works perfectly.

The plane comes to me almost straigh (it seems the straigh line depends on throttle), and poshold is AMAZING !! I have tried RTH 25 times, and every time it worked fine. I have used a full battery in PH mode (circles and circles until lipo saver beeped). Very good job.

Thanks again for your efforts and work. I owe you two beers !!.

Two new questions:

- If I shoot RTH with no throttle, the plane doesn't put any. So I think that it is far away it won't come.

- In one of the PH circles it started to take much heigh. Is there an altitude control in that mode?

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

Re: Airplane RTH BaseFlight

Post by PatrikE »

Hi great you got the problems solved..

The GPS PID's is generally the half in BF compared to MWii.

I don't really understand the first question.
But if you lower throttle to min it will stop the motor in RTH mode.
The plane will try to return as long as it have air under the wings.
It will not add any elevator up for climbing to avoid stall.
I have also added a new parameter for power off glide. "fw_glide_angle" ( in 1/10th degrees)
It will add dive angle to maintain speed up. (set fw_glide_angle = 10// => 1 degree nose down)
A good sailplane can have a glide ratio 1:50 = ~1 degree.
Motor planes Not so good.

It should keep altitude. But...
If the plane climbs in PosHold the fw_roll_comp is too high.
Since the plane almost will be in a constant turn the added elevator can push it up.
And fw_roll_comp is added last after all calculations.

Well lots of mumbling..
But might give you some input to keep up the testing.

/Patrik

Johninarky
Posts: 15
Joined: Sat Jul 05, 2014 9:44 pm
Location: Rogers,Arkansas USA

Re: Airplane RTH BaseFlight

Post by Johninarky »

I am just trying Airplane mode. I fly Quads using Taranis Tx and Cleanflight so am familiar with Baseflight and GUI.
The GUI shows the plane surfaces to be 3 4 5 6. The plane I would use needs dual Aileron. I program the Tx so that
those channels go to the proper place. When I open the GUI and check the outputs in the receiver tab, none of
the channels are correct. My FC is a flip32,using SBUS on Channel 4, select SBUS,select Serial Rx, which are the
same setup I use on the Quads. Using Baseflight_FW_150711. I need some suggestions.
John

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

Re: Airplane RTH BaseFlight

Post by PatrikE »

Hi,
First All mixing is done in the FC.
Baseflight airplane Mixer have two wing servos, elevator and Rudder.
Hence you should set up the TX as a normal 4ch airplane plus the AUX channels.
No mixing in the radio.

Johninarky
Posts: 15
Joined: Sat Jul 05, 2014 9:44 pm
Location: Rogers,Arkansas USA

Re: Airplane RTH BaseFlight

Post by Johninarky »

Thanks Patrik,
I set it up as T(1&2) A(3&4) R(5) E(6) which is what the GUI defines. That didn't work, so I tried AETR which is the
default on the receiver tab, and that didn't work. It is strange that on the Receiver screen AETR is listed as default,
but the colored bar graph shows AERT.
Could it be that some how SBUS is not working like it should. I have no problem in Cleanflight using it.
Thanks again for your response.
John

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

Re: Airplane RTH BaseFlight

Post by PatrikE »

The colored bar graph layout depends on the creator of the Gui.
Multiwii Gui have TAER so don't worry about that.

Just make sure TX and Gui have same order.
Do you see any channels working at all?

To activate SBUS

Code: Select all

feature SERIALRX
set serialrx_type = 2

Johninarky
Posts: 15
Joined: Sat Jul 05, 2014 9:44 pm
Location: Rogers,Arkansas USA

Re: Airplane RTH BaseFlight

Post by Johninarky »

Hi Patrik,
Some progress after switching to AETR.
Tx is setup as AETR AUX1234

Servos connected to Output pins on FC as follows
Ail 3 & 4
Ele 6
Thr 1 or 2
Rud 5
All servos move when Tx sticks are moved except Throttle.
The GUI receiver display now shows all channels moving correctly
including Throttle, moving from 1000 to 2000.
Throttle on GUI does not move unless ARM and my Thr save Switch
is activated, just as it should. I have tried Thr on pins 1 and 2, neither work.
Something is causing the Thr servo to drive all the way to one end position
and it stays there, even though the GUI shows the bar graph moving with the Thr stick.
John

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

Re: Airplane RTH BaseFlight

Post by PatrikE »

Arm is used on planes too.
You must ARM before throttle activates.

Johninarky
Posts: 15
Joined: Sat Jul 05, 2014 9:44 pm
Location: Rogers,Arkansas USA

Re: Airplane RTH BaseFlight

Post by Johninarky »

Hi Patrik,
Well, problem solved for now.
The problem was I setup the Tx for 5 outputs(2 ailerons) which in the FC moved the
Aux inputs down one. My Arm was on Aux 4, which was now not defined. I didn't understand
your original comment of set up regular program, so I set up as usual for 2 Ail. servos.
One other thing I don't get is how the GPS maintains the planes altitude without the FC having a baro.
Thanks again for the help.

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

Re: Airplane RTH BaseFlight

Post by PatrikE »

The code simply uses the Altitude and heading data from the Gps together with the loc data..

Johninarky
Posts: 15
Joined: Sat Jul 05, 2014 9:44 pm
Location: Rogers,Arkansas USA

Re: Airplane RTH BaseFlight

Post by Johninarky »

Thanks Patrik,
I didn't know that the GPS had a way of determining altitude.
John

User avatar
leocopter
Posts: 101
Joined: Mon Jan 27, 2014 7:29 pm

Re: Airplane RTH BaseFlight

Post by leocopter »

Hi Patrik !
I was glad to read the previous posts on adjusting settings for RTH and PH. I 've had trouble with those last summer. The airplane mode itself flies beautifully ... even in 30 km/h winds. Living in Quebec (Canada) I am surrounded by lakes and forests ... I waterproofed several of my planes so that I can hand launch them from my boat and land them in the water ... I specially enjoy flying twin engine EPPs (laminated following CrashTestHobby techniques) from Na Polskim Niebe (the Polish sky). I have a fleet of Me110, Mosquito, PZL37, Beaufighter, Yermolayev-2 ... and others that are a joy to fly. With a 15 $ Flip32 and your code, I have a fleet of crash resistant (never seriously broke a frame), waterproof and almost idiot proof planes !
Thanks again !

Chris :D

P.S: I also put Flip32s in FliteTest scratch builds. The FT Mustang, Bloody Wonder and FT Duster fly like a charm ... they are dirt cheap to build (like all my other planes I laminate them). The only minus is that Dollar tree foam board is not waterproof.

User avatar
leocopter
Posts: 101
Joined: Mon Jan 27, 2014 7:29 pm

Re: Airplane RTH BaseFlight

Post by leocopter »

Hi Patrick.
I'm in the middle of my 'building season' (just finished a few twin engines from Na Polskim Niebie and a Wraith from VAS - IBCrazy). I'm putting in the FC's. The latest BF is still broken ... no output to servos. so I'm using your 20150711 file. The motors spin when armed. Even when I check the 'Don't spin motor when armed' box. Is this normal ?
Regards,

Chris

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

Re: Airplane RTH BaseFlight

Post by PatrikE »

Load the latest dev and not the stable...
The servos is broken in the stable version!..

User avatar
leocopter
Posts: 101
Joined: Mon Jan 27, 2014 7:29 pm

Re: Airplane RTH BaseFlight

Post by leocopter »

Thank you Patrik.
I have flashed the Jan 6 BF dev. Mixer is good. fw_roll_comp now defaults to 100 (In your version, the default is 1). I am guessing that it is equivalent and that the scale of 100 permits precise tuning of the parameter ?
Have you tried Inav ? I wonder how it compares to your code.
Cheers,
Chris

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

Re: Airplane RTH BaseFlight

Post by PatrikE »

It's just a change to integer in the code instead of Float!.
100% equals 1.0

No i have not flown iNav just made some bench tests of it.
I don't like the behaviour of the PID's it use though!..
It behaves more like a copter!
Will maybe test it when summer temperatures return.

User avatar
leocopter
Posts: 101
Joined: Mon Jan 27, 2014 7:29 pm

Re: Airplane RTH BaseFlight

Post by leocopter »

As I have already stated, your code flies very well with a dozen of my airframes : from the small FT Duster to the larger Me110. I've also used your code with a Spitfire, a flying wing, a self leveling Albatros from CrashTestHobby (Rudder used instead of ailerons) and many more. For the airplanes (up to 1m wingspan) I use p=2.5, i=0.022, d=23. The planes are very responsive and stable even in high winds. Now I'm building a larger fleet. I had a 1.5 m Mosquito and a 1.3 m Me110 custom built for me by Marek from NaPolskimNiebie. I'm also configuring a twin engine Wraith form VAS. Hours of fun !
The only reason I was considering Inav was for WP navigation. For the moment I will configure an AIOP flashed with MWI 2.4 and a PX4Lite with APM for this. I don't know how easily they will tune ...
Keep up the good work and thank you.

Chris

User avatar
leocopter
Posts: 101
Joined: Mon Jan 27, 2014 7:29 pm

Re: Airplane RTH BaseFlight

Post by leocopter »

Hi Patrik,

I have 2 quick questions for you : fw_glide_angle = 10 corresponds to 1 degree ?
Also for fw_roll_comp is the usual tuning rage between 100 and 200 ?

thks,
Chris

Cereal_Killer
Posts: 221
Joined: Fri Mar 06, 2015 5:44 am

Re: Airplane RTH BaseFlight

Post by Cereal_Killer »

Hello PatricE, I have read threw ALL your blog and forum posts located all over the Internet but I can't find a definitive answer from you (some mention from other people but no definitive answer)...

Naze32 (rev6)
NEO M8N GPS module on UART2
Running latest stable dev build
Plus FrSky telemetey on softserial
Plus Bluetooth on UART1

I'm currently running PPM however here's my issue: I'm using a X4R-SB receiver and to get it to do cppm output you have to jumper pins 2 and 3 DURING BIND, this presents a problem as I regularly need to rebind (I have 2 transmitters, one a tray type that I don't always feel like using) but again, in order to get ppm from the x4r you have to set a jumper DURING BIND (and then remove it for use, it doesn't do PPM if you don't set that jumper). If I could run SBUS I could eleminate this step (the jumper setting during binding)...

Is there anything preventing me from running GPS on softserial to open up UART2? What's the minimum baud rate your code needs GPS to be running at for smooth navigation? S.port is 38500 baud and [from previous experience I know that] both softserial ports must run at the same speed therefore I'd need to be able to run GPS at 38500 to match. Is that good (note I have no problem reconfiguring the GPS module in Ucenter)

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

Re: Airplane RTH BaseFlight

Post by PatrikE »

Sorry.
I don't have any experience of using Softserial.
But GPS should be OK to run at 38500 since only 5Hz is used.
I have been running a NMEA at 36k on MWii FixedWing.

Or you could just connect a push button as a jumper easy accessable.

Cereal_Killer
Posts: 221
Joined: Fri Mar 06, 2015 5:44 am

Re: Airplane RTH BaseFlight

Post by Cereal_Killer »

Hi again, gps finally came in.

Bluetooth on uart1
GPS on uart2 @ 57kbaud
FrSky telemetey on SS1 (not working after adding gps but I'm still working on it)
D4r receiver in ppm mode (swapped out the x4r when I did gps)

It's not recognizing failsafe, I can get the rx to do preset failsafe and that'll cut the motor and center the elevons but baseflight won't recognize the failsafe to trigger RTL.

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

Re: Airplane RTH BaseFlight

Post by PatrikE »

You can do like that.
But the FC will never know it's in failsafe and continue to circle at home until the battery runs flat.

A better option is to trim down Throttle to absolute minimum and save it as failsafe.
leave all other channels neutral.
You can probably trim it to around 990µs or lower.
Adjust failsafe threshold with cli command slightly higher than you programmed RX.
Trim throttle back to min 1000 and ensure non of the first 4 channels can trigger the threshold.

I got an Idé though.
Maybe add Failsafe as a Mode via AUX.
Then it will Show if it's triggered and make it possible to test safely without turning of TX.
That's always a bit scary!..

Post Reply