Implementing VNAV support in FlightGear: Difference between revisions

Jump to navigation Jump to search
→‎JSBSim: how to add new FCS components
No edit summary
(→‎JSBSim: how to add new FCS components)
Line 158: Line 158:
* a way of implementing this data into the aircraft's model(usually xml file)
* a way of implementing this data into the aircraft's model(usually xml file)


== JSBSim - Open Questions ==
== JSBSim ==
=== Adding new Control System Components ===
<syntaxhighlight lang="diff">
diff --git a/src/models/FGFCS.cpp b/src/models/FGFCS.cpp
index 59deaaf..5457632 100644
--- a/src/models/FGFCS.cpp
+++ b/src/models/FGFCS.cpp
@@ -64,6 +64,7 @@ INCLUDES
#include "models/flight_control/FGWaypoint.h"
#include "models/flight_control/FGAngles.h"
#include "models/flight_control/FGDistributor.h"
+#include "models/flight_control/FGDummy.h"
#include "FGFCSChannel.h"
@@ -642,6 +643,8 @@ bool FGFCS::Load(Element* el, SystemType systype)
          newChannel->Add(new FGAngles(this, component_element));
        } else if (component_element->GetName() == string("distributor")) {
          newChannel->Add(new FGDistributor(this, component_element));
+ } else if (component_element->GetName() == string("dummy")) {
+          newChannel->Add(new FGDummy(this, component_element));
        } else {
          cerr << "Unknown FCS component: " << component_element->GetName() << endl;
        }
diff --git a/src/models/flight_control/CMakeLists.txt b/src/models/flight_control/CMakeLists.txt
index e9a1a8d..8a67322 100644
--- a/src/models/flight_control/CMakeLists.txt
+++ b/src/models/flight_control/CMakeLists.txt
@@ -14,7 +14,8 @@ set(JSBSIM_MODELS_FLIGHT_CONTROL_SRC FGDeadBand.cpp
                                      FGMagnetometer.cpp
                                      FGAngles.cpp
                                      FGWaypoint.cpp
-                                    FGDistributor.cpp)
+                                    FGDistributor.cpp
+     FGDummy.cpp)
set(JSBSIM_MODELS_FLIGHT_CONTROL_HDR FGDeadBand.h
                                      FGFCSComponent.h
@@ -33,7 +34,8 @@ set(JSBSIM_MODELS_FLIGHT_CONTROL_HDR FGDeadBand.h
                                      FGSensorOrientation.h
                                      FGAngles.h
                                      FGWaypoint.h
-                                    FGDistributor.h)
+                                    FGDistributor.h
+     FGDummy.h)
add_library(FlightControl ${JSBSIM_MODELS_FLIGHT_CONTROL_HDR}
                          ${JSBSIM_MODELS_FLIGHT_CONTROL_SRC})
diff --git a/src/models/flight_control/FGDummy.cpp b/src/models/flight_control/FGDummy.cpp
new file mode 100644
index 0000000..5c4dcf4
--- /dev/null
+++ b/src/models/flight_control/FGDummy.cpp
@@ -0,0 +1,28 @@
+#include <iostream>
+
+#include "FGDummy.h"
+#include "input_output/FGXMLElement.h"
+
+using namespace std;
+
+namespace JSBSim {
+
+FGDummy::FGDummy(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
+{
+}
+
+
+FGDummy::~FGDummy()
+{
+
+}
+
+
+bool FGDummy::Run(void )
+{
+
+  return true;
+}
+
+} //namespace JSBSim
+
diff --git a/src/models/flight_control/FGDummy.h b/src/models/flight_control/FGDummy.h
new file mode 100644
index 0000000..cc30490
--- /dev/null
+++ b/src/models/flight_control/FGDummy.h
@@ -0,0 +1,42 @@
+#ifndef FGDUMMY_H
+#define FGDUMMY_H
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+INCLUDES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#include <iostream>
+#include <cstdlib>
+
+#include "FGFCSComponent.h"
+#include "math/FGCondition.h"
+#include "math/FGPropertyValue.h"
+#include "math/FGRealValue.h"
+
+namespace JSBSim {
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DECLARATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+class FGDummy  : public FGFCSComponent
+{
+public:
+  /** Constructor
+      @param fcs a pointer to the parent FGFCS class
+      @param element a pointer to the Element (from the config file XML tree)
+            that represents this distributor component */
+  FGDummy(FGFCS* fcs, Element* element);
+
+  /// Destructor
+  ~FGDummy();
+
+  /** Executes the distributor logic.
+      @return true - always*/
+  bool Run(void);
+
+private:
+
+}; // FGDummy class
+} // of namespace JSBSim
+#endif
 
</syntaxhighlight>
=== Open Questions ===
Check the JSBSim docs/website: there's a compact little example called WNS (Waypoint Navigation System), for following/making lateral waypoints. All implemented in JSBSim directly, i.e. can be run/played with standalone. It's in the end of the reference manual, example #5 - just search for "waypoint" or "WNS".
Check the JSBSim docs/website: there's a compact little example called WNS (Waypoint Navigation System), for following/making lateral waypoints. All implemented in JSBSim directly, i.e. can be run/played with standalone. It's in the end of the reference manual, example #5 - just search for "waypoint" or "WNS".


Navigation menu