-
Hello all! I've been using JSBSim on a project to study C172 flight trajectories as a result of varying initial conditions. At this stage of the project, batch runs are becoming an increasingly important aspect. However, I'm having trouble properly configuring JSBSim properties between adjacent trials. I've tried a few different approaches so far (which halfway work) but I'd like to do it correctly. Current ApproachJSBSim has many variables, but two subcategories are "initial variables" and "current" variables. As an example, here are two variables for true airspeed that correspond to the different categories. ic/vt-kts // represents the initial value of the airspeed, in knots
velocities/vt-fps // represents the "current" value of the airspeed, in feet per second To move copy the initial conditions into JSBSim, my understanding is that you need something like this. FDM.SetPropertyValue("ic/vt-kts", 90.0); // sets the initial value of the airspeed to 90 knots
FDM->ResetToInitialConditions(0x0); // run the initial conditions. This calls FDM->RunIC()
FDM.Run(); // run one time step of the flight dynamics model
FDM.GetPropertyValue("velocities/vt-fps"); // returns the "current" value of the airspeed, in feet per second. This should be approximately 90 knots = 151.903 feet per second Assuming that all initial conditions were properly copied, my understanding is that one time step should produce approximately the same value. These two returned values should be close. Because of this, all initial conditions variables are essentially buffers to the "current" or "real" variables. To ensure that these values are being properly copied from the "buffer" initial conditions variables First ApproachMy first approach is to use the FDM.SetPropertyValue("ic/vt-kts", 90.0); // sets the initial value of the airspeed to 90 knots
FDM->ResetToInitialConditions(0x0);
// or
FDM->RunIC(); Second ApproachThe second approach is to obtain the std::shared_ptr<JSBSim::FGInitialCondition> fgic = FDM->GetIC();
fgic->SetVtrueKtsIC(90.0);
FDM->ResetToInitialConditions(0x0); I understand that the It's also important to keep in mind that I'm wanting to send a complete state, not just true airspeed. I've isolated my variables down to the following. LATITUDE_DEG
LONGITUDE_DEG
ALTITUDE_FT
KTAS
ROLL_DEG
YAW_DEG
GAMMA
WIND_DIRECTION_DEG
WIND_SPEED_FPS
DENSITY_ALTITUDE_FT
WEIGHT_CONFIGURATION Current ResultsMy current results allows for a few (perhaps three) healthy configurations of an aircraft state. After this, my "integrity test" finds massive discrepancies between variables. For example, it finds that true airspeed will be 30 knots lower from its requested value, which can stall the airplane. Additional NotesWithout diving incredibly deep into any code, I've identified coupling between different Punchline Questions
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
Are you sure you're not confusing/mixing up TAS and IAS? |
Beta Was this translation helpful? Give feedback.
-
In terms of airspeed you're sure you're not mixing up TAS and CAS (same as IAS just without instrument, position errors)? I haven't seen it documented explicitly anywhere that I'm aware of, other than in the source code, typically the comment for each method, e.g. jsbsim/src/initialization/FGInitialCondition.cpp Lines 748 to 752 in 6c1abbe jsbsim/src/initialization/FGInitialCondition.cpp Lines 620 to 624 in 6c1abbe |
Beta Was this translation helpful? Give feedback.
-
For this particular batch simulation, here's the psuedo code for what I'm doing. Varying winds out of the north.
Here's the output. North wind magnitudes vary from 0 to 45 knots. Left Maneuver for a C172. Local easting and northing coordinates. You can observe
There's probably something in |
Beta Was this translation helpful? Give feedback.
-
But excluding the 45kt wind case, isn't that what your plotted trajectories are showing? So in the 40kt wind case after the aircraft has travelled 200m to the left it has only travelled ~330m north, but the 0/5kt wind case it has travelled ~390m north. |
Beta Was this translation helpful? Give feedback.
-
Configuring JSBSim for Batch SimulationsHello all. After much struggle, I am updating this thread because I've discovered a method to do repeatable, reproducible batch simulations in JSBSim. It's actually quite an elegant solution; not too complex. Here are the results of twenty simulations. Ten were identical (blue), the ten others had random winds (red). You can see IDENTICAL an trajectory in blue, and varied trajectories from random winds. High levelHere's the basic idea how you can achieve this.
My python looks something like this. # get ENTIRE IC state from JSBSim
ic_state_map = jsb.get_initial_conditions()
# ic_state_map looks like this
{
'ic/alpha-deg': 5.0,
'ic/alpha-rad': 0.08726646259971647,
'ic/beta-deg': 0.0,
'ic/beta-rad': 0.0,
'ic/gamma-deg': 7.951386703658792e-16,
'ic/gamma-rad': 1.3877787807814457e-17,
'ic/h-agl-ft': 4999.975370524856,
'ic/h-sl-ft': 5000.0,
'ic/lat-gc-deg': 34.5,
'ic/lat-gc-rad': 0.6021385919380436,
'ic/long-gc-deg': -118.00000000000001,
'ic/long-gc-rad': -2.059488517353309,
'ic/mach': 0.13845916898601293,
'ic/p-rad_sec': 0.0,
'ic/phi-deg': 0.0,
'ic/phi-rad': 0.0,
'ic/psi-true-deg': 0.0,
'ic/psi-true-rad': 0.0,
'ic/q-rad_sec': 0.0,
'ic/r-rad_sec': 0.0,
'ic/roc-fpm': 1.2648451968694188e-13,
'ic/roc-fps': 2.108075328115698e-15,
'ic/sea-level-radius-ft': 0.0,
'ic/terrain-altitude-ft': 0.0,
'ic/theta-deg': 5.000000000000001,
'ic/theta-rad': 0.08726646259971649,
'ic/u-fps': 151.32480004229163,
'ic/v-fps': 0.0,
'ic/w-fps': 13.239204514027781,
'ic/vc-kts': 83.57850748221145,
'ic/vd-fps': -0.0,
'ic/ve-fps': 0.0,
'ic/ve-kts': 83.5450463327801,
'ic/vg-fps': 151.90283619473269,
'ic/vg-kts': 89.99996219641588,
'ic/vn-fps': 151.90283619473269,
'ic/vt-fps': 151.90283619473269,
'ic/vt-kts': 89.99996219641588,
'ic/vw-bx-fps': 0.0,
'ic/vw-by-fps': 0.0,
'ic/vw-bz-fps': 0.0,
'ic/vw-dir-deg': 0.0,
'ic/vw-down-fps': -2.108075328115698e-15,
'ic/vw-east-fps': 0.0,
'ic/vw-mag-fps': 5.684341886080802e-14,
'ic/vw-north-fps': 5.684341886080802e-14
} Now, you can do this to reset JSBSim for a batch trial. for i in range(num_trials):
# reset all initial conditions to how they were at `t=0`
jsb.set_initial_conditions(ic_state_map)
# modify any parameters you want here (optional)
jsb.set_property_value("ic/phi-deg", 0)
jsb.set_property_value("ic/theta-deg", -5)
jsb.set_property_value("ic/psi-true-deg", 0)
jsb.set_property_value("ic/u-fps", 150)
jsb.set_property_value("ic/v-fps", 0)
jsb.set_property_value("ic/w-fps", 0)
# set the simulation to the initial conditions that you have just specified
# This method calls FDM->ResetToInitialConditions(0x0), which initializes all models from scratch and calls RunIC()
jsb.reset_to_initial_conditions() I should also mention that I did not use JSBSim Python for any of this. Long story, so I won't go into details. That being said, they methods names may not match exactly. I'm just presenting the basic idea for everyone here. |
Beta Was this translation helpful? Give feedback.
Configuring JSBSim for Batch Simulations
Hello all. After much struggle, I am updating this thread because I've discovered a method to do repeatable, reproducible batch simulations in JSBSim. It's actually quite an elegant solution; not too complex.
Here are the results of twenty simulations. Ten were identical (blue), the ten others had random winds (red). You can see IDENTICAL an trajectory in blue, and varied trajectories from random winds.
High level
Here's the basic idea how you can achieve this.
t=0
timestep of your simulation. This is what JSBSim will be reset to every time you begin a …