Replies: 10 comments 7 replies
-
@vranki I have a C++ based simulator I developed using JSBSim for test pilot training, acting as a VSS simulator. So, in current_seconds = getcurrentseconds(); // Seconds since 1 Jan 1970
actual_elapsed_time = current_seconds - initial_seconds; // Real world elapsed seconds since start
sim_lag_time = actual_elapsed_time - FDMExec->GetSimTime(); // How far behind sim-time is from actual
// elapsed time.
// Copy control inputs in
copy_to_JSBSim();
for (int i=0; i<(int)(sim_lag_time/frame_duration); i++) { // catch up sim time to actual elapsed time.
result = FDMExec->Run();
cycle_duration = getcurrentseconds() - current_seconds; // Calculate cycle duration
current_seconds = getcurrentseconds(); // Get new current_seconds
if (FDMExec->Holding()) break;
}
// Copy JSBSim model data out
copy_from_JSBSim();
if (play_nice) sim_nsleep(sleep_nseconds); I added the following code to void copy_to_JSBSim()
{
.......
// DirectInput inputs
g_Joystick.Poll();
if (g_Joystick.JoystickPresent())
{
FCS->SetDeCmd(g_Joystick.Pitch);
FCS->SetDaCmd(g_Joystick.Roll);
}
FCS->SetDrCmd(DeadBand(g_Joystick.Rudder, 0.02));
FCS->SetLBrake(g_Joystick.LeftBrake);
FCS->SetRBrake(g_Joystick.RightBrake);
// Stirling Inceptor inputs
g_StirlingJoystick.Poll();
.........
} |
Beta Was this translation helpful? Give feedback.
-
Set a breakpoint in |
Beta Was this translation helpful? Give feedback.
-
You didn't mention how exactly you're determining this. Are you logging some properties, or are you flying the model connected to an external view and/or instruments and it doesn't appear to respond to joystick inputs. You mentioned the throttle working. Are you possibly in trim mode all the time? The range is typically For example look at my recent comment on another discussion today. So at the end of the day what counts is the property used by the FDM developer for the functions that calculate moments and forces. They typically, but again no-one forces them to use an angular deflection, typically because that's how most aeronautical data is provided. And so again typically within the FCS section there will be sections that convert a normalised But given the convention I'm sure 99.99% of FDM models work on the assumption of a command range of |
Beta Was this translation helpful? Give feedback.
-
One option to try is to use Also confirm that the initial conditions make sense and that they are being loaded and set. |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm still struggling with this. But there is some progress: I created a practically identical example app with just main() function with the same code I've been using. To my surprise that worked as expected and the controls move. My original program that uses JSBSim is built as a Qt plugin. Could this cause JSBSim not to work as expected? It's using -std=gnu++11 -D_REENTRANT and -shared flags among others to build. This is getting above my understanding of c++ internals so I might be wrong. I could try porting my app to be a standalone process instead of plugin to see if that would help. Anyway it's really weird behavior. |
Beta Was this translation helpful? Give feedback.
-
@vranki One typical example is for retracting gears where the landing gear only has two command positions "UP" and "DOWN" ( <kinematic name="Gear Control">
<input>gear/gear-cmd-norm</input>
<traverse>
<setting>
<position>0</position>
<time>0</time>
</setting>
<setting>
<position>1</position>
<time>5</time>
</setting>
</traverse>
<output>gear/gear-pos-norm</output>
</kinematic> It is the XML model that sets the laws that drive the |
Beta Was this translation helpful? Give feedback.
-
During the christmas vacations i found a solution but not the cause for the issue. The issue is triggered when the process creates a QCoreApplication in main(). QCoreApplication sets the process locale according to system settings. See full documentation at https://doc.qt.io/qt-6/qcoreapplication.html#locale-settings As suggested, calling setlocale(LC_NUMERIC,"C") fixes the symptoms. I'm not sure exactly what is the cause. Does jsbsim use some functions that depend on locale when reading or converting some data? Maybe when reading files it uses locale-aware functions which fail to parse strings? In my system LC_NUMERIC is fi_FI.UTF-8 and for example locale-aware decimal separator is , instead of . |
Beta Was this translation helpful? Give feedback.
-
Hmm, I've run into locale specific issues with other software I've developed in the past, and in particular to do with data persistence and the different decimal separators when floating point values are persisted as strings. I'm guessing the control input issue you were seeing then was really the tip of the iceberg potentially given all the floating point values that are read in from the FDM, unless the JSBSim routines for reading them ignores the locale setting, although there must be at least some code which makes use of the defined locale which was causing your issue. Having a quick glance at https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale?view=msvc-170
|
Beta Was this translation helpful? Give feedback.
-
@vranki |
Beta Was this translation helpful? Give feedback.
-
FYI I have opened the issue #795 as JSBSim should at the very least report an error when the decimal separator in the flight model data does not match the locale. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm trying to use JSBSim in my own simulator application written in c++.
The problem is that control inputs (stick & rudder) are ignored. I am setting fcs/*-cmd-norm values but it looks like the controls always stay centered. Throttle (fcs/throttle-cmd-norm) works as expected though.
My code finds the property nodes for the values and uses setDoubleValue() to set the normalized value. I'm setting the values on each loop before FGFDMExec.Run() is called (not sure if it's necessary).
I am testing with f16 model, but the controls stay centered with any other models I've tried.
Any ideas how to debug this? I'm using latest release 1.1.12 on Ubuntu 20.04.
Beta Was this translation helpful? Give feedback.
All reactions