PID vs Dynamic Inversion #4
Replies: 17 comments 7 replies
-
|
Hi Sean, I think yes to everything you have said. Especially if you are flying a warbird or any aerobatic plane that is getting out into the very nonlinear edges of the envelope you need a good model using real stability derivatives. Also you are correct on needing a good representative range of data to least squares fit through. It's easy to end up with a big ball of noise and a fit that is nonsense. I have been imagining much more docile GA aircraft or survey drones that spend most of their time in the safe predictable range of the envelope. I have a pretty compelling simulator proof of concept, but it's based on some data I can't share, so I have been slowly working towads a demo with one of my model airplanes. (But I'm doing this for fun, not on a deadline and this summer I've been distracted with completely rewriting my ground station gui.) I just went out yesterday though and collected 3.5 hours of flight data, so I'm looking forward to starting to crunch through that and see if I can extract anything useful here. If it does look promising then I do plan to code up some simple control laws around this idea and see if I can demo it in real flight. So for example, in real flight test data and in a simulator model I was able to pull out a strong correlation between roll rate and aileron deflection * qbar ... especially in the regions of the envelope a GA pilot would spend 100% of their time flying in. Similarly I found a strong linear relationship between elevator position and Accel_z / qbar. Accel_z / qbar also strongly correlates with Alpha. Of course there are more terms to consider in a complete model, but this seems to be a pretty dominant term. My RC model plane has a high pitch line so there is also a strong correlation between power and pitch rate (or the amount of elevator needed to keep pitch rate at zero.) Oh, and one more wrinkle ... if you keep the model really simple ... you can collect data as you fly and update your least squares fit ... the system can "learn to fly" your airplane in it's current configuration ... cg ... weight ... etc. You can probably do this with a more complicated model too, but it might be riskier if your terms cross couple or the noise gets put in the wrong bucket ... I could see a risk of a more complicated model diverging, especially if peg the plane at a single flight condition for a long time. What I had pretty good success with in simulation was to fit these relationships (in flight or in post) and using that as an "open loop" model to drive the ouput based on the pilot's stick request (roll rate and load factor). Then I added a damper "D" to slow down all the dynamics that I hadn't accounted for in my model. And finally I pasted an integrator (actually a "PI" controller) at the end of the pipeline to account for any modeling errors/environment factors. I could watch the output of the integrator as an indicator of my model fit quality. If the model is perfect the integrator would have nothing to do and be close to zero. If the integrator needed to saturate out the control surface range, then I'd know my model was really bad (or I'm in a spin, or on the ground, or something not accounted for in my model.) Yes, the integrator can jump at the start of a step maneuver ... probably my model not accounting for the dynamics as you point out. In a real scenario you would also have to account for things like flap position that can significantly change/affect the aerodynamic model. I haven't observed any twitchiness ... but I could see getting into a state like that depending on how you've crafted up your control law flow. I would never say that in general this would be a good way to approach creating your control laws. But there has seemed to be a lot of goodness flowing out of this approach and some positives I've stumbled into by accident, and my sim tests have been very promising ... so I do want to push forward and see how far I can take this. A side note (and I'm not sure how much of this I've said before, sorry if I'm totally repeating myself.) If you made a PID based system and added a bunch of feed forward terms ... you've done almost exactly what I've done and arrived in almost exactly the same place ... just from a different direction. My goal is to generate everything from data instead of going out and tuning knobs until it feels about right. And of course at the end, you may do a lot of tuning away from some metric of "optimal" to get a better feel for pilot preference. You might want softer gains for ride comfort, or loser tracking so the system doesn't feel as mechanical, or slowly changing power output (taking whatever hit on performance you have to) to avoid a lot of annoying power hunting and throttle changes. I'm writing all of this before I look at yesterday's data ... if I get some good signal out of the noise I will be thrilled and might start coding things up sooner ... if it's just a big ball of noise then I may have to go away and think some more. :-) Hopefully a bit of this makes some sense ... I'm running down an idea, it still could prove to be a dead end ... or in order to make it work well I'll end up needing to go read up on the F-35 system and eventually get around to doing it all the "right" way ... we'll see! |
Beta Was this translation helpful? Give feedback.
-
|
Hi Curtis. Thanks for the feedback and the update. Talking of 'twitchy' flight I'm not sure if you've flown Zaretto's F-15 in FlightGear? While looking into roll performance a month or so ago I noticed the aileron control power in the model was off by an order of magnitude. So if you fly it now it should feel quite different. See - Zaretto/F-15#1
I know you want to try out your current approach in terms of mapping a pilot command like commanded roll-rate to a surface deflection via your dynamics mapping approach, so take this as a bit more F-35 spam for now 😉 So, although I mentioned that the F-35 based approach of using Dynamic Inversion was somewhat similar to your approach, they don't actually do a mapping directly from pilot command, e.g. roll rate command to surface deflection using Dynamic Inversion.
Here is an example from the roll regulator.
So once the required roll acceleration is calculated,
In the F-35 example this could be tweaked as a combination of changing the roll command gearing, i.e. lateral stick deflection to commanded roll rate and also by changing the roll time constant in the regulator |
Beta Was this translation helpful? Give feedback.
-
|
I don't want this to sound like we are talking past each other, and I don't want to get overly pedantic. But again I think everything you have said appears to be right on. I have nothing to disagree with! There is a lot here I don't know about. My background is computer science, so I struggle to wrap my brain around any information presented in the frequency domain ... I'm still trying to grok frequency domain and when I spend too much time thinking about it, my brain hertz! So that said, the F-35 is going to have powerful actuators that can move the control surfaces against extreme hinge moments at all the craziest places in the flight envelope. This means in 99.9% of the flight envelope the actuators will have far more capability than actually needed. And then this means that you could /way/ over drive the system and you probably do need to think carefully about shaping the acceleration response, you don't want to just slam the control surfaces around for fastest convergence. I am picturing RC airplanes or GA airplanes where you maybe have just barely enough actuation to meet your steady state requirements, or you have corners of the envelope that get clipped off because you don't have enough torque or rate (power) to get there and maybe you live with that because airplanes are a series of compromises that you hope come out to a net positive. So I'm coming at this from the other direction where I don't think I have enough actuation and I'll take whatever I can get (compared to the F-35 where you have an excess so you need to decide how to limit rates and then you might as well do it in a way that feels really good to the pilot.) I could very well be completely wrong on my assumptions! Maybe accel shaping is really important and I just haven't discovered that yet. This is very possible! I have some flight data now so I will try to put some plots together to show more clearly what I am thinking ... but it is real world flight data on a really crappy slow airplane, so bear in mind this is not going to look like a pristine textbook matlab plot! And we have to guess how much of the noise is due to modelling error (or not considering enough relevant terms) versus turbulence, versus this being a foam-not-very-rigid airframe. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
I asked about the amount of variation in qbar above.
Looking at A4 Skyhawk Roll Performance again I noticed that the steady state roll rate isn't proportional to qbar, it's proportional to the TAS, So I ran a roll rate comparison on the 737 model in JSBSim at 160KTAS and 320KTAS to compare the roll response.
I assumed roll coordination, without explicitly implementing roll coordinate, so I just set the 737's So doubling TAS results in ~doubling of steady state roll rate and not 4x roll rate due to qbar increasing by a factor of 4. |
Beta Was this translation helpful? Give feedback.
-
|
Curtis, I came across this LinkedIn post recently which includes a copy of the paper as well - |
Beta Was this translation helpful? Give feedback.
-
|
You've written a lot, and I want to respond to it all, but life has been busy recently, but let me try to hit a couple things quickly. For RC model test data I have not flown over a large qbar range, but for some other experiments I have. My system can't tell me what the true relationships are, but it can tell me if one term correlates better than another and so far what I've seen is that roll rate correlates best with aileron*qbar (not velocity). But that in no way means anything fundamental about physics, just that's what I have seen. For pilot feel, I'm not sure what to think. I'm certainly not an expert in what fighter pilots like to feel, and how to accomplish that. I am inclined to think that it would be nice if the aircraft performance matched the stick deflection as closely as possible without delaying or speeding that up ... but I'm sure there is much nuance here that is simply out of my range of vision because I've never attempted to develop real control laws for real high performance aircraft. My proof of concept will be with an RC plane so the pilot won't have any direct feel at all, so my use-case could send me in a different direction entirely. Fair point that big aircraft programs won't just take a wag at gains and turn the knobs until it feels about right. They will do a careful detailed model of their aircraft, and design the control laws to meet specific measurable criteria, they'll do careful filtering to avoid flutter or short period, and they'll probably have some crazy analysis tools and techniques and people with 40 years of experience doing these exact things. When you say transfer function and start using "S" terms, my eyes glaze over and my brain goes into shutdown mode, sorry! :-) Your thought about just analyzing the steady state roll cases vs. taking all data ... fair point, but I'm hoping that the variations in both directions cancel each other out mostly ... and I'm hoping for a /lot/ of help from Mr. Guassian. Roll response vs. aircraft velocity: I am hoping for a system that gives a consistent roll response for a specific stick deflection across the entire flight envelope (or as much as possible with physics and aerodynamics.) So for example, I'm hoping full stick deflection will command something like 30-40 degrees per second roll rate no matter what speed I'm flying ... until I get too slow and full deflection can't give me that rate any more. I think I noticed that same paper on linked in. I'm not very fluent in phd so I often struggle to make sense of these kinds of papaers. I was really hoping to find out more information about what sysid terms they were modeling and fitting. Maybe I got lost in the notation but I didn't see any real information there ... they were more interested in describing their higher level fitting/modeling approach and less about the terms they were modeling (from what I could glean so far ...) But from what I could see, they are in the middle of the same space that I'm nibbling on the edges of. I'm still hoping to get a real proof of concept of these ideas (built offline with past flight test data) flying sometime this fall, but life continues to be busy and full of obligations and distractions! |
Beta Was this translation helpful? Give feedback.
-
No problem, I'm also fairly busy work wise, so I also don't respond immediately, plus often don't have time to respond to everything you post. I did notice, via YouTube figuring out to highlight some of your recent videos that you've been busy with some RC flying in terms auto-land testing?
I'm in the same boat. My ideal ~35 years ago would've been to study computer science, electrical engineering, aerospace engineering and become a test pilot, but I had to choose just one so went with computer science.
Mostly "know of", as opposed to being a practicing expert in.
Yep, that's why I thought you might be interested in the paper.
I would imagine that if a large percentage of the sample points are sampled before reaching a steady state roll rate then in theory you would be underestimating the mapping from aileron deflection to roll rate. Looking at some of the data you posted above it doesn't really look like you ever really have any periods of steady state roll rates? Also if you look at equation 2 in - A4 Skyhawk Roll Performance you'll see that the roll moment due to aileron deflection is directly proportional to qbar. So if the roll damping is very small and/or you're not letting the aircraft get close to a steady state roll rate, i.e. so It would be ideal if you could get data across a wide range of speeds with steady state roll rates. |
Beta Was this translation helpful? Give feedback.
-
|
Out of interest, what sort of programming do you do at work? |
Beta Was this translation helpful? Give feedback.
-
Ah, about 10 years ago I started doing some work in this line for a startup company, Aerobotics - https://aerobotics.com/drone-scan although not really on the stitching side, more on the processing side of the drone and satellite imagery, camera processing etc. They also used Skywalker UAVs in the early days.
Sounds like interesting work. Does your current simulation work involve JSBSim by any chance? |
Beta Was this translation helpful? Give feedback.
-
I'm one of the current (since 2018) JSBSim developers with the second most commits since 2018 😉 https://github.com/JSBSim-Team/jsbsim/graphs/contributors I'm fairly prolific in terms of commenting on issues and discussions on JSBSim. Do you have some examples of issues/discussions where there was no help/attention from the JSBSim developers and rejected patches?
I'm not complaining 😉 and would be interested to see the sorts of issues that users had difficulty with. |
Beta Was this translation helpful? Give feedback.
-
|
One of my colleagues submitted a patch related to engine/prop advance and
it was rejected with a statement that this could all be done with scripting
... but if you do it through a script you can't use the trimmer to get to a
trimmed state at initialization time. My colleague felt like not only was
his patch rejected (he is an Aerospace engineering phd with Nasa and Boeing
experience and isn't just an academic hack, he knows the right ways to do
things and his stuff works) he was kinda slapped down in the process.
More recently I've pointed out that the FlightGear rascal model can't trim
in the air. I believe the issue is around the electric motor model
somehow, but I couldn't get any serious attention on the matter and ran out
of energy on my side so I gave up for now. Maybe I'll try again someday.
I also see that the python interface to JSBSim carries some uninitialized
state so that sometimes things blow up when you start, but if you can get
started and fly around, subsequent startups work just fine. This is a
tricky complicated one and I wouldn't even know where to start so I haven't
even tried saying anything.
Thanks,
Curt.
…On Sat, Aug 16, 2025 at 11:37 AM Sean McLeod ***@***.***> wrote:
can't get any help/attention from current JSBSim developers ...
I'm one of the current (since 2018) JSBSim developers with the second most
commits since 2018 😉
https://github.com/JSBSim-Team/jsbsim/graphs/contributors
I'm fairly prolific in terms of commenting on issues and discussions on
JSBSim.
https://github.com/JSBSim-Team/jsbsim/issues?q=is%3Aissue%20AND%20(commenter%3Aseanmcleod%20OR%20commenter%3Aseanmcleod70)
https://github.com/JSBSim-Team/jsbsim/discussions?discussions_q=commenter%3Aseanmcleod+is%3Adiscussion
Do you have some examples of issues/discussions where there was no
help/attention from the JSBSim developers and rejected patches?
anyway, just complaining!
I'm not complaining 😉 and would be interested to see the sorts of issues
that users had difficulty with.
—
Reply to this email directly, view it on GitHub
<#4 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACXYYDJW5Z6QTPBUDT5J72D3N5M3NAVCNFSM6AAAAACCMF3B5KVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTIMJSG4ZDMNY>
.
You are receiving this because you commented.Message ID: <NorthStarUAS/.
***@***.***>
--
Curtis Olson
|
Beta Was this translation helpful? Give feedback.
-
|
I'll take a look at the issues you mentioned. In terms of the Python issue, if you can come up with a reproducible case then log it as an issue and I'll take a look. |
Beta Was this translation helpful? Give feedback.
-
|
I found your JSBSim report about the trim issues with the Rascal. As a quick test, I removed the engine as a factor by not starting it and then trying to find a trim solution for a glide. Similar approach I took for an engine on example to generate a trim envelope for the 737, see: https://github.com/JSBSim-Team/jsbsim/blob/master/examples/python/Trim%20Envelope.ipynb So with the following quick test I wasn't able to find a trim solution for the Rascal in a glide, so I doubt the trim issue is related to the engine. Will have to take a closer look to try and figure out why it fails to trim. import jsbsim
import math
import numpy as np
AIRCRAFT_NAME="Rascal110"
# Path to JSBSim files, location of the folders "aircraft", "engines" and "systems"
PATH_TO_JSBSIM_FILES="../../jsbsim"
# Create a flight dynamics model (FDM) instance.
fdm = jsbsim.FGFDMExec(PATH_TO_JSBSIM_FILES)
# Load the aircraft model
fdm.load_model(AIRCRAFT_NAME)
# Avoid flooding the console with log messages
jsbsim.FGJSBBase().debug_lvl = 0
# Set engines running
#fdm['propulsion/set-running'] = -1
fdm.set_dt(0.001) # 1000 Hz time step
# --- Simulation Parameters ---
# These lines set the simulation parameters.
# Set alpha range for trim solutions
fdm['aero/alpha-max-rad'] = math.radians(12) # Maximum angle of attack in radians.
fdm['aero/alpha-min-rad'] = math.radians(-4.0) # Minimum angle of attack in radians.
# Set envelope limits
min_speed = 20 # Set the minimum calibrated airspeed (kts).
max_speed = 80 # Set the maximum calibrated airspeed (kts).
altitude = 100 # Set the altitude (ft).
min_gamma = -30 # Set the minimum flight path angle (deg).
max_gamma = -1 # Set the maximum flight path angle (deg).
for speed in np.linspace(min_speed, max_speed, 10):
for gamma in np.linspace(min_gamma, max_gamma, 10):
fdm['ic/vc-kts'] = speed
fdm['ic/h-sl-ft'] = altitude # altitude above sea level (ft)
fdm['ic/vc-kts'] = speed # calibrated airspeed (kts)
fdm['ic/gamma-deg'] = gamma # flight path angle (deg)
fdm.run_ic() # Run the initial conditions
try:
fdm['simulation/do_simple_trim'] = 1
print(f'Trim succeeded for speed: {speed} gamma: {gamma}')
except jsbsim.TrimFailureError:
print(f'Trim failed for speed: {speed} gamma: {gamma}')
pass |
Beta Was this translation helpful? Give feedback.










Uh oh!
There was an error while loading. Please reload this page.
-
Here goes.
I happen to be reading up on the F-35's flight control law design - The F-35 Lightning II: From Concept to Cockpit and what you're describing is pretty similar to Dynamic Inversion for control.
If you know the desired state rates,$\dot{x}_{des}$ , plus the current state $x$ , then you can solve for $u$ .
This does imply that you've computed$A$ , aircraft dynamics matrix (stability derivatives) and $B$ , control effectiveness matrix.
Which I know you mentioned you're trying to avoid, i.e. having to come up with a full detailed model of the aircraft 😉 Typically done via some combination of CFD, wind-tunnel testing, and then fine-tuned with System Identification techniques from actual flight data.
In a sense you're describing a "small scale" System Identification from flight data.
In the F-35 case they've implemented a Nonlinear Dynamic Inversion (NDI) based controller, with a very highly detailed aircraft model.
In terms of your initial roll rate example in terms of mapping a requested roll rate$p$ to an aileron deflection $\delta_a$ based on processing and sampling flight data don't you run the risk of the mapping being skewed depending on whether your flight data has enough periods of steady state roll rate $p_{ss}$ data?
For example take a look at A-4 - Skyhawk Roll Performance in terms of this graph plotting roll rate versus time and the roll rate acceleration versus the steady state roll rate.
That plot is for a fixed aileron deflection at some dynamic pressure, showing the roll rate acceleration plus the effect of roll damping in terms of then settling down to a steady state roll rate.
If in your test flight data processing a large percentage of the samples were taken for the periods before reaching the steady state roll rate then your control system is going to be too 'twitchy' and always overshoot the steady state roll rate that the pilot is trying to achieve.
How far along are you?
Cheers
Beta Was this translation helpful? Give feedback.
All reactions