From: Adam D. <ade...@ex...> - 2020-09-25 18:18:33
|
I’m running JSBSim, using the python API, and it is working. But, I would like to be able to reset to prior conditions without rerunning the trim each time. So, what I would like to do is to run trim once, then store the relevant variables. Then, later just reload them, instead of running trim again. That would also allow me to continue running a simulation that had been run before. It is almost working, but I am not getting everything to work. For example when I’m using the c172x and if I run reset01.xml then run do simple trim and run the sim, it holds altitude very well (as expected). While if I then reset and set the variables, the aircraft starts to descend. I think that I am just missing some pitch or engine related variable, or not setting it correctly. Here are some specifics: #reset and run trim: fdm.reset_to_initial_conditions(True) fdm['simulation/do_simple_trim'] = 1 #Store the variables I will need later: alpha=fdm['aero/alpha-deg'] roll=fdm['attitude/phi-deg'] trim=fdm['fcs/pitch-trim-cmd-norm'] throttle=fdm['fcs/throttle-pos-norm'] ailerons=fdm['fcs/aileron-cmd-norm'] rudder=fdm['fcs/rudder-pos-norm'] elev=fdm['fcs/elevator-pos-deg'] #do some running: t = fdm['simulation/sim-time-sec'] while t<60.: result=fdm.run() t = fdm['simulation/sim-time-sec'] Then, do this, and I hope to get identical results to above #Load a few initial conditions fdm['ic/alpha-deg']=alpha fdm['ic/phi-deg']=roll #reset to apply those fdm.reset_to_initial_conditions(True) fdm['fcs/pitch-trim-cmd-norm']=trim fdm['fcs/throttle-cmd-norm']=throttle fdm['fcs/aileron-cmd-norm']=ailerons fdm['fcs/rudder-pos-norm']=rudder fdm['propulsion/set-running']=-1 t = fdm['simulation/sim-time-sec'] while t<60.: result=fdm.run() t = fdm['simulation/sim-time-sec'] But, I’m getting different results. As I said, I think that I must have missed some variable, or not set it correctly (command versus position?) So, I guess the overall question is what variables does do_simple_trim actually set? And, can I just store and reload those, to repeat or continue a simulation? Any guidance about what might be missing from the above? Thanks, -- Adam |