Jump to content

[1.12.x] Kramax Autopilot Continued: Course guidance and auto-land for spaceplanes


linuxgurugamer

Recommended Posts

This mod no longer seems to work in 1.6 or is it just my problem?I would love to see this coming back as it was a great help in flying planes long-distance. Thanks in advance.

 

Edit: Got it to work after reinstalling it via CKAN, Idk what went wrong with the manual install but its working now so nvm.

Edited by CellTechAeronautics
Works now
Link to comment
Share on other sites

It's essential for flying planes. At all.

I've about given up on KSP altogether, though. Some of my mods have updated to 1.6, most of them are still in 1.5, and a few are all the way back in 1.4. The updates come so often now that I can't keep my mods current even with CKAN. It stinks.

Link to comment
Share on other sites

  • 2 weeks later...

Hello @linuxgurugamer

It seems that the user modifiable config file, ./GameData/KramaxAutoPilot/Extras/FlightPlans.cfg, is only being loaded once - at time of initialization.

If you select "Refresh", or exit that scene and then go back,you are unable to ever see the data from the "FlightPlans.cfg" file.

This is shown in the ksp.log, and it looks like on refresh or subsequent reloads after initial that the path is 'off'.....

i have included the ksp.log, and both config files.

files for KramaxAutoPilot

Cheers, and thanks for upkeep and working on this great mod.

 

Link to comment
Share on other sites

7 minutes ago, drtedastro said:

Hello @linuxgurugamer

It seems that the user modifiable config file, ./GameData/KramaxAutoPilot/Extras/FlightPlans.cfg, is only being loaded once - at time of initialization.

If you select "Refresh", or exit that scene and then go back,you are unable to ever see the data from the "FlightPlans.cfg" file.

This is shown in the ksp.log, and it looks like on refresh or subsequent reloads after initial that the path is 'off'.....

i have included the ksp.log, and both config files.

files for KramaxAutoPilot

Cheers, and thanks for upkeep and working on this great mod.

 

Please open a github issue

Link to comment
Share on other sites

  • 2 weeks later...
On 3/1/2019 at 4:38 PM, eightiesboi said:

Is there a hotkey to quickly enable / disable the autopilot? I closed out the autopilot UI without realizing it was still running, making control, erm, difficult. :lol:

I think that a right-click on the Add'On icon on the tool bar would be a nice way to accomplish that!

Edited by Lisias
tasting my own medicine :)
Link to comment
Share on other sites

On 3/10/2019 at 12:59 PM, Aremos said:

Is there a way to make this work with rescaled kerbol system?

Running with x10.65, but the autopilot cant  find its way around.

you have to change the flight plans (DefaultFlightPlans.cfg; FlightPlans.cfg) to take in a count the diference in size.

Link to comment
Share on other sites

  • 2 months later...
1 hour ago, traisjames said:

Is there a way to soften the strength of the autopilot?

Kramax uses cascade PID control, and PID controllers need tuning to the process you want to control.
As different aircraft designs are going to respond differently to the same control inputs, you will often need to tune the PID controllers during the first test-flight - this is why Kramax has presets. I usually have a bunch of presets ranging from "twitchy stunt plane" to "lumbering freighter", and I try each of them on a new craft until I get reasonable response. For some aircraft I need to switch presets based on airspeed or altitude too.

For a start, try increasing the "scalar" variable for the control axis you are having difficulty with, it makes everything less aggressive. See "Pilot Assistant 101 - How to fight the wobble".
If that doesn't solve your problem, you'll have to twiddle with the (k) P(proportional), I(integral) and D(derivative) factors. For that you will need an understanding of the mathematics involved, and the internet will teach it better than I ever could, despite working with such controllers IRL. For overshoot (my guess at your problem without seeing it), I'd start by increasing scalar and/or decreasing Kp.

Once you have a handle on how the system (controller + process) behaves, tuning becomes fairly intuitive.

Edited by steve_v
Link to comment
Share on other sites

3 hours ago, traisjames said:

Any suggested values?

Nope. As I said, the values are specific to the airframe you are flying.

I'm going to assume you didn't watch or didn't understand that video, so against my better judgement I'll try to explain how to tune Kramax (or any other PID for that matter, such as MechJeb's attitude controller or even RL industrial systems) as best I can...

The really short (and woefully incomplete) answer to instability (guessing instability since I can't see your screen and it's a common complaint) is to reduce the proportional gain until it goes away. Less kp or more scalar (scalar is a flat divisor of all values), just whack at it until it works.
Your control will probably still be sub-optimal (slow to respond or oscillating slightly either side of the setpoint) after doing after this, but once you understand the effect of each of the three gain parameters this is fairly easy to fix...


Here goes nothing. First what's what, from memory:

Kp: The proportional parameter controls the magnitude of the response to a given error value. E.g. in pitch hold mode, the change in elevator deflection applied per cycle is proportional to the difference between our current pitch and the setpoint (the error), multiplied by Kp.
Ki: The integral parameter increases the response proportional to the both magnitude of the error and the time for which it has persisted - in this example it corrects any steady-state offset in the final pitch achieved. The longer we're not at the right pitch, the harder it pulls on the stick.
Kd: The derivative parameter doesn't use the error value directly, instead it applies a  correction based on the rate of change of the error. It's there to control oscillation - if our actual pitch is close to and moving rapidly towards the setpoint, the D factor controls how much to back off so we don't overshoot.  Think D for damping.
Scalar: Divide all of the above values by this number, useful for those "Just chill the %@#$ out, airplane" situations.

Once you grok these, observe what your aircraft is doing in order to decide what to change:
If it's oscillating and those oscillations get worse over time, your control is unstable because it's applying excessively large corrections. Reduce Kp.
If it's oscillating and the oscillations are not getting worse (or getting better slowly), try increasing Kd to damp it out faster. If the oscillations are large, Kp might still be a little bit too high as well.
If your craft isn't oscillating, but it never gets quite to the heading/altitude you set, add a dash of Ki to nudge it the rest of the way. Ki is like salt, add only as much it needs.
 

In the case of cascade control like Kramax, you will often have two PID controllers to play with per axis... Yeah, I know, bear with me.
Using vertical speed hold as an example, the "outer loop" as it is known (shown when you click the "PID" button) compares your current vertical speed to the setpoint and outputs the angle of attack required to correct it.
The "inner loop" (shown when you click the "Srf" button) takes the output of the outer loop as a setpoint and controls the elevators to try to put the craft at that angle.
The other control modes are similar: Heading and bank-angle, altitude and vertical speed, etc. The individual PID controllers are just assembled in different chains depending on the autopilot mode.

To determine which PID controller in a chain is causing your problems, open the inner loop settings and look at the "target" at the top. If the value is oscillating then it's a good bet the outer loop is the one that needs tuning, as that's where the value is coming from.
If that target value is fairly stable but the control surfaces on the aircraft are oscillating, then it's the inner loop that is the problem.

Spoiler

screenshot342.png
Yup, it's a VTOL to take to Laythe. Micro-submarine in the cargo bay. :cool:

In my experience with Kramax/Pilot Assistant, it's usually the outer loop that gives grief.


There are many PID tuning guides on the 'net if you don't like mine, or you could just bash at it randomly until you get a feel for it. It's not as arcane as it sounds, and even blind trial-and-error will get there - eventually.

Edited by steve_v
Check in-game for actual button labels
Link to comment
Share on other sites

5 hours ago, traisjames said:

how dod you make it so you can see all of those at once?

Drag the little horizontal bar below each section down until you can see everything you need. You might need to shrink or collapse other parts of the ui to get it all on the screen...
If that's actually what you're asking, I'm not completely sure.

Edited by steve_v
Link to comment
Share on other sites

  • 2 months later...
  • 3 weeks later...
  • 4 weeks later...
On 9/9/2019 at 4:28 PM, maculator said:

Sad that each and ecery mod you take overnow requires 2 additional mods.

They all require the same two mods.  This provides both a reduction in code size and complexity, both of which are good things.  In general, everytime I add the toolbar controller to a mod which supports both the stock toolbar and the Blizzy toolbar, i end up removing more than a thousand lines of code from the mod.

Link to comment
Share on other sites

Greetings!

Thanks for an awesome mod, I've been lucky enough to get an obscene amount of use out of this mod. However I've recently run into an issue with 1 particular function, while everything else behaves in an expected manor (after the K values are tweaked for the airframe). It's possible that I am overestimating the capability of the radar altitude hold function, but I will outline the exact behavior below.

Issue:

On an otherwise stable airframe where the autopilot functions have been verified working as expected, the Radar Altitude function for holding altitude doesn't work as expected. The Requested Radar Altitude value is entered, and then control is handed over to altitude hold. In this particular case, this altitude was 500 AMSL. The airframe then pitches up violently, in excess of 60 degrees relative to horizon. It then oscillates down from 60 to 10. Then between 10 and -10.

Here are two graphs outlining the behavior. First one is Actual AMSL vs requested altitude using radar alt. The second one shows the pitch and pitch input over mission time. These are clearly oscillations, however I am used to the frequency being far faster, and the magnitude being much less, I also am not able to explain the fact that it appears to be interpreting an additional 0 into the altitude entered. Also, both small and large changes to the proportional, integral, and derivative values seem to not be effecting this in the way I expect based on comparison to other oscillations that I have tweaked out on this airframe. My question here is, am I missing something? This should work.
drq5bN5.png

mXE8B4b.png

I've included the code for producing the graphs in the odd event that helps.

import matplotlib.pyplot as plt
from typing import List, Dict

flight_data: Dict[str, List[float]] = {"altitude": [390.37, 373.83, 356.87, 340.49, 324.71, 319.43, 350.7, 410.99, 492.29, 610.05, 780.25, 995.78, 1249.34, 1526.97, 1826.28, 2127.65, 2427.27, 2754.53, 3050.9, 3322.18, 3599.26, 3870.52, 4124.95, 4247.3, 4461.12, 4664.73, 4866.67, 5046.39, 5175.77, 5255.61, 5310.94, 5373.71, 5456.0, 5539.73, 5596.05, 5612.35, 5584.4, 5535.59, 5482.73, 5448.0, 5436.61, 5449.32, 5473.69, 5503.14, 5529.51, 5528.75, 5493.22, 5442.86, 5395.03, 5365.73, 5360.23, 5378.67, 5411.44, 5452.7, 5485.72, 5515.71, 5532.42, 5516.84, 5472.64, 5422.77, 5386.07, 5372.91, 5384.49, 5415.29, 5459.11, 5495.24, 5512.59, 5530.0, 5535.29, 5509.51, 5461.61, 5413.44, 5380.17, 5371.11, 5386.88, 5418.42, 5461.13, 5499.34, 5534.89, 5546.19, 5520.27, 5472.22, 5424.06, 5392.91, 5386.23, 5405.81, 5439.41, 5480.11, 5496.97, 5503.52, 5471.14, 5424.68, 5389.06, 5376.88, 5389.97, 5428.29, 5475.19, 5525.46, 5550.35, 5537.37, 5493.73, 5441.05, 5404.71, 5391.86, 5403.66, 5433.36, 5474.4, 5507.2, 5510.21, 5475.94, 5428.36, 5388.76, 5375.17, 5387.91, 5422.08, 5465.0, 5509.38, 5531.91, 5514.04, 5468.47, 5419.22, 5391.54, 5387.69, 5408.4, 5445.06, 5491.98, 5526.44, 5523.95, 5485.67, 5436.47, 5399.18, 5383.99, 5394.04, 5424.51, 5468.88, 5509.72, 5520.38, 5492.14, 5444.04, 5403.21, 5382.93, 5387.42, 5415.96, 5455.29, 5501.33, 5531.29, 5525.75, 5485.81, 5436.5, 5399.72, 5385.24, 5396.02, 5417.38, 5458.16, 5501.59, 5524.37, 5510.22, 5466.1, 5418.85, 5388.47, 5382.49, 5401.57], "pitch": [-2.583759307861328, -2.503394842147827, -2.3421623706817627, -2.4411652088165283, -1.015120029449463, 7.699493408203125, 12.963165283203125, 13.773712158203125, 22.3621826171875, 34.09893798828125, 44.070709228515625, 53.8515625, 63.51708984375, 65.84762573242188, 60.228240966796875, 61.836181640625, 63.80584716796875, 55.9283447265625, 46.21923828125, 52.023895263671875, 49.935546875, 39.264801025390625, 27.8931884765625, 30.174041748046875, 38.919219970703125, 35.028167724609375, 24.36859130859375, 13.81329345703125, 3.53204345703125, 4.005157470703125, 13.062591552734375, 21.236846923828125, 16.179229736328125, 5.4559326171875, -4.937421798706055, -14.686358451843262, -10.175664901733398, -7.622991561889648, -0.09931441396474838, 6.24951171875, 10.21044921875, 8.6871337890625, 6.997406005859375, 6.329833984375, -3.893538236618042, -13.655208587646484, -9.0669527053833, -6.309922218322754, 1.313568115234375, 7.05059814453125, 11.253387451171875, 8.704620361328125, 12.69744873046875, 3.5517578125, 7.048614501953125, 2.287078857421875, -7.844022274017334, -12.246378898620605, -8.104050636291504, -1.1646206378936768, 5.8009033203125, 9.934906005859375, 12.543304443359375, 11.48272705078125, 6.88848876953125, -0.4590585231781006, 5.617401123046875, 0.922943115234375, -9.31019115447998, -11.014798164367676, -7.688395023345947, 0.0633544921875, 6.51397705078125, 10.682342529296875, 8.989532470703125, 12.758270263671875, 3.986541748046875, 8.464385986328125, -0.8549870252609253, -11.399503707885742, -10.716222763061523, -7.141841411590576, 0.778594970703125, 6.85980224609375, 11.225860595703125, 9.172027587890625, 12.115966796875, 2.582489013671875, -2.912907838821411, -13.636370658874512, -9.268720626831055, -1.2895700931549072, 5.9215087890625, 10.141876220703125, 14.5074462890625, 8.0888671875, 10.658294677734375, 1.641845703125, -9.026542663574219, -12.602285385131836, -8.076216697692871, -1.0343533754348755, 5.8543701171875, 10.017547607421875, 11.601776123046875, 10.478240966796875, 6.43865966796875, -3.9757165908813477, -13.93315315246582, -9.058341026306152, -1.778041958808899, 5.831817626953125, 10.149810791015625, 14.25115966796875, 9.01300048828125, 10.1058349609375, 0.716949462890625, -9.9419527053833, -12.082487106323242, -6.555356502532959, 1.6611328125, 7.2469482421875, 11.4212646484375, 10.739898681640625, 11.4210205078125, 5.0433349609375, -5.745434284210205, -13.855917930603027, -8.55447769165039, -1.8724453449249268, 5.28717041015625, 9.59869384765625, 13.725799560546875, 10.020050048828125, 8.401153564453125, -2.1332364082336426, -12.567564010620117, -10.058292388916016, -3.659806966781616, 3.958099365234375, 8.652496337890625, 12.789398193359375, 9.14178466796875, 12.7357177734375, 3.991180419921875, -6.791440010070801, -13.430326461791992, -8.23849868774414, -1.6071306467056274, 5.42755126953125, 9.703582763671875, 13.758575439453125, 8.420867919921875, 10.975372314453125, 1.83953857421875, -8.754253387451172, -12.383949279785156, -7.6278581619262695, 0.800567626953125, 6.910308837890625, 11.0054931640625, 11.644683837890625], "pitch_input": [0.17787615954875946, 0.1223529800772667, 0.13236893713474274, 0.16981135308742523, 0.354541152715683, 0.7611978650093079, -0.3872259855270386, 0.00716315908357501, 0.8509212136268616, 1.0, 1.0, 1.0, 1.0, 0.29780295491218567, 0.007332563400268555, 0.17037580907344818, 0.20265483856201172, -0.3875111937522888, -0.661490261554718, 0.370773583650589, -0.17429150640964508, -0.6180631518363953, -0.2758972942829132, -0.16913367807865143, 0.5689898133277893, -0.18809732794761658, -0.5885653495788574, -0.8432124853134155, -0.92157381772995, -0.1691918820142746, 0.5779373049736023, 1.0, 0.15416720509529114, -0.46242770552635193, -0.8070858120918274, -0.6553367376327515, 0.03652910143136978, 0.6507585644721985, 0.8153135776519775, 1.0, 1.0, 0.19425097107887268, 0.5373457670211792, -0.04399773105978966, -0.45965009927749634, -0.42998242378234863, 0.18812893331050873, 0.24788369238376617, 0.8904986381530762, 1.0, 1.0, 0.964272677898407, 0.537842333316803, -0.18773643672466278, 0.4533553123474121, -0.18544481694698334, -0.6362828612327576, -0.18572202324867249, 0.27368173003196716, 0.7728931307792664, 1.0, 1.0, 0.805422842502594, 0.7678675651550293, 0.005136121064424515, -0.41828012466430664, 0.4772469699382782, -0.19318465888500214, -0.62053382396698, -0.1392044574022293, 0.3640243113040924, 0.8204629421234131, 1.0, 1.0, 0.9604514241218567, 0.6671255230903625, -0.04946555942296982, 0.44695237278938293, -0.3640337586402893, -0.7466857433319092, -0.09077753126621246, 0.22098864614963531, 0.8483641743659973, 1.0, 1.0, 0.18553921580314636, 0.5244823694229126, -0.2698501646518707, -0.5008251667022705, -0.48097729682922363, 0.0894329696893692, 0.7792697548866272, 1.0, 1.0, 1.0, 0.21120797097682953, 0.34984302520751953, -0.35359466075897217, -0.7525511384010315, -0.18461228907108307, 0.28848037123680115, 0.7757835388183594, 1.0, 1.0, 0.7926142811775208, 0.7304849028587341, 0.044087622314691544, -0.5181852579116821, -0.45385509729385376, 0.15913446247577667, 0.7318512797355652, 1.0, 1.0, 0.3547183871269226, 0.06823227554559708, 0.19902010262012482, -0.377861350774765, -0.7729614973068237, -0.06202376261353493, 0.1853419691324234, 0.9026492834091187, 1.0, 1.0, 0.28085023164749146, 0.5679713487625122, -0.19283457100391388, -0.643494188785553, -0.5719586610794067, 0.10744225978851318, 0.6814461946487427, 1.0, 1.0, 0.38535821437835693, 0.3427319824695587, 0.0008999269921332598, -0.4797249436378479, -0.7276068329811096, -0.04080676659941673, 0.6247774958610535, 0.9780075550079346, 1.0, 1.0, 0.2002120316028595, 0.05516251176595688, -0.22303666174411774, -0.652823269367218, -0.543681263923645, 0.03396162390708923, 0.6972270607948303, 1.0, 1.0, 0.43890300393104553, 0.9810880422592163, 0.5821564197540283, -0.3303062617778778, -0.7158969044685364, -0.13788296282291412, 0.45664292573928833, 0.8652099967002869, 1.0, 1.0, 0.608807384967804]}

f1 = plt.figure()
f2 = plt.figure()

ax1 = f1.add_subplot(111)
ax1.plot(flight_data['altitude'], label="Actual AMSL")
ax1.plot([500 for i in range(len(flight_data['altitude']))], label="Requested rAMSL")
ax1.set_title("Altitude During Flight")
ax1.set_ylabel("AMSL")
ax1.set_xlabel("Mission Time Seconds")
ax1.legend()
ax2 = f2.add_subplot(111)
ax2.plot(flight_data['pitch'], label="Pitch degrees")
ax2.plot(flight_data['pitch_input'], label="Pitch input" )
ax2.set_title("Pitch During Flight")
ax2.set_ylabel("Input Pitch (DEG)")
ax2.set_xlabel("Mission Time Seconds")
ax2.legend()
plt.show()

 

Link to comment
Share on other sites

Okay, well I've already read the entire thread. Dug into the post, and the mathworks video that was linked, and the philosophy behind cascade control. Even checked github to see if any siimilar issues have been raised. Alas, I am unable find a reason that describes the magnitude of the offset for the values. I'll dig into the code surrounding the radar altimeter values being fed into the PID controller and see if there's something weird with input values, since we know the controller code works.

Thanks for taking a look.

Edited by GraphTheData
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...