20,741
edits
(→JSBSim) |
|||
Line 635: | Line 635: | ||
<references/> | <references/> | ||
=== Status: Child FDM Support === | |||
Meanwhile, since around ~2009, this has been partially implemented in JSBSim, which now contains support for a slaved '''<child>''' FDM element that is mated/coupled to the main FDM. The feature is still considered experimental and | Meanwhile, since around ~2009, this has been partially implemented in JSBSim, which now contains support for a slaved '''<child>''' FDM element that is mated/coupled to the main FDM. The feature is still considered experimental and not supported by JSBSim developers, it is also currently disabled by default - especially in FlightGear, where it's causing problems/segfaults. | ||
However, we can look at the corresponding code in order to learn how to instantiate an '''FGFDMExec''' instance as part of '''FCS''' system/channel in order to run an identical FDM instance in look-ahead mode, see $JSBSIM_SRC/FGFDMExec.cpp: '''bool FGFDMExec::ReadChild(Element* el)''' | However, we can look at the corresponding code in order to learn how to instantiate an '''FGFDMExec''' instance as part of '''FCS''' system/channel in order to run an identical FDM instance in look-ahead mode, see $JSBSIM_SRC/FGFDMExec.cpp: '''bool FGFDMExec::ReadChild(Element* el)''' | ||
Line 689: | Line 690: | ||
return true; | return true; | ||
} | } | ||
</syntaxhighlight> | |||
This sets up the child FDM entry in the FGFDMExec instance and adds a corresonding child FDM, i.e. another FGFDMExec instance. To see how this is currently handled at runtime, take a look at the FGFDMExec::Run() method, which interleaves execution of child FDMs with the main/parent FDM: | |||
<syntaxhighlight lang="cpp"> | |||
bool FGFDMExec::Run(void) | |||
{ | |||
bool success=true; | |||
Debug(2); | |||
for (unsigned int i=1; i<ChildFDMList.size(); i++) { | |||
ChildFDMList[i]->AssignState( (FGPropagate*)Models[ePropagate] ); // Transfer state to the child FDM | |||
ChildFDMList[i]->Run(); | |||
} | |||
IncrTime(); | |||
// returns true if success, false if complete | |||
if (Script != 0 && !IntegrationSuspended()) success = Script->RunScript(); | |||
for (unsigned int i = 0; i < Models.size(); i++) { | |||
LoadInputs(i); | |||
Models[i]->Run(holding); | |||
} | |||
if (Terminate) success = false; | |||
return (success); | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Now, as can be seen | |||
Now, as can be seen in the ReadChild() and Run() this is all currently specific to the use-cases discussed originally on the JSBSim/FlightGear-Devel mailing lists, so it cannot be directly used "as-is" for VNAV purposes, but needs to be slightly modified, or rather, re-implemented with the following requirements in mind: | |||
* add a new FCS component that instantiates a child FDM | * add a new FCS component that instantiates a child FDM |