Howto:Build and run FlightGear on Raspberry Pi 4: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
 
(5 intermediate revisions by the same user not shown)
Line 17: Line 17:
</gallery>
</gallery>


== Update Raspbian ==
== Possible Paths ==
Use the below commands to update your Raspberry Pi:


<syntaxhighlight lang="bash">
[[File:FlightGear System.jpg|FlightGear and the Raspberry Pi family.]]
sudo apt-get update
sudo apt-get full-upgrade
</syntaxhighlight>


Do not use the below update command unless you know how and why to use it. This command will install experimental software that has a good chance of breaking your operating system. It is like flying into a thunder storm cloud.
The Raspberry Pi can run FlightGear or perform other duties. Creating avionics steam gauges to more modern touch screen avionics devices. These ancillary Raspberries can serve a standard desktop computer running FlightGear or another Raspberry running FlightGear with most of the settings set to low.


<syntaxhighlight lang="bash">
== Did You Know ==
sudo rpi-update          (DO NOT USE)
</syntaxhighlight>
 
==Backtrace using gdb: and Download_and_compile.sh==
Tracking down a crash with <code>double free corruption (fasttop)</code>
 
Set environment variable:
<syntaxhighlight>
set environment MALLOC_CHECK_ 2
</syntaxhighlight>
 
Next run FlightGear with debug:
<syntaxhighlight lang="bash">
./run_fgfs_debug.sh --launcher
</syntaxhighlight>
 
Use the below gdb commands <code> handle SIGPIPE nostop and handle SIG32 nostop</code>  to skip innocent events:
<syntaxhighlight>
gdb: handle SIGPIPE nostop
gdb: handle SIG32 nostop
</syntaxhighlight>
 
Use <code>r</code> within gdb to run FlightGear:
<syntaxhighlight>
gdb: r
</syntaxhighlight>
 
After the crash use the gdb command <code>bt</code> to print the backtrace:
<syntaxhighlight>
gdb: bt
</syntaxhighlight>
 
==osgviewer==
Using the command line osgviewer to display models. These instructions are for FlightGear and OSG built with download_and_compile.sh.
 
<syntaxhighlight>
cd /flightgear/dnc-managed/install/openscenegraph/bin
 
export LD_LIBRARY_PATH=../openscenegraph/lib:$LD_LIBRARY_PATH
 
./osgviewer "path to your model file"
</syntaxhighlight>
 
Type <code>h</code> for the help menu.
 
== Feature Scaling - FlightGear ==
{{See also|FlightGear and OpenGL ES}}
 
=== Menu Bar ===
 
Hiding the menu bar improves FPS too some degree. More so when FlightGear is running in a window. It can be toggled on/off with [Shift] + [F10] or the Auto Hide option can be used.
 
=== GPU Profile ===
{{Main article|Graphics card profiles}}
 
The following GPU profile was provided by enrogue <ref>https://forum.flightgear.org/viewtopic.php?f=45&t=36922&p=364937#p364914</ref>
<syntaxhighlight lang="xml">
<?xml version="1.0"?>
 
<PropertyList>
  <shaders>
    <custom-settings type="bool">true</custom-settings>
    <clouds type="double">0</clouds>
    <generic type="double">1</generic>
    <landmass type="double">3</landmass>
    <model type="double">0</model>
    <contrails type="double">1</contrails>
    <crop type="double">0</crop>
    <skydome type="bool">false</skydome>
    <transition type="double">0</transition>
    <urban type="double">0</urban>
    <water type="double">3</water>
    <wind-effects type="double">0</wind-effects>
    <vegetation-effects type="double">0</vegetation-effects>
    <forest type="double">0</forest>
    <lights type="double">3</lights>
    <quality-level-internal type="double">3</quality-level-internal>
    <quality-level type="double">-1</quality-level>
  </shaders>
  <random-objects type="bool">true</random-objects>
  <random-vegetation type="bool">true</random-vegetation>
  <random-vegetation-shadows type="bool">false</random-vegetation-shadows>
  <random-vegetation-normals type="bool">false</random-vegetation-normals>
  <vegetation-density type="double">1</vegetation-density>
  <random-buildings type="bool">false</random-buildings>
  <building-density type="double">1</building-density>
  <point-sprites type="bool">true</point-sprites>
  <particles type="bool">true</particles>
  <clouds3d-enable type="bool">true</clouds3d-enable>
  <clouds3d-vis-range type="double">10000</clouds3d-vis-range>
  <clouds3d-detail-range type="double">10000</clouds3d-detail-range>
  <clouds3d-density type="double">0.25</clouds3d-density>
  <shadows>
    <enabled type="bool">true</enabled>
  </shadows>
</PropertyList>
</syntaxhighlight>
 
=== FG1000 ===
{{Main article|FG1000}}
 
For the time being, the FG1000 must be considered hardly usable on the RPi, i.e. ~200ms/5fps. We're currently in the process of investigating what can be done to make it possible to use the device on the RPi, since that would seem like a perfect use-case.
 
One thing that's obvious is that initialization of the device takes unusually long.
To see what's going on, we can wrap the initialization code inside $FG_ROOT/gui/menubar.xml in between profiling calls:
 
{{See also|Built-in Profiler}}
<syntaxhighlight lang="diff">
diff --git a/gui/menubar.xml b/gui/menubar.xml
index ff3faa1ac..6c94b2e76 100644
--- a/gui/menubar.xml
+++ b/gui/menubar.xml
@@ -834,6 +834,7 @@
                        <binding>
                                <command>nasal</command>
                                <script>
+                                      fgcommand("profiler-start");
                                        var nasal_dir = getprop("/sim/fg-root") ~ "/Aircraft/Instruments-3d/FG1000/Nasal/";
                                        if (! defined("fg1000")) {
                                                io.load_nasal(nasal_dir ~ 'FG1000.nas', "fg1000");
@@ -846,6 +847,7 @@
                                        var fg1000system = fg1000.FG1000.getOrCreateInstance();
                                        var pfdindex = fg1000system.addPFD();
                                        fg1000system.displayGUI(pfdindex);
+                                      fgcommand("profiler-stop");
                                </script>
                        </binding>
</syntaxhighlight>
 
 
Another thing worth trying is running the built-on OSG optimizer on the root group, this requires patching SG/FG respectively:
 
<syntaxhighlight lang="diff">
diff --git a/simgear/canvas/elements/CanvasGroup.hxx b/simgear/canvas/elements/CanvasGroup.hxx
index 33687637..288da23d 100644
--- a/simgear/canvas/elements/CanvasGroup.hxx
+++ b/simgear/canvas/elements/CanvasGroup.hxx
@@ -20,6 +20,8 @@
#ifndef CANVAS_GROUP_HXX_
#define CANVAS_GROUP_HXX_
+#include <osgUtil/Optimizer>
+
#include "CanvasElement.hxx"
#include <list>
@@ -97,6 +99,11 @@ namespace canvas
      osg::BoundingBox
      getTransformedBounds(const osg::Matrix& m) const override;
+      void optimize () {
+            osgUtil::Optimizer opt;
+            opt.optimize(_scene_group.get()  );
+      }
+
    protected:
      static ElementFactories  _child_factories;
 
</syntaxhighlight>
 
<syntaxhighlight lang="diff">
diff --git a/src/Scripting/NasalCanvas.cxx b/src/Scripting/NasalCanvas.cxx
index 602f06989..23aadfb36 100644
--- a/src/Scripting/NasalCanvas.cxx
+++ b/src/Scripting/NasalCanvas.cxx
@@ -521,7 +521,8 @@ naRef initNasalCanvas(naRef globals, naContext c)
    .bases<NasalElement>()
    .method("_createChild", &f_groupCreateChild)
    .method( "_getChild", &f_groupGetChild)
-    .method("_getElementById", &sc::Group::getElementById);
+    .method("_getElementById", &sc::Group::getElementById)
+    .method("optimize", &sc::Group::optimize);
  NasalText::init("canvas.Text")
    .bases<NasalElement>()
    .method("heightForWidth", &sc::Text::heightForWidth)
</syntaxhighlight>


===Sun, tree and other textures===
[[File:Rendering.png|thumb|How to fix some texture issues with the Raspberry Pi4.]]
Did you know that the sun, tree and other textures can be fixed by enabling the "Cache graphics for faster loading" option, that is found in the launcher? This works for version 2020.3.5.




[[Category:Raspberry Pi]]
[[Category:Raspberry Pi]]
[[Category:Building from source‎]]
[[Category:Building from source‎]]

Latest revision as of 03:04, 19 January 2021


It is now possible to run FlightGear on a Raspberry Pi, starting with the model Pi 4. The objective of Howto:Build and run FlightGear on Raspberry Pi 4 is to introduce Pi users to FlightGear and possibly FlightGear users to the Raspberry Pi family. One of the main objectives of the Raspberry Pi is education. Hopefully this marriage will introduce some young programmers to FlightGear. Although this will mainly deal with the Pi 4, other models may find applications in the area of flight panels and instruments.

Gallery

Possible Paths

FlightGear and the Raspberry Pi family.

The Raspberry Pi can run FlightGear or perform other duties. Creating avionics steam gauges to more modern touch screen avionics devices. These ancillary Raspberries can serve a standard desktop computer running FlightGear or another Raspberry running FlightGear with most of the settings set to low.

Did You Know

Sun, tree and other textures

How to fix some texture issues with the Raspberry Pi4.

Did you know that the sun, tree and other textures can be fixed by enabling the "Cache graphics for faster loading" option, that is found in the launcher? This works for version 2020.3.5.