-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix quadrants by removing active engines #1335
Conversation
Nice to see this clean up. It's a bit unfortunate though that JSBSim still doesn't support defining multiple engine variants, which means there are now 2 FDMs that need to kept in sync.
|
Of the top of my head I'm not sure this is the correct fix. I think there is more tied to these multiple engines than just the throttle. There has to be a way to make the throttle quadrant work with either engine. I want to look at this a little closer and see exactly what the issue is. I have heard this issue before and don't fully understand the details of the issue. I have a throttle quadrant and it works fine. Is that because I mapped it differently than the default? What make us think we can't map both engines to the [zero] engine throttle using filters or code of some sort. What's up with the state overlay stuff. Is this new state overlay definitions or maybe old definitions that we had removed? |
@stuartbuchanan is this just the number 0 engine accounted for or is the number 1 engine also part of this code as variant? In other words, does the variant, larger engine, still need to be duplicated from these changes. All I saw was engine 0? |
Why is it so hard or not appropriate to change the bindings for the joysticks? How are aircraft with multiple engines that are operated simultaneously managed? If the only argument is that the majority of aircraft have always used engines/engine[0]/xxx or all the nasal bindings uses that property, why don't we just fix those bindings so there is a "common" or universal property that can be used by all to get any current or future single or multiple engine configuration to work right out of the box? |
Hi Folks, Thanks very much for the feedback. Attempting to collate all the feedback so far: @onox - I removed the "start with engine running" option as it's covered by support for the state system (which is the next commit I'd like to get pulled). I thought I'd removed the option to change the engine within the engine options dialog?
I don't think the problem is that the joystick bindings aren't robust. I think the fundamental issue here is that the 172 is not a twin engined aircraft :) , and VS had to do a huge number of hacks to try to fool the FDM and simulator into thinking that what at a configuration level had two engines, in fact only had one Basically, this breaks the simulation "model". The correct way to handle this is through variants and having separate FDM files to handle airframes with substantially different FDMs. That's what this fixes. |
OK, like I said, I'm not opposed to the variant approach, I understand that's what it's there for. I know this affects our ability to change variants on the fly and I think it is a shame to loose the flexibility of being able to change all these features "in sim", all because of a controller binding. I'm not convinced about the reasons we need to do this, just my opinion, but mostly because I still don't understand why we can't add code to either or Nasal/controls.nas and/or
I am aware though we had to apply a few filters to accommodate this approach, but it was how it had to be done to achieve the outcome. As far as a hack, I guess it's a matter of perspective. Depends on you ultimate goal. As the core code and supports stands now, maybe more of a hack than not, but that's not to say we couldn't take another path to make this a viable option for aircraft. There are now at least a few to several aircraft that offer multiple size engines. But I am not hearing any feedback or support for my position from anyone else on the team @gilbertohasnofb , @legoboyvdlp @dany93 and it appears @onox is OK with removing the added flexibility of how it is now. I guess that's the beauty of the flexibility of open source code and private hangers. I can keep a version however I want it privately. It's not worth a fight in my opinion even though I strongly disagree, at least so far, with the reason why this needs to be done. As far as the states, that is long overdue, but I'm sure you followed my comments on the mailing list about what really needs to be done to give it justices and not basically be yet another hack! For now I am going to step back and just do my own thing. Maybe in the future I will come to see the reasoning for this is justified and the right approach for the future as it was for the past. |
This code change is well above my skills. I'm not rigid on the subject of changing the engine in-sim, however I appreciated this flexibility. But the main flexibility (bushkit, floats, skis) will remain. As the standard gear with the 180hp engine, I guess. I agree that having to loose this only for one quadrant JS which doesn't work is not very pleasant. |
This is actually quite a good point to think about. The standard engine on a 172P is the 160hp, and I think we definitely need to fit that in as the default. But that means we will lose the flexibiility with changing to floats or bushkits in-sim, as the 160hp is not powerful enough for those. Making the 180hp engine the default would be wrong IMO, as the 160hp is the most used one in RL by far. The only solution I can think of would be to also remove the flexibility of changing to bushkit and float in-sim and use only the variant approach. This would be a pity.
Yes, that would be quite annoying to maintain. This single aircraft actually becomes several aircraft. For me this is actually the most annoying point; I could definitely live without the flexibility of changing engines in-sim but maintain two FDMs sounds annoying to say the least, and might lead to bugs in the long run (e.g. only one FDM being altered when fixing a bug, unknowingly causing them to diverge). |
FYI...
If this PR is going to be executed, there may may be references supporting leaving a variant of all undercarriage change outs for both engines. The variants as they are laid out now grouped the most likely uses attached to the most common engine regimes. This was acceptable because you could still mix and match all features "in sim". There is no reason not to leave a variant for each combination of features. You definitely shouldn't remove the ability to use the bush tires or any other undercarriage from the io320 even if only the "in sim" portion, in my opinion. It would be wrong as I believe it was done and discovered that a larger engine was needed to do it justice! |
Hi Folks, Re: FDM maintaining multiple FDMs. There should be minimal difference between the FDMs - just the different engine, prop and a pointmass for the additional engine mass for the io360. (Though I notice that I've left a spurious float chamber in the io360 definition I should remove) Re: Variants. The PR retains the flexibility to choose whatever set of gear/floats with whatever the chosen engine is. The -set variants really just impact the engine and the starting gear. The user can change the gear in-sim, as before. So to use the 160hp engine with amphibious floats the user would select a 160hp variant in the launcher, and then change to the amphibious floats from the configuration menu in-sim. @dany93 - this affects all quadrants with multiple throttle/prop/mixture levers. I've verified it on the CH version, and another user hit it on theirs (not sure whether it was CH or Saitek). So it's not just a single piece of hardware. |
@stuartbuchanan wrote
Initially, there was a float chamber for each engine.
If I remember well, this float chamber is used, at least in case of negative g's. For 160 and 180 hp engines, of course. |
@stuartbuchanan wrote
Obviously this cannot be a hardware issue.
|
By "So it's not just single piece of hardware" I should have written "So it's not just a single model of hardware". As I mentioned earlier in the thread, it's a specific issue with quadrants that have multiple throttle controls. I've done a quick grep, and I think it affects the following standard joystick configuration files that are in fgdata, and which use controls.perEngineSelectedAxisHandler (which is what mine uses): I haven't tested them, but from a code read I'm sure it also affects any throttle control attempting to set /controls/engines/engine[0]/throttle directly. So that also impacts the following Note that as the default aircraft, it's particularly important that stuff like this works out of the box. -Stuart |
Thanks for this detailed response and research, @stuartbuchanan. And sorry for my lack of knowledge about this. |
There are issues with the changes making this only use engine[0] I have to say what I dislike about this the most is that this change is just decided by one person outside the c172p core team and that this is the needed change to fix this issue. No discussion, no research as to cause and effect, and no attempt to understand what other remedies may be available. This is not how we have managed the changes to this aircraft in this development group. We have had many discussions as to what we want done, how and why.
Has anyone looked at how we may be able to accommodate these controllers in the aircraft code VS trying to change the controller configurations? |
Firstly, I'm sorry that this has come across so badly and apologize for any hurt I've caused. It certainly wasn't my intention to cause problems, and this pull request simply represent the result of the analysis I've done and my proposed fix. I think there is a problem here that needs to be fixed, and if there is a better solution than mine then great. Equally, I'm quite happy to be challenged on my understanding of the problem as well. Given you're clearly not happy about his, I suggest i go and have another look at how else we might address this. -Stuart The 180hp engine extra mass is now part of the FDM file itself (line 195 of c172p_io360.xml) |
@wlbragg wrote
It is included in the c172p-io360.xml file, lines 191-200.
This aside, I would have preferred a more consensual approach too. |
System/engine.xml
|
System/engine.nas
|
My throttle quadrant bindings, interesting, it isn't remapped as far as I can tell?
So what are these other controllers using that is not accounted for in the aircraft code? |
@stuartbuchanan I never wanted to come off this way. I really am happy with what we have managed to do with this aircraft and I feel like this is a step backwards to undo this flexibility. I understand you probably feel it is a step back to a more standard or accepted norm. That alone makes this problematic for us both. But if there is any other solution that isn't so invasive and accomplishes the task at hand, plus preserves the current functionality, I really would like to find it. |
Is the issue that these other controllers are calling engine[0]/engine[1] directly vs controls.throttleAxis()? |
Yes, that's exactly the issue. (As I think you've spotted, your quadrant binding of controls.throttleAxis() is being remapped by engine.nas (see the middle of the file).) There is also an override of controls.perEngineSelectedAxisHandle(), in engine.nas - I didn't spot it initially as it's right at the end of the file. However, the Joystick Configuration dialog (and my quadrant) doesn't use it - it sets /controls/engines/engine[]/throttle etc directly. From the comments in joystick.nas, this was an explicit decision so that those axes could be inverted, which perEngineSelectedAxisHandle() doesn't support. I took another look at modifying the core control bindings. It might be possible, but would require a lot of work on the core side and would still leave some problems: It would require modifying perEngineSelectedAxisHandler() to support inverted axes and then modify the joystick configuration dialog to use it. I think that would just about be possible, but it would still leave a couple of other issues:
I've done some further investigation to see if there's another way to address this without the refactoring, and come up with one possibility : As you've spotted, there only a mapping from /controls/engines/current-engine/... to /controls/engines/engine[0] and /controls/engines/engine[1]. I don't think it would be possible to get a mapping to go the other way because you end up in a loop. It might be possible to create a dummy engine[0] and then use that for the controls mapping to the "real" engine[1] and engine[2]. So that would be a possible solution, and would mean that the normal /controls/engines/engine[0]/throttle etc would work, while retaining the flexibility of in-sim engine changes. |
From the Aviator.xml controller
|
@stuartbuchanan why do we use both engine[x] and/or the nasal wrapper controls.xxx in controller configurations? Shouldn't we really only be using the nasal wrapper version? Where is /controls/engines/engine[x]/throttle actually used in any aircraft FDM? I did a "find in files" on the c172p and the only reference is the above filter mapping current-engine to engine[0]? Yet that is the active property that is controlling the engine? |
From my understanding, using /controls/engines/engine[x]/throttle in a controller binding eliminates the aircraft code from being able to use that property in any way, that can't be right. If so then the controllers shouldn't be using it as a direct binding. |
I'm not sure what you mean by "dummy" property, but I can't see a way to use /controls/engines/engine[x]/throttle in aircraft side code for anything so long as a controller is using it as a direct call to the FDM throttle. What that in effect does is tie the controller to the native JSBSim FDM bypassing any attempt to control the throttle in the aircraft code. Maybe I am not seeing this clearly. |
Unless you can explain how this works, I see no other solution other than your proposed solution of variants OR not allowing joystick controllers to map directly to ...engine[x]/throttle! |
First, I apologize, you didn't come off badly, I just needed to understand all the ramifications and options before I could be OK with this. We usually discuss minor stuff and this is major. Please read my responses above. No, I am really not happy about this change. But if it is insisted that a controller be allowed to use controls/engine/engine[x]/throttle directly, then I agree with you, this is the only way to make this work. I still don't understand how controls/engine/engine[x]/throttle ties directly to the FDM throttle outside our FDM? I see no link or connection in our local FDM code. That puzzles me. I think it is wrong overall because using this property directly from the controller eliminated the aircraft side code ability to filter that property in any way. If controls/engine/engine[x]/throttle was actually being tied to a local fcs function then we could easily filter it and do whatever we wanted to do with it. |
49cd705
to
0a1640d
Compare
Hi Folks, Good news! I've managed to write the XML control logic to map correctly to the JSBSim properties directly. This means
So I think this achieves both your design goals and the requirement for the standard properties to Just Work. I need to do some work to replace /controls/engines/current-engine/throttle and /controls/engines/current-engine/mixture with -Stuart |
False alarm :(. What I thought was working for both engines was in fact just working for engine[0]. Which isn't any use. :( I'll have another look at this with fresh eyes tomorrow. -Stuart |
On 9/29/20 6:11 PM, stuartbuchanan wrote:
False alarm :(.
What I thought was working for both engines was in fact just working for
engine[0]. Which isn't any use. :(
is there some way to alias the 160 or the 180 to engine[0] as needed? or the
other way around?
|
Stuart, is it both engine throttle mappings that don't work on your controller or just the one using engine[1] ? |
That actually might be workable. If you have a direct call to engine[0] working then we may be able to map engine[1] differently by using engine[0]. Can you post the changes you made so I can follow along? I think I answered my above question about which engine is not working with which mapping. I changed my joystick mapping to /controls/engines/engine[0]/throttle and then also to 1 and neither worked. So I answered that question. But I still would like to know...
|
Hi wlbragg, It's just engine[1]. Yes, for all engines with a single engine, the user will So I can make the 160hp engine work, but not the 180hp engine. The ideal would be that /controls/engines/engine[0]/throttle would work for both the 160 and 180 engines. Here the autopilot control file I've been trying to get work to map from those properties to the internal JSBSim ones. They work in that they set the properties, but there is a further transformation from the "pos" to the "cmd" properties that currently isn't :(. I've got one further idea - use autopilot config files to map from /controls/engines/engine[0] to /controls/engines/engine[1] directly. -Stuart |
That is where I was going if you actually got engine[0] to work directly. |
@stuartbuchanan |
There are changes elsewhere. I've just pushed them here: https://github.com/stuartbuchanan/c172p-detailed/tree/enginefilter -Stuart |
Hi Folks, Having spent some more time on this, I'm at a dead end. I've been unable to get the autopilot filters to work in the way I need them to. Mapping to /controls/engines/engine[0] to /fdm/jsbsim/fcs/throttle-pos-norm[1] doesn't work, and neither does mapping from /controls/engines/engine[0] to /controls/engines/engine[1]. In both cases the values from the "proper" joystick axis end up over-riding it. So I think we're back to balancing which is more important: - being able to use the /controls/engines/engine[] properties directly, or being able to change the engine in-sim. -Stuart |
@stuartbuchanan you have been extremely patient with me and I truly appreciate it and ask you for just a bit more indulgence.
OR, Is there a third option (desirable or not) to NOT use /controls/engines/engine[] directly but only use the mappings that the other half of the controllers use, such as controls.throttleAxis()? I ask becasue I am still unclear of the validity of a controller controlling "THIS" aircraft using /controls/engines/engine[] VS controls.throttleAxis(). Just because /controls/engines/engine[] has been used traditionally doesn't necessarily mean it is the best way to do this. Especially if there is the option to simply remap the existing controllers and retain the ability to have this engine flexibility. It that possibility doesn't' exist, then I concede and it would be a different story. OK, that's my questions as best I can describe them with absolutely no disrespect implied and understanding your experience in all things FlightGear. Maybe these questions will sum up my hesitation to change this and why I am so stuck on this opinion. If the c172p had always been configured this way would these joysticks be configured to work with it? If they can be configured to work through their mappings, I would take on the responsibility to do the work with your guidance. |
p.s. I haven't had the chance to look at where you are with getting engine[0] working but not mapping 1 to 0, and will look at it tonight and verify that I come to the same conclusion as you. |
@dany93 is this an option? |
@wlbragg - That third option would be effectively to deprecate using the /controls/engines[]/ properties directly. I think that's quite a major conceptual change that you'd need to propose on the -devel list and get agreement on. Personally, I don't think I would support that change, but I'd be happy to help explain the technical side if you needed assistance so it can be considered. I'm not going to throw my toys out of the pram if there was a consensus supporting it :) Good question on controls.throttleAxis(). That was introduced to make it easier to allow a single joystick to control any number of engines. So instead of having a joystick axis with separate bindings for each of the engines, you could just have one. You ask if joysticks could be configured to use the controls.throttleAxis() bindings: Yes, absolutely. I think we covered that above. The challenge is a) testing because we don't have access to the controllers to ensure the change works, b) we still have issues with existing bindings and devices that aren't covered by the bindings in fgdata/Input. Unfortunately the c172p is held to a higher bar because it's the default aircraft. We really need it to work "out of the box" as much as possible. In terms of having a single engine definition that covers both the 160 and 180hp engines, I think the stumbling block is going to be the propeller definition. -Stuart |
Sorry you misunderstood me, the third option is the same as "remapping". Just don't use /controllers/./../engine[x]/trhrottle directly anymore.
If so, if that broke your controller, then I don't consider this an option either. I would never push for that.
So this is where I am at as a last ditch solution. I feel that if these controllers are such an issue we would have heard about it by now. My guess is they are one offs or the users have already changed their bindings to something that works. So "needing testing" falls in that train of thought as well. If anyone has issues we generally hear about it.
We can use multiple pitch on the prop. Or are you saying we need a completely different prop and we can't change that on the fly? |
@wlbragg wrote
From the reality point of view, I don't understand the interest for this 'upgrade'. Can it be for a few people who wished to postpone their investment? Otherwise, why investing in an injection 180 hp engine and bridle it at 160 hp? Knowing that you will have to change the propeller + some instruments later to use it at 180 hp... The degradation proceeding (180 --> 160 hp) is obviously out of interest too. From the simulation point of view:
[1] Please fix me if I'm wrong |
@wlbragg wrote
At least, probably a different prop diameter.
|
@dany93
then this
This sounds to me like the engine is the same engine configured differently. So on the surface is seems we are already "cheating" in the way we did this? Unless we did exactly that and used the same engine parameters less available RPM? But to do that we needed two different engine definitions? |
In JSBSim, one engine giving 180 hp at 2700 RPM and one giving 160 hp at 2500 RPM are two different engines. |
@wlbragg - I'm afraid I still don't understand what your option 3 is. Unless it's to change the existing joystick bindings in fgdata/Input, and deprecate using the properties directly, which as I said above is something you'd really need to get buy-in from the -devel list. Or am I missing something?
Well, I'm telling you about it now. :) I don't think we see half the issues that end-users encounter. This isn't unique to this particular problem, but a general issue where I suspect a lot of new users hit problems and immediately give up because at that point they haven't got anything invested in the software. They shrug their shoulders and move on. I've reached the limits of the time I can spend on this. I've now spent significantly more time code-reading, explaining what is going on in the code and investigating alternatives than I did on the original work. BTW - I'm happy to have done so, as I learnt some stuff in the process. However I think we're now running round in circles. -Stuart |
Yes and no, yes, don't use it directly for the c172p. Do what ever you want any other aircraft. Especially if there is a "per aircraft binding capability". If it takes a dev list consensus so be it.
The term "Suspect" doesn't hold much weight in my opinion. I suspect it is because most user simply change their bindings.
Me too right now at this moment in time. Bottom line with me is... No matter how hard I try to be ok with this, so long as the bindings can be changed and the problem is solved, I can't. So I guess we are at an impasse and I am not interested in making this change if it can be handled with a binding. |
I want to make it clear, that if it can't be fixed with a binding change then I would support this. |
i don't know if i'm going to ask this properly but i'm going to try... why can't we have similar to what we currently have with two engine definitions... call them engine160 and engine180... they're in their own separate property trees... when we select the 180, map/alias these onto engine[0] and go... if we select the 160, map/alias those onto engine[0]... or is the problem that we cannot change the FDM at runtime so it has to have both engines in it all the time? could this be handled by adjusting the craft init code in core so we can get the FDM switch in place before JSBSim eats it for operation? kinda like when we switch airports or scenery settings and the sim basically restarts everything... just do the same for an engine change like this... |
@wkitty42 what your asking is on an order of magnitude a whole bunch more than either fix Stuart and I are talking about and probably is a non starter. But thanks for the suggestion. With no other fix other than Stuart's original idea or simply changing a controller binding (doesn't matter to me how many hardware bindings need changed), I just can't make myself be OK with changing the aircraft to support a binding as I can with changing a binding to support an aircraft. I wish I could and that it didn't matter to me, but it does because it takes away a flexibility in programming that I don't want to loose. |
@stuartbuchanan wrote
@wlbragg wrote
Maybe posting a question in the forum, asking if other people had the issue? And, if yes, which hardware and if / how they solved it? |
737805b
to
4009cc7
Compare
4009cc7
to
996d98d
Compare
Hi Folks,
There's been a long-standing bug with the c172p that hardware throttle quadrants don't work. The root cause is the model having multiple engine definitions and logic to select an active-engine.
On balance I think being able to use a throttle quadrant is more important than being able to change the engine in-sim, and I finally got around to looking at fixing it. I wasn't able to find a way to do so by over-riding the controls.nas module (which has previously caused problems in itself), so spit the FDM file in two based on the engine type (io320 or io360).
The downside is that it's not possible to change the engine type in-sim. However, I think selecting it in the launcher makes sense and having the amphibious and float planes use the io360 makes sense.
The change below is largely mechanical - removing /engines/active-engine.
-Stuart