Property explanations #403
Replies: 31 comments 17 replies
-
I'm not aware of any comprehensive documentation of every property along the lines of XPlane's DREFs. There are some classes that like jsbsim/src/initialization/FGInitialCondition.h Lines 171 to 181 in 518f2a7 These will then also appear in the generated DOxygen documentation that gets generated automatically, see - https://jsbsim-team.github.io/jsbsim/classJSBSim_1_1FGInitialCondition.html for example. However this documentation will be scattered across the various classes, so you would need to perform a search on the property's name to find it. Which is what I typically do, i.e. search through the source code for the property name. Which may turn up a hit in some documentation in a header file like the example above, or it may only turn up a hit for the actual source code setup of the property like the following example jsbsim/src/models/atmosphere/FGWinds.cpp Lines 496 to 497 in eccfd64
What I'd suggest you do is get at least somewhat familiar with a couple of basic concepts, e.g. https://jsbsim-team.github.io/jsbsim-reference-manual/mypages/user-manual-frames-of-reference/ https://jsbsim-team.github.io/jsbsim-reference-manual/mypages/user-manual-units/ Attitude angles - Also the 'original' JSBSim manual - http://jsbsim.sourceforge.net/JSBSimReferenceManual.pdf Given that knowledge you can use it to 'decode' a lot of the properties without or before you actually search the source code to double-check, e.g.
|
Beta Was this translation helpful? Give feedback.
-
@JDatPNW out of interest are you looking into using JSBSim with your QPlane? In terms of reinforcement learning and the use of JSBSim I've come across a couple of examples. A DARPA program recently which had 8 teams designing AI agents to perform dog fights against each other with the winning team then fighting against a human pilot. They used JSBSim and the F-16 model in particular. And a Q&A session with the winning team - https://www.youtube.com/watch?v=uxxkG4uKThY with a number of questions regarding their reinforcement learning model for their agent. In terms of RL being used in conjunction with JSBSim here is another example: https://github.com/Gor-Ren/gym-jsbsim Created as part of Gordon Rennie’s MSc. https://drive.google.com/file/d/1jPLG-OYcPiffh4ZAWW1N1__4l68jh-G_/view |
Beta Was this translation helpful? Give feedback.
-
Hi @seanmcleod, |
Beta Was this translation helpful? Give feedback.
-
Alright! |
Beta Was this translation helpful? Give feedback.
-
Where? |
Beta Was this translation helpful? Give feedback.
-
I have pushed it to my QPlane repo. It is located here - Sorry I should have made that clear. |
Beta Was this translation helpful? Give feedback.
-
Hi @seanmcleod I have been working quite a lot on this project this week, and it is working out quite well for the most part.
I am trying to get to a point where the XPlane and the JSBSim environments are "identical" and interchangeable (which is why some of these properties are used over others, because XPlane might not have the perfect fit in some cases, e.g. why I am setting local velocities in the ic, because from what I could find, XPlane onlt allows for local velocities to be set). I know the physics are not perfectly identical, but I want to try to at least manage to make all inputs and outputs identical (in the sense that they show the same properties in the same units and or range) and then see if I can train a RL agent that can generalize between the two. Thanks a lot for helping me with this! |
Beta Was this translation helpful? Give feedback.
-
In terms of What do you mean by "acceleration on the local frame"? Does local refer to the aircraft's body axes, or do you mean a local NED frame? In terms of control inputs I'd suggest that your code sets the For more complex aircraft with an FCS, e.g. an F-16 the pilot's command will be an input into the FCS which will have some command law, e.g. g-command such that the pilot's command is mapped to a specific g-command and the FCS via control logic, feedback loops etc. will drive the control positions to achieve the particular command. When I made contact with one of the developers of the winning alpha-dog trials I asked what their RL controlled and he said they basically controlled the |
Beta Was this translation helpful? Give feedback.
-
Hi! Thanks for the fast response! :) self.fdm.set_property_value("ic/lat-gc-deg", 35.126) # Latitude initial condition in degrees
self.fdm.set_property_value("ic/long-gc-deg", 126.809) # Longitude initial condition in degrees
self.fdm.set_property_value("ic/h-sl-ft", 6000) # Height above sea level initial condition in feet
self.fdm.set_property_value("ic/theta-deg", -25) # Pitch angle initial condition in degrees
self.fdm.set_property_value("ic/phi-deg", -45) # Roll angle initial condition in degrees
self.fdm.set_property_value("ic/psi-true-deg", 0) # Heading angle initial condition in degrees
self.fdm.set_property_value("ic/ve-fps", 0 * self.msToFs) # Local frame y-axis (east) velocity initial condition in feet/second
self.fdm.set_property_value("ic/vd-fps", 25 * self.msToFs) # Local frame z-axis (down) velocity initial condition in feet/second
self.fdm.set_property_value("ic/vn-fps", -55 * self.msToFs) # Local frame x-axis (north) velocity initial condition in feet/second
self.fdm.set_property_value("propulsion/refuel", True) # refules the plane?
self.fdm.set_property_value("propulsion/active_engine", True) # starts the engine?
self.fdm.set_property_value("propulsion/set-running", 0) # starts the engine? This causes it to loop. As I am writing this I noticed that I set |
Beta Was this translation helpful? Give feedback.
-
Ok, I have found a few mistakes that I made (to the best of my knowledge, where axis were inverted between XPlane and JSBSim) |
Beta Was this translation helpful? Give feedback.
-
@JDatPNW the initial values you are issuing for the pitch (-25 deg) and roll angles (-45 deg) really seem huge - whatever their signs are. These are initializing the aircraft nose down (25 degrees below the horizon) with a bank of 45 deg to the left. Are you sure you want your aircraft initialized in that position ? In parallel you are setting velocities in the NED frame but the sign of the north component of the velocity seems wrong: the aircraft is heading north ( Also it seems that you have computed the north and down velocities from trigonometry but you could save yourself the trouble of these computations by setting the velocity in the body frame : setting The 3 components of acceleration in the body frame can be read from the properties As a final note, rather than calling the methods vn = self['ic/vn-fps'] # instead of fdm.get_property_value('ic/vn-fps') Properties can be written with self['ic/vn-fps'] = 55. # instead of fdm.set_property_value('ic/vn-fps') |
Beta Was this translation helpful? Give feedback.
-
Yes, I was going to say it looked like you possibly had the aircraft flying backwards with it pointed northwards but What range of starting configurations are you looking to use for your RL? In particular will the aircraft always start out in a non-stalled condition? If so you need to make sure that the velocities and attitude you start with don't result in the AoA being greater than the critical/stall angle of attack. Also starting with a large AoS (Angle of Sideslip) will also start things off with large forces that have to be corrected if the control positions are all left in their neutral position. If you do want to include starting conditions that have the aircraft stalled from which the RL agent is expected to recover then you need to make sure that the JSBSim model you're using has valid data past the stall angle, the vast majority of existing JSBSim models don't. Nx, Ny, Nz are the accelerations in the aircraft's body axes, e.g. think of a set of accelerometers being strapped to the aircraft measuring the accelerations. Given Nx, Ny, Nz and the aircraft's attitude you could transform them to a local NED frame of reference. I don't see JSBSim exposing local NED accelerations. PropertyManager->Tie("accelerations/udot-ft_sec2", this, eU, (PMF)&FGAccelerations::GetUVWdot);
PropertyManager->Tie("accelerations/vdot-ft_sec2", this, eV, (PMF)&FGAccelerations::GetUVWdot);
PropertyManager->Tie("accelerations/wdot-ft_sec2", this, eW, (PMF)&FGAccelerations::GetUVWdot);
/** Retrieves a body frame acceleration component.
Retrieves a body frame acceleration component. The acceleration returned
is extracted from the vUVWdot vector (an FGColumnVector3). The vector for
the acceleration in Body frame is organized (Ax, Ay, Az). The vector is
1-based. In other words, GetUVWdot(1) returns Ax. Various convenience
enumerators are defined in FGJSBBase. The relevant enumerators for the
acceleration returned by this call are, eX=1, eY=2, eZ=3.
units ft/sec^2
@param idx the index of the acceleration component desired (1-based).
@return The body frame acceleration component.
*/
double GetUVWdot(int idx) const { return vUVWdot(idx); }
PropertyManager->Tie("accelerations/Nx", this, &FGAuxiliary::GetNx);
PropertyManager->Tie("accelerations/Ny", this, &FGAuxiliary::GetNy);
PropertyManager->Tie("accelerations/Nz", this, &FGAuxiliary::GetNz);
/** The longitudinal acceleration in g's of the aircraft center of gravity. */
double GetNx (void) const { return Nx; }
/** The lateral acceleration in g's of the aircraft center of gravity. */
double GetNy (void) const { return Ny; }
/** The vertical acceleration in g's of the aircraft center of gravity. */
double GetNz (void) const { return Nz; } |
Beta Was this translation helpful? Give feedback.
-
@JDatPNW what is the aim of the RL agent? Glancing at your current reward function it seems maximum reward is set when the pitch and roll angles are close to 0? So is the idea for the agent to be able to take an aircraft in any starting attitude and have the aircraft get to 0 pitch and roll? |
Beta Was this translation helpful? Give feedback.
-
Hi @seanmcleod and @bcoconni. As for the -50 starting velocity. That was my fault, and I only noticed it when I typed it up yesterday. XPlane seems to be South oriented (S = + / N = -), and since I was writing the JSBSim Code on the XPlane base, a few of these mistakes slipped their way into my code. I found a few yesterday and corrected them, which means the plane is no longer looping at the beginning. The reason why I am using I tried calculating my own local NED accelerations, since I have all values I need for them. I think (hope) that should work, if I did not make any mistakes. On the topic of stalls. From what I understand a stall occurs if the AoA exceeds the critical value. (So for example if the plane is at a pitch of 90 degrees pointing up, as an extreme example, right?) I do not necessarily need/want any stall angles, but I can also not say that they will not occur throughout training, since the agent performs random actions for a long time and might enter them somewhat regularly at times. When you say most models don't have valid data past the stall point, does that mean that I will not behave physically accurate once it has exceeded the critical angles? (Currently I am using the c172r) Lastly, yes! I am trying to train the agent to stabilize at 0°, 0° - for roll and pitch respectively. And if I manage to do so, potentially expand that to the agent stabilizing at any given pitch and roll values. Thanks for helping me out with all this! I really appreciate it :) I am trying my best to incorporate JSBSim and to make it interchangeable with XPlane, but my limited knowledge in terms of aviation sometimes makes things a bit more confusing to me than they probably are. And with XPlane and JSBSim having a lot of axis inverted and using different measurement units, I ended up making a good amount of mistakes in the beginning. I hope I have gotten rid of most of them, and I will try to crosscheck them one more time today. Is there any good ways of going about that? I am just booting up both sims, and then going through the properties at flight time (while paused) and write down which axis is pointing which way) |
Beta Was this translation helpful? Give feedback.
-
@JDatPNW reading through the Markov-Pilot thesis you referenced I saw the following comment about using XPlane and JSBSim for RL.
In terms of your question:
Correct. Although I would imagine that typically exceeding the critical angle of attack would be a reason to quit the RL episode? Unless you're specifically designing an agent to recover from a stall.
A pitch angle of 90 degrees by itself doesn't mean the AoA is greater than the critical angle, the AoA is the angle between the pitch angle and the velocity vector. So it can be exceeded at any pitch angle, and the AoA can be smaller than the critical angle at any pitch angle, e.g. aircraft performing a loop pitch up and past 90 degrees without stalling. |
Beta Was this translation helpful? Give feedback.
-
@JDatPNW I've migrated the issue you opened to a discussion. The github issues are reserved for reporting bugs or new feature requests. |
Beta Was this translation helpful? Give feedback.
-
In terms of the state space I'd been meaning to ask, have you chosen the local NED states in terms of velocity and acceleration deliberately, or more as a side-effect of what you could find available for XPlane at the time? If part of the exercise is to have your agent work on using representative sensor data that it would have access to in an aircraft like a C-172 etc. then the local NED frame of reference probably isn't a good choice. The typical ADAHRS (Air Data Attitude And Heading Reference System) will have absolute and differential pressure transducers to output pressure altitude and IAS (Indicated Air Speed), lookup the meaning of IAS if you're not familiar with it. It will then typically have 3-axis gyros, accelerometers and magnetometers which will be used to output attitude, angular rates (p, q, r) and accelerations in the body axes. Some personal experiences with different ADAHRS units and FTI:
Depending on how realistic you want your RL training and testing to be you could also look at not using the ground-truth states but rather take the ground truth states and model noise, bias, drift etc. In terms of detecting a stall during an episode you know what the critical angle of attack is for your aircraft, take a look in the aircraft model file and look at the Cl versus alpha data for lift, and you can retrieve the current AoA (aka alpha) from the property
I'd mentioned a handful of things that would be useful to understand above, in particular things like alpha (AoA) are pretty critical to understanding how aircraft fly etc. Angles between body frame and wind frame - Here are a couple of potentially useful links for some introduction to basic aircraft dynamics. |
Beta Was this translation helpful? Give feedback.
-
Depends. The property jsbsim/src/models/FGAerodynamics.cpp Lines 339 to 346 in edea29d Or on someone writing to jsbsim/src/models/FGAerodynamics.cpp Line 588 in edea29d The complication with the |
Beta Was this translation helpful? Give feedback.
-
Yep, since the C-172r model you're using doesn't set the In terms of working out a maximum alpha value the C-172 doesn't have leading edge flaps or slats, only trailing edge flaps. So compared to the example Cl vs alpha graph I included above there are fewer combinations. In fact, things are even simpler if you take a look at the model in So you can find (ignore the jsbsim/aircraft/c172r/c172r.xml Lines 577 to 608 in e9f7e8b |
Beta Was this translation helpful? Give feedback.
-
I have no experience with RL, only a very high-level understanding of it, but I'm interested in trying it out for some aircraft control situations. I have limited experience using CNN for some image processing work in the past. I noticed the following suggestions in the Markov-Pilot thesis regarding the choice of state/observations.
So I'd suggest the following initial minimal set.
|
Beta Was this translation helpful? Give feedback.
-
Hi!
Here from -15:
In the line State, the last value is AoS, with the second to last being AoA. (The entire line is: Roll, Pitch, Yaw, P, Q, R, AoA, AoS |
Beta Was this translation helpful? Give feedback.
-
First off you seem to be inconsistent between roll and pitch. Your comments about the state line and the orientation line all show the pitch being either +15 or -15 degrees and the roll constant at 10 degrees. Which doesn't match up with your initial description of the issue. Take a look at the starting velocities in each case, remember AoA will be the difference between the pitch attitude and the velocity vector. Lastly, log and draw a graph of the attitude angles, AoA, AoS, the control commands and airspeed. |
Beta Was this translation helpful? Give feedback.
-
@seanmcleod hello! I will update on my progress soon, but in the meantime I wanted to ask something a bit different |
Beta Was this translation helpful? Give feedback.
-
@JDatPNW sure no problem with an acknowledgement. Please post a link to your thesis once it's complete, we have started a WiKi page referencing examples, papers, thesis etc. that make use of JSBSim - https://github.com/JSBSim-Team/jsbsim/wiki/Interesting-JSBSim-Examples |
Beta Was this translation helpful? Give feedback.
-
Hi @JDatPNW and @seanmcleod I'm doing research on AI in dogfight recently. I'd like to use reinforcement learning with JSBSim and I'm new to artificial neural networks and RL, so may I asked you for some advice? Here's what I've planned to do: For every single timestamp, RL model receives a states vector of the last iteration and take actions for the current iteration. Actions are then grouped and used to generate JSBSim scripts. Then a new state vector is calculated by Flight Dynamics Model JSBSim using the generated script. Among them, the input and output part of JSBSim and actions taken seems quite complex. In my opinion, input from "Next state" (which is also the output of the last timestamp JSBSim) should be all the properties which could describe the pose and state of a plane, i.e., line 142-169 in
Actions which could be taken are "set" in
for f-16, which are:
My questions are:
|
Beta Was this translation helpful? Give feedback.
-
Have you taken a look at the reinforcement learning references on the Wiki in terms of JSBSim and it's use in RL? https://github.com/JSBSim-Team/jsbsim/wiki/Interesting-JSBSim-Examples#reinforcement-learning |
Beta Was this translation helpful? Give feedback.
-
Hi, I also don't think you need to generate a script. You can control the plane directly through the model.py (take a look at my QPlane repository for reference) Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
@mrwangyou show us the python code you're using. For example here is some python code I posted a while ago which loads the 737 model at a specific altitude, speed etc. - |
Beta Was this translation helpful? Give feedback.
-
Sorry for the way too late response! My thesis has cleared the embargo a while ago already and honestly I just forgot to share. As such, I can now also share the newest and probably last paper in this series of RL for fixed-wing aircraft, a review paper. I will link all papers below, if you find them helpful feel free to link them. https://doi.org/10.1145/3458305.3478446 Thanks again for all the help, advice and support! PS: Feel free to close this issue/discussion! |
Beta Was this translation helpful? Give feedback.
-
Thanks @JDatPNW for the update. I've edited the Wiki page to add a reference to your MSc thesis. |
Beta Was this translation helpful? Give feedback.
-
Hello!
I have been working a bit with XPlane11 recently and wanted to see if JSBSim would work better, as there are features that I prefer, such as stepping physics myself and my own speed, and directly interfacing with the sim - not having to send UDP packets for it.
I am by no means a aviation specialist (I am actually very new to it), and am therefore having trouble understanding the properties. I am currently using the c172 model and I printed out all properties available to me. For XPlane the DREFs (which are basically XPlanes Properties) are listed in their wiki, which makes it easier for someone like me to understand them: DREFS, but the printed list from JSBSim is a bit too technical for me to understand. Is there a list with short explanations?
small extract from the Properties (randomly copied):
My plan is to reset the plane (mid air with a velocity, going straight, or something like that) and to then control it per physics step using my code.
I would want to control the stick and pedals (or ailerons, elevator and the rudder) at each timestep
Receive the:
at each timestep
And then when resetting set the same values to a desired state, lets say flying straight ahead for example.
I have somewhat figured out how to do this in terms of writing the code, but I am not sure which properties I need to set. (
fdm.set_property_value
andfdm.get_property_value
)On a secondary note, I wanted to ask if there is a python documentation, and if I can reset the plane with
fdm.run_ic
orfdm.reset_to_initial_conditions
without the printout:Thanks!
JD
Beta Was this translation helpful? Give feedback.
All reactions