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.
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()