C172X Autopilot altitude hold not maintaining altitude #974
Replies: 5 comments 1 reply
-
Goods news but also maybe bad news. The altitude holding does work. It's holding AGL(above ground level) but the HUD is displaying above Sea Level. If you press the "D" key, which brings up the debug display as seen in the images below, and look at the AGL, you will see it's holding. The increasing sea level altitude is because the default project uses Round planet in it's GeoReference component and when combined with default flat terrain, the further out in the terrain you go the higher above sea level you are. Imagine a dinner plate on top of a large soccer ball, and you are flying only on the dinner plate 😄 That C172ap uses AGL as part of the altitude holding math. The C310 uses seal level as path of the math. In the below images you can view the example of the C310 holding 1500ft above sea level, but eventually it crashes into the terrain because the terrain does not curve with the Round Planet. If we change to Flat planet in the GeoReference component, then everything is good for the C310 For the C172x, you can change the project HUD to display above ground level, instead of seal level, or change to Flat planet, as seen below in the pictures. Or change the terrain model to be more round so that it follows curvature of the earth and the sea level. The bad news: If changing to Flat plane in the GeoReference component , the airplane flys backwards/in reverse! If you have this issue please confirm. It's probably a simple fix but will have to be fixed later. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the reply. |
Beta Was this translation helpful? Give feedback.
-
jsbsim/aircraft/c172x/c172ap.xml Line 204 in ae4652a This section here of the file says AGL. Change the agl to sl like this: <input> -position/h-sl-ft </input> But it also seems the PID or something else is not tuned well for the c172ap. The aircraft first overshoots the altitude slowly and then comes back down very slowly over the period of many minutes or more. Only then does it hold altitude. You can watch this effect more quickly by advancing game time using UE console command "t.OverrideFPS 1" to greatly accelerate the game tick rate. Use 0 to reset the game rate. So more work will likely need to be done to balance this autopilot altitude holding. Edit: If you change these PID values, to something like those you first linked of an updated c172, then the aircraft doesn't overshoot much and very soon finds it's holding. jsbsim/aircraft/c172x/c172ap.xml Lines 297 to 301 in ae4652a These values as were shared in the file you linked seems acceptable and doesn't overshoot much. <pid name="fcs/altitude-hold-pid">
<input> fcs/ap-alt-hold-switch </input>
<kp> 0.03 </kp>
<ki> 0.001 </ki>
<kd> 0.0000 </kd> |
Beta Was this translation helpful? Give feedback.
-
Yeah, I Tried changing that and it didn't change too much. the aircraft keeps climbing indefinitely, not being able to hold altitude. I tried to adopt the C310 to the C172, but it takes more than a few tweaks and it is above my ability ATM to make the transition. |
Beta Was this translation helpful? Give feedback.
-
Yep, it does settle on the value now. I'll try fiddling with the PID values to make it more responsive, if you come up with better values by any chance, please let me know. Thanks! |
Beta Was this translation helpful? Give feedback.
-
I compiled JSBSim to unreal environment, and working with the C172X model as a base for a UAV via the c172ap XML.
Basically everything works as it should, and all the autopilot functions work as planned, besides the altitude hold function.
it does manage to keep the plane stable in the longitudinal plane, however it does not maintain the altitude setpoint, but keeps on climbing past it.
I have seen several newer implementations of the C172 autopilot, most of them based on the C310, such as:
https://github.com/Aircraft-Design-UniNa/WiReS/blob/master/JSBSim/aircraft/c172x_unina_mod/c172ap_unina_mod.xml
any idea whether it is a known issue or if there is a better AP implementation?
Beta Was this translation helpful? Give feedback.
All reactions