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

From FlightGear wiki
Jump to: navigation, search
m (Download_and_compile.sh)
(Download_and_compile.sh)
Line 534: Line 534:
 
[[Scripted Compilation on Linux Debian/Ubuntu]]
 
[[Scripted Compilation on Linux Debian/Ubuntu]]
  
There can be a complication when using a version of FlightGear that has been built with Download_and_compile.sh. This involves the combination of  two situations; the version is being used and changes are being performed to files within the FlightGear build, furthermore the build is being updated. During updates, Git keeps an eye on any changes too files within this build. Git assumes that you are a software developer, of course this is no problem if you know what you are doing. So if Git sees a change, like to a joystick file, it thinks you are a developer and keeps track of changes. The issue shows up, after changes were performed, when download_and_compile.sh goes to update the FlightGear build. Git gets involved and needs to know how to integrate your changes with the changes from the update performed by download_and_compile.sh. An easy solution is to make a second copy of FlightGear to use and just update the original. Or make a copy of fgdate and use the FlightGear launcher to point to this working/running version of fgdata.
+
There can be a complication when using a version of FlightGear that has been built with Download_and_compile.sh. This involves the combination of  two situations; the version is being used and changes are being performed to files within the FlightGear build, furthermore the build is being updated at a later time. During updates, Git keeps an eye on any changes too files within this build. Git assumes that you are a software developer, of course this is no problem if you know what you are doing. So if Git sees a change, like to a joystick file, it thinks you are a developer and keeps track of changes. The issue shows up, after changes were performed, when download_and_compile.sh goes to update the FlightGear build. Git gets involved and needs to know how to integrate your changes with the changes from the update performed by download_and_compile.sh. An easy solution is to make a second copy of FlightGear to use and just update the original. Or make a copy of fgdate and use the FlightGear launcher to point to this working/running version of fgdata.
  
 
The following was provided by enrogue <ref>https://forum.flightgear.org/viewtopic.php?f=45&t=36922&start=20</ref>
 
The following was provided by enrogue <ref>https://forum.flightgear.org/viewtopic.php?f=45&t=36922&start=20</ref>

Revision as of 09:46, 25 May 2020

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 useres 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, hence FGPanel.

Gallery

Update Raspbian

Use the below commands to update your Raspberry Pi:

sudo apt-get update
sudo apt-get full-upgrade

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.

sudo rpi-update          (DO NOT USE)

Joysticks

Joystick calibration using jstest-gtk dialog box.

You will find that controlling your aircraft, with the official Raspberry Pi keyboard and mouse, too be rather difficult. A joystick will solve this problem. The Logitech Extreme 3D PRO is plug and play, for the most part, with FlightGear. Most modern joysticks should also work. There is a dialog box to assign common joystick controls, in FlightGear. Controls are also properties, however that is for later. This joystick dialog box is found in the top menu bar under 'Files'. Next you will find 'Joystick Configuration' to click on and that will bring up the desired dialog box.

If the joystick’s travel is not being used efficiently or the neutral dead band is not right, the joystick can be calibrated. Install jstest-gtk through the Raspbian software installer or use the terminal and apt-get install command.

sudo apt-get install jstest-gtk

After running jstest-gtk click on your joystick within the jstest-gtk window. Next click on the 'Calibration' button. The calibration can be performed within this dialog box. Consider making note of these values before performing the calibration. Do not forget to cycle the hat switch that is on top of the stick. This is because this switch is considered as a proportional input just like the stick axis. In order to save these new settings, after a reboot or new power up, do not close jstest-gtk at this moment. First open a terminal and enter the below command in order to save the new calibration values. The 'device_name' of the joystick is in the first dialog box of jstest-gtk. It will be something like js0, js1 etc.

sudo jscal-store /dev/input/js0


Some or most Linux distributions will need more work to store these new calibration values, in the way of RULES. However, it seems that Raspbian doesn’t require anymore work.

The above calibration may not adjust for any center dead band. Notice that the calibration values are representing binary numbers in that the maximums are in power of two’s. Except where the maximum value is 1 or -1. It is common to see these values close to 512 or 1024. Consider the values below. To find the maximum value add the RangeMin to the RangeMax. For example; 0 + 1024 = 1024. Since this scheme starts with 0, not 1, 1022 or 510 might be the maximum value. The first pair of numbers, not considering the axis number, should add up to the maximum value.

Axis CenterMin CenterMax RangeMin RangeMax
0 511 511 0 1022
1 511 511 0 1022
2 127 127 0 254
3 127 127 0 254
4 0 0 -1 1
5 0 0 -1 1

In order to introduce a dead band consider the values below:

Axis CenterMin CenterMax RangeMin RangeMax
0 491 531 20 1002
1 491 531 20 1002
2 117 137 10 254
3 117 137 10 254
4 0 0 -1 1
5 0 0 -1 1

Or the values in the calibration dialog box screenshot, entitled "Joystick calibration using jstest-gtk dialog box".

Axis 4 and 5 are examples of the hat switch.

Saitek Saitek Pro Flight Quadrant

Properties controls.
Properties tree controls throttle-coupled.

This throttle quadrant is now produced by Logitech and works with FG and the Raspberry Pi4. If used with a single engine aircraft or a multi engine aircraft where the engines are controlled with one stick on the quadrant, this will be a plug and play setup. However, there will be a noticeable dead band in the middle of the travel. Furthermore, it is possible that all the usable stick travel is not utilized. Both of these issues can be addressed by calibrating the quadrant as in the joystick example above. Below is the calibration data before calibration and below that is the data after calibration. Notice that the center dead band is removed.

Axis CenterMin CenterMax RangeMin RangeMax
0 112 124 15 239
1 112 124 15 239
2 112 124 15 239

After calibration below:

Axis CenterMin CenterMax RangeMin RangeMax
0 127 127 0 255
1 127 127 0 255
2 127 127 0 255

If this quadrant is used with a multi engine aircraft and each engine throttle is controlled by a separate quadrant lever, the levers will only use half of its travel. In order to resolve this, the joystick configuration file will need a small edit. This file is located in homepi/.fgfs/Input, assuming your user name is ‘pi’. Notice that ‘.fgfs’ is a hidden folder in your Home folder. Only edit the joystick configuration files that are in your Home folder. Do not edit the files that are native to FlightGear. In this example we will be editing ‘Saitek-Saitek-Pro-Flight-Quadrant.xml’.

Let us assume that this configuration is for the twin engine DC-3 Dakota and axis-0 will be assigned to ALL engine mixture levers, axis-1 will be assigned to ‘Throttle Engine 0’ and axis-2 is assigned to ‘Throttle Engine 1’. Note that within this .XML configuration file that <axis> is another way to express <axis n=’0’>. The axis-0 doesn’t need the n=’0’. Find <axis n=’1’> and change the ‘offset’ from 0 to -1 also change ‘factor’ from 1 to -0.5. Do the same for <axis n='2'>.

Note For FG version 2019.1.1, axis n="1" and n="2" needed to be change to:
<factor type="double">.5</factor>
<offset type="double">1</offset>

The below worked on FG version 2018.3.2.

  <axis>
    <desc type="string">Mixture All Engines</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/engines/mixture-all</property>
      <factor type="double">1</factor>
      <offset type="double">0</offset>
    </binding>
  </axis>
  <axis n="1">
    <desc type="string">Throttle Engine 0</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/engines/engine[0]/throttle</property>
      <offset type="double">-1.0</offset>
      <factor type="double">-0.5</factor>
    </binding>
  </axis>
  <axis n="2">
    <desc type="string">Throttle Engine 1</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/engines/engine[1]/throttle</property>
      <offset type="double">-1.0</offset>
      <factor type="double">-0.5</factor>
    </binding>
  </axis>

Now the Quadrant will move the throttle levers as they should. The levers and props should follow the levers on the Quadrant. However, you might notice that the throttles do not seem to feel like they are independent to each other when taxing or in the air. There is another adjustment to look into and this is the property throttles-coupled='true'(bool).

In this example, the DC-3 Dakota will need a small edit. The file that needs this edit is named ‘controls.xml’ and it's location can be found at /Aircraft/Douglas-Dc3/Systems/controls.xml. The bellow command will be found near the bottom of this file.

<throttle-coupled type="bool">1</throttle-coupled>

The Boolean value 1 needs to be changed to a 0, as in the below example.

<throttle-coupled type="bool">0</throttle-coupled>

Of course the file needs to be saves. Depending where the file is located, permissions might need to be dealt with.

Honeycomb Aeronautical Alpha Flight Controls - Yoke

The Honeycomb Aeronautical Alpha Flight Controls yoke is a quality flight yoke that works with the Raspberry Pi and FlightGear. The buttons on the yoke are standard normally open, where as the base buttons are normally closed double throw and one five position rotary. The base buttons are odd in that they use two USB Buttons per button. However it might be possible to hack the yoke in order to add nine more buttons. FlightGear is self limited to 32 button, however HID interface will be included in the next version and it will allow an unlimited number of buttons.

The below is being written for the Dakota DC-3, hence there will be some unusual bindings. This is a work in progress and shared for educational purposes.

<?xml version="1.0"?>

<!--
**********************************************************
* Bindings for Honeycomb Aeronautical Alpha Flight Controls - Yoke
*
*
* Axis 0: ailerons
* Axis 1: elevator
* Axes 2 and 3 (hat): view direction
* 
* Button  0: YOKE white-Trigger left-handle
* Button  1: YOKE white-top-Button left-handle
* Button  2: YOKE white-top-Button right-handle
* Button  3: YOKE red-top-Button right-handle
* Button  4: YOKE outer-Rocker down left-handle
* Button  5: YOKE outer-Rocker up left-handle
* Button  6: YOKE inner-Rocker down left-handle 
* Button  7: YOKE inner-Rocker up left-handle 
* Button  8: YOKE top-Rocker inward right-handle
* Button  9: YOKE top-Rocker outward right-handle
* Button 10: YOKE bottom-Rocker inward right-handle
* Button 11: YOKE bottom-Rocker outward right-handle
* Button 12: BASE Master Alternator up
* Button 13: BASE Master Alternator down
* Button 14: BASE Master Battery up
* Button 15: BASE Master Battery down
* Button 16: BASE Avionics Bus1 up
* Button 17: BASE Avionics Bus1 down
* Button 18: BASE Avionics Bus2 up
* Button 19: BASE Avionics Bus2 down
* Button 20: BASE Beacon up
* Button 21: BASE Beacon down
* Button 22: BASE Land up
* Button 23: BASE Land down
* Button 24: BASE Taxi up
* Button 25: BASE Taxi down
* Button 26: BASE Nav up
* Button 27: BASE Nav down
* Button 28: BASE Strobe up
* Button 29: BASE Strobe down
* Button 30: BASE Off
* Button 31: BASE Right Mag
* Button 32: BASE Left Mag
* Button 33: BASE Both Mag
* Button 34: BASE Start
**********************************************************
-->

<PropertyList>
  <name type="string">Honeycomb Aeronautical Alpha Flight Controls</name>

  <axis>
      <desc type="string">Aileron</desc>
      <binding>
          <command>property-scale</command>
          <property>/controls/flight/aileron</property>
          <factor type="double">1</factor>
          <offset type="double">0</offset>
      </binding>
  </axis>

  <axis n="1">
      <desc>Elevator</desc>
      <binding>
          <command>property-scale</command>
          <property>/controls/flight/elevator</property>
          <factor type="double">-1</factor>
          <offset type="double">0</offset>
      </binding>
  </axis>

  <axis n="2">
      <desc>View Direction</desc>
      <direction>left</direction>
      <low>
          <repeatable>true</repeatable>
          <binding>
              <command>nasal</command>
              <script>view.panViewDir(1)</script>
              <module>__js1</module>
              <offset type="double">1</offset>
          </binding>
      </low>
      <high>
          <repeatable>true</repeatable>
          <binding>
              <command>nasal</command>
              <script>view.panViewDir(-1)</script>
              <module>__js1</module>
              <offset type="double">1</offset>
          </binding>
      </high>
  </axis>
  <axis n="3">
      <desc>View Elevation</desc>
      <direction>upward</direction>
      <low>
          <repeatable>true</repeatable>
          <binding>
              <command>nasal</command>
              <script>view.panViewPitch(1)</script>
              <module>__js1</module>
              <offset type="double">1</offset>
          </binding>
     </low>
     <high>
          <repeatable>true</repeatable>
          <binding>
              <command>nasal</command>
              <script>view.panViewPitch(-1)</script>
              <module>__js1</module>
              <offset type="double">1</offset>
          </binding>
      </high>
  </axis>
  <button n="0">
      <desc>View Cycle Forwards</desc>
      <binding>
          <command>nasal</command>
          <script>view.stepView(1);</script>
      </binding>
      <repeatable>0</repeatable>
  </button>

  <button n="1">
      <desc>Reset View</desc>
      <binding>
          <command>nasal</command>
          <script>
              setprop("/sim/current-view/view-number", 0);
              view.resetView()
          </script>
      </binding>
      <repeatable>0</repeatable>
  </button>

  <button n="3">
      <desc>Gear Toggle</desc>
      <binding>
          <command>nasal</command>
          <script>controls.gearToggle(1);</script>
      </binding>
      <repeatable>0</repeatable>
  </button>

  <button n="4">
      <desc>Elevator Trim Up</desc>
      <binding>
          <command>nasal</command>
          <script>controls.elevatorTrim(-1);</script>
      </binding>
      <repeatable>1</repeatable>
  </button>

  <button n="5">
      <desc>Elevator Trim Down</desc>
      <binding>
          <command>nasal</command>
          <script>controls.elevatorTrim(1);</script>
      </binding>
      <repeatable>1</repeatable>
  </button>

  <button n="6">
      <desc>Flaps Down</desc>
      <binding>
          <command>nasal</command>
          <script>controls.flapsDown(1);</script>
      </binding>
      <repeatable>0</repeatable>
  </button>

  <button n="7">
      <desc>Flaps Up</desc>
      <binding>
          <command>nasal</command>
          <script>controls.flapsDown(-1);</script>
      </binding>
      <repeatable>0</repeatable>
  </button>

  <button n="8">
      <desc>Rudder Trim Left</desc>
      <binding>
          <command>nasal</command>
          <script>controls.rudderTrim(-1);</script>
      </binding>
      <repeatable>1</repeatable>
  </button>
  <button n="9">

      <desc>Rudder Trim Right</desc>
      <binding>
          <command>nasal</command>
          <script>controls.rudderTrim(1);</script>
      </binding>
      <repeatable>1</repeatable>
  </button>

  <button n="10">
      <desc>Aileron Trim Left</desc>
      <binding>
          <command>nasal</command>
          <script>controls.aileronTrim(-1);</script>
      </binding>
      <repeatable>1</repeatable>
  </button>

  <button n="11">
      <desc>Aileron Trim Right</desc>
      <repeatable>1</repeatable>
      <binding>
          <command>nasal</command>
          <script>controls.aileronTrim(1);</script>
      </binding>
  </button>


  <button n="12">
      <desc>Instruments ON OFF</desc>
      <repeatable>0</repeatable>
      <binding>
          <command>nasal</command>
          <script>setprop("/controls/lighting/instruments-norm", 0.16)</script>
      </binding>
      <mod-up>
          <binding>
              <command>nasal</command>
              <script type="string">setprop("/controls/lighting/instruments-norm", 0)</script>
          </binding>
      </mod-up>
  </button>

  <button n="14">
      <desc>Battery ON OFF</desc>
      <repeatable>0</repeatable>
      <binding>
          <command>nasal</command>
          <script>setprop("/controls/electric/battery-switch", 1)</script>
      </binding>
      <mod-up>
          <binding>
              <command>nasal</command>
              <script>setprop("/controls/electric/battery-switch", 0)</script>
          </binding>
      </mod-up>
      </button>

  <button n="22">
      <desc>Landing Lights Left and Right ON OFF</desc>
      <repeatable>0</repeatable>
      <binding>
          <command>nasal</command>
          <script>
              setprop("/controls/lighting/landing-lights", 1);
              setprop("/controls/lighting/landing-lights[1]" ,1)
          </script>
      </binding>
      <mod-up>
          <binding>
              <command>nasal</command>
              <script>
              setprop("/controls/lighting/landing-lights", 0);
              setprop("/controls/lighting/landing-lights[1]" ,0)
          </script>
          </binding>
      </mod-up>
  </button>

  <button n="25">
      <desc>Tail Wheel Lock ON OFF</desc>
      <repeatable>0</repeatable>
      <binding>
          <command>nasal</command>
          <script>setprop("/controls/gear/tailwheel-lock", 1)</script>
      </binding>
      <mod-up>
          <binding>
              <command>nasal</command>
              <script>setprop("/controls/gear/tailwheel-lock", 0)</script>
          </binding>
      </mod-up>
  </button>

</PropertyList>

Thrustmaster Flight Rudder Pedals

There could be two adjustments needed for these rudder pedals. The toe brakes are reversed and delete the toe brake center dead band. Use the same method to delete the dead band as in the above throttle quadrant. Do not delete the dead band for the rudder unless that is what you want to do. Below is a calibration data example:

Axis CenterMin CenterMax RangeMin RangeMax
0 511 511 0 1022
1 511 511 0 1022
2 448 574 63 959

Reversing the toe brake direction in FlightGear, using it's joystick dialog box, does't work. The easiest method is to reverse them using jstest-gtk and check the invert box for axes 0 and axes 1.

Depending on the version of FlightGear, there could be a bug where one of the toe brakes do not show up in the FlightGear joystick dialog box. If so this is easy to edit in the configuration file. It might also be beneficial to delete controls that are not part of this rudder pedal so not to produce any conflicts. See below:

  <name type="string">Thrustmaster T-Rudder</name>
  <axis>
    <desc type="string">Brake Right</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/gear/brake-right</property>
      <factor type="double">0.5</factor>
      <offset type="double">1</offset>
    </binding>
  </axis>
  <axis n="1">
    <desc type="string">Brake Left</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/gear/brake-left</property>
      <factor type="double">0.5</factor>
      <offset type="double">1</offset>
    </binding>
  </axis>
  <axis n="2">
    <desc type="string">Rudder</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/flight/rudder</property>
      <factor type="double">1</factor>
      <offset type="double">0</offset>
    </binding>
  </axis>

A much more in-depth study of joystick programming can be found at the below link:

Writing Joystick Code

Compiling

Download_and_compile.sh

Scripted Compilation on Linux Debian/Ubuntu

There can be a complication when using a version of FlightGear that has been built with Download_and_compile.sh. This involves the combination of two situations; the version is being used and changes are being performed to files within the FlightGear build, furthermore the build is being updated at a later time. During updates, Git keeps an eye on any changes too files within this build. Git assumes that you are a software developer, of course this is no problem if you know what you are doing. So if Git sees a change, like to a joystick file, it thinks you are a developer and keeps track of changes. The issue shows up, after changes were performed, when download_and_compile.sh goes to update the FlightGear build. Git gets involved and needs to know how to integrate your changes with the changes from the update performed by download_and_compile.sh. An easy solution is to make a second copy of FlightGear to use and just update the original. Or make a copy of fgdate and use the FlightGear launcher to point to this working/running version of fgdata.

The following was provided by enrogue [1]

I'll just post this here now, I have a successful compile on Debian 10 armhf (via an LXD container on a RK3399 powered Rock960 which runs ubuntu 64bit), and on an RPi3B

I can verify that the build works on the RPi4B 4GB running raspbian & uses just over 1G ram while running - so you *might* be able to squeeze into a 2G Rpi4, but I'm not sure - you probably would have issues doing a -j4 compile on a 2GB one as a couple of the compiles use over 600M per process

The method:

mkdir work

cd work/

git clone https://git.code.sf.net/p/flightgear/fgmeta

mkdir next

cd next

../fgmeta/download_and_compile.sh -j2

*wait a bit..., it will fail on in simgear*

*may as well grab fgdata (depth=1 to keep the download small)*

 cd install/flightgear

git clone --depth=1 git://git.code.sf.net/p/flightgear/fgdata

cd ../..

../fgmeta/download_and_compile.sh -j2 OSG

*it will fail*

*grab the patch*
wget -c https://sources.debian.org/data/main/o/openscenegraph-3.4/3.4.1+dfsg1-5/debian/patches/0007-Explicit-signed-char-type-for-portability-base64.patch

cd openscenegraph/

*patch it*
patch -p1 < ../0007-Explicit-signed-char-type-for-portability-base64.patch

cd ..

*you may have done these configs already*
git config --global user.email "you@example.com"

git config --global user.name "Your Name"

*build OSG*
../fgmeta/download_and_compile.sh -pn -j4 OSG

*build the rest - it will pick up your compiled OSG now*
../fgmeta/download_and_compile.sh -pn -j4

Raspbian

This is not meant to be a fast copy and past compiler method. Below, is meant to be compiling more by learning or understanding. However, there will be plenty of opportunities for copying and pasting.

Must Read

Please read Building Flightgear - Raspbian

Dependencies

Below is a list of dependencies (packages) that need to be installed before compiling.

Package Version (ref. only, as of 03-28-2020) Notes
cmake 3.13.4-1
g++ 4:8.3.0-1+rpi2
git 1:2.20.1-2+deb10u1 Needs a user account at www.github.com
make 4.2.1-1.2
sed 4.7-1
freeglut3-dev 2.8.1-3
libboost-dev 1.67.0.1+b1
libcurl4-openssl-dev 7.64.0-4+deb10u1
libdbus-1-dev 1.12.16-1
libevent-dev 2.1.8-stable-4
libfreetype6-dev 2.9.1-3+deb10u1
libglew-dev 2.1.0-4
libopenal-dev 1:1.19.1-1
libopenscenegraph-3.4-dev 3.4.1+dfsg1-5
libqt5opengl5-dev 5.11.3+dfsg1-1+rpi1+deb10u3
libqt5svg5-dev 5.11.3-2
libssl-dev 1.1.1d-0+deb10u3+rpt1 Needed if building Cmake
libxi-dev 2:1.7.9-1
libxmu-dev 2:1.1.2-2+b3
pkg-config 0.29-6
qml-module-qtquick2 5.11.3-4
qml-module-qtquick-window2 5.11.3-4
qt5-default 5.11.3+dfsg1-1+rpi1+deb10u3
qtbase5-private-dev 5.11.3+dfsg1-1+rpi1+deb10u3
qtdeclarative5-private-dev 5.11.3-4
qttools5-dev 5.11.3-4

The command dpkg -s package_name can be used, in the terminal to verify if a package is installed. Replace 'package_name' with the name of the dependency from the above list.

Before installing any missing dependencies, update Raspbian per the above Update Raspbian instructions. The below terminal command can be used to install any missing dependencies:

sudo apt-get install package_name

git

When using some git commands you might be prompted by git config --global user.email "you@example.com" and or git config --global user.name "Your Name". In that case a user account is needed at www.github.com. So, before starting the compiling process it would be advisable to first go to their web page and create a free user account. After acquiring the user account, use the below commands (one at a time) in order to satisfy the above git requirement. Replace 'you@example.com' with your git account email address and also replace 'Your Name' with the user name for this account. It might be best to choose a user name without a space in it.

git config --global user.email "you@example.com"

git config --global user.name "Your Name"

Link to git configuration and customization information page.

Florent wrote:

I'm not knowledgeable about details of the RaspBerry PI build; what I can say regarding your message is: when you clone a Git repository with no special option such as --bare, some branch is initially checked out (often, this is 'master'). This means that only this particular branch is clearly visible in the directory where the repository has been cloned. Other branches may be present in hidden/machine form inside the .git subdirectory after you do 'git fetch foo', where foo is the name of a branch.

Run 'git branch -r' to see what branches are available remotely, then 'git fetch foo' to retrieve the branch you are interested in (supposedly called 'foo' here). This only happens in the .git subdirectory, but then 'git checkout foo' should cause this branch to appear in the filesystem, replacing whatever was previously checked out in your clone of the upstream repository. In the case of the download_and_compile.sh script, OpenSceneGraph-3.4 is the name of the OSG branch currently used by the script (until a newer version is deemed preferable). Note that as a safety measure, you can't check out a different branch when there is “unfinished work” (things modified but not committed) on the currently checked-out branch.

Hope this helps. Regards

I have to correct something from my first reply in this thread:

The argument passed to 'git fetch' is not branch name (according to the manual, it's a <refspec>). The way I use this command is by passing a remote name, e.g. 'git fetch origin' or 'git fetch upstream'. A “remote” is some place where the repository is hosted that is known to your clone (.git/config). Thus, your clone can fetch branches and commits from remotes. A remote can offer many branches. You can display info about known remotes with 'git remove -v' from within your clone, but I believe this info essentially comes from the .git/config file.

Essential git commands:

  • git status
  • git checkout
  • git pull
    • Can be used to update the fgmeta folder when using the download_and_compile.sh script. Use this command from within the fgmeta folder.
  • git reset --hard
  • git log
    • REVISION example '522c742419e028daf35e79f9c6097ffa34c9f536' (this revision number was found in the FlightGear menu and at flightgear/dnc-managed/build/flightgear/src/Include/build.h. Florent wrote:
      This is a recent FG commit. You can find it with: cd flightgear/dnc-managed/flightgear && git log. Then you can type /522c742419e028daf35e79f9c6097ffa34c9f536 to look for this string in the output (the search string is interpreted as a regular expression) in less, n for next occurrence, N for previous, q to quit (I'm assuming less is your $GIT_PAGER). Or more directly: git show 522c742419e028daf35e79f9c6097ffa34c9f53 in the same dir. Regards
  • git diff

Copy Path(s)

Easy way to copy the path of a file or folder.

During the compiling process there will be times when the path of a file or folder is needed for a Terminal command. One easy GUI short cut is to right click on the file or folder to pull up an option list. Find the option 'Copy Path(s)' and click on it. The path of the file or folder will be copied. Next, in the Terminal, click on 'Edit' at the top of the Terminal window and then click on 'Paste' in order to past the link into the Terminal. See the screen shot to the left.

Location of Files

The SD card performs well for common computer tasks and running FlightGear. However, compiling large programs could wear out the SD card before it's time. This is an excellent application for a SSD drive. Especially if many compiled versions of FlightGear are planned. For that reason this Wiki will choose to compile and install FlightGear on a SSD drive.

This is a good time to create some needed folders on the SSD. For this Wiki the folder FlightGear was created in the root of the SSD. Within this newly created folder FlightGear, create two more folders named fg-install and source. Use your favorite method to navigate and create folders, whether it be the Terminal or GUI. Furthuremore, these files can have other names as long as those other names are globally used.

Build Order

wkitty42 wrote:

"The download_and_compile.sh builds in this order:

PLIB, OSG, SimGear, FlightGear

It updates fgdata between the building of SimGear and FlightGear so that the translations tool can be handled properly..."

Patching

There could come a time when the source needs to be patched before compiling. In this case the patch command can be used along with it's argument -p. For example; the OpenSceneGraph-3.4.0 requires the '0007-Explicit-signed-char-type-for-portability-base64.patch' patch, in order for it to compile for the ARM architecture.

In this example, the patch can be found at this link: OpenSceneGraph-3-4-0 patch. The download link for '0007-Explicit-signed-char-type-for-portability-base64.patch' is what we are looking for. This file can be downloaded with the wget command as seen below:

wget --trust-server-names https://sources.debian.org/src/openscenegraph-3.4/3.4.1+dfsg1-5/src/osgPlugins/osgjs/Base64.cpp/

Place, the above patch file, into the the source root folder of OpenSceneGraph-3-4-0.

The argument ,-p adjusts the path of the patch. Below is an example of a snippet from a patch. Reference the line ,--- openscenegraph-3.4.orig/src/osgDB/ConvertBase64.cpp. The folder openscenegraph-3.4.orig/ can not be used, in our example. In this case, one of the path folders need to be ignored, hence -p1. If two path folders needed to be ignored; -p2.

Index: openscenegraph-3.4/src/osgDB/ConvertBase64.cpp
===================================================================
--- openscenegraph-3.4.orig/src/osgDB/ConvertBase64.cpp
+++ openscenegraph-3.4/src/osgDB/ConvertBase64.cpp
@@ -28,7 +28,7 @@ namespace osgDB
 
     int base64_decode_value(char value_in)
     {
-        static const char decoding[] = {62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51};
+        static const signed char decoding[] = {62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51};
         static const char decoding_size = sizeof(decoding);
         value_in -= 43;
         if (value_in < 0 || value_in > decoding_size) return -1;

Navigate the terminal into the root folder of OpenSceneGraph-3.4.0 source. Side note: the patch command might need to be installed. Now enter the below command into the terminal:

patch -p1 <0007-Explicit-signed-char-type-for-portability-base64.patch

PLIB

Compilation algorithm for PLIB. Directory tree structure
  1. Navigate the Terminal into the source folder.
  2. Enter the below command into the Terminal:
    • git clone git://git.code.sf.net/p/libplib/code libplib.git
      
      • This will copy the needed source files into this folder source.
  3. Enter the below command into the Terminal:
    • cd libplib.git
      
      • This will navigate the Terminal into the folder libplib.git that was created and populated by the git command.
  4. Enter the below command into the Terminal:
    • echo "1.8.6" > version
      
      • This will edit the file 'version' that is in this folder. This file can also be modified with a text editor, even via a GUI.
  5. Enter the below command into the Terminal:
    • sed s/PLIB_TINY_VERSION\ \ 5/PLIB_TINY_VERSION\ \ 6/ -i src/util/ul.h
      
      • This is some complicated version editing.
  6. Enter the below command into the Terminal:
    • git commit --all --message "Increase tiny version to 6."
      
      • More version patching stuff.
  7. Create a folder named build-plib and have it placed in the source folder.
    • The mkdir command or a GUI method can be used to create this folder.
    • In other words; FlightGear/source/build-plib
  8. Navigate the Terminal into the build-plib folder that was just created.
  9. Enter the below command into the Terminal:
    • cmake -D CMAKE_INSTALL_PREFIX:PATH=fg-install libplib.git
      
      • The two folders fg-install and libplib.git need to be replaced with the relative or absolute address of these folders. Use your favorite method.
      • The absolute address can easily be copied and pasted with the above Copy Path(s) method. This could be a large string, however the Terminal doesn't mind.
    • This will setup the build.
  10. Enter the below command into the Terminal:
    • make -j3
      
      • This will perform the compiling.
      • The -j3 argument will allow three of the Pi's cores to participate in the compilation.
  11. Enter the below command into the Terminal:
    • make install
      
      • PLIB will be installed into the fg-install folder.
Storage Device
 |
 |
 |----FlightGear
 |     |
 |     |
 |     |----fg-install
 |     |
 |     |
 |     |
 |     |----source
 |     |     |  [1] [2]
 |     |     |
 |     |     |
 |     |     |----build-plib
 |     |     |     [8] [9] [10] [11]
 |     |     |
 |     |     |
 |     |     |----libplib.git
 |     |     |      [3] [4] [5] [6]
 |     |     |      [7]
 |     |     |
 |     |
 |

OSG

Compilation algorithm for OSG. Directory tree structure

Not done Not done

  1. Navigate the Terminal into the source folder.
  2. Enter the below command into the Terminal:
    • git clone --branch OpenSceneGraph-3.4.0 https://github.com/openscenegraph/OpenSceneGraph.git
      
      • The above is one line.
  3. Patch OSG 3.4 with with the above steps.

Not done Not done


Storage Device
 |
 |
 |----FlightGear
 |     |
 |     |
 |     |----fg-install
 |     |
 |     |
 |     |
 |     |----source
 |     |     |  [1] [2]
 |     |     |
 |     |     |
 |     |     |----OpenSceneGraph
 |     |     |       [3]  
 |     |     |
 |     |     |
 |     |     |----
 |     |     |      
 |     |     |      
 |     |     |
 |     |
 |

Not done Not done

OpenRTI

James wrote: " OpenRTI is optional. If you're using it, you need to compile it before SimGear (and therefore, before FlightGear). It's orthogonal to OSG.

SimGear

Compilation algorithm for SimGear. Directory tree structure
  1. Not done Not done
    • Not done Not done


Storage Device
 |
 |
 |----FlightGear
 |     |
 |     |
 |     |----fg-install
 |     |
 |     |
 |     |
 |     |----source
 |     |     |  
 |     |     |
 |     |     |
 |     |     |----build-plib
 |     |     |     
 |     |     |
 |     |     |
 |     |     |----libplib.git
 |     |     |      
 |     |     |      
 |     |     |
 |     |
 |

Not done Not done

FlightGear

Compilation algorithm for FlightGear. Directory tree structure
  1. Not done Not done
    • Not done Not done


Storage Device
 |
 |
 |----FlightGear
 |     |
 |     |
 |     |----fg-install
 |     |
 |     |
 |     |
 |     |----source
 |     |     |  
 |     |     |
 |     |     |
 |     |     |----build-plib
 |     |     |     
 |     |     |
 |     |     |
 |     |     |----libplib.git
 |     |     |      
 |     |     |      
 |     |     |
 |     |
 |

Not done Not done

FlightGear Data

Install algorithm for FlightGear Data. Directory tree structure
  1. Not done Not done
    • Not done Not done


Storage Device
 |
 |
 |----FlightGear
 |     |
 |     |
 |     |----fg-install
 |     |
 |     |
 |     |
 |     |----source
 |     |     |  
 |     |     |
 |     |     |
 |     |     |----build-plib
 |     |     |     
 |     |     |
 |     |     |
 |     |     |----libplib.git
 |     |     |      
 |     |     |      
 |     |     |
 |     |
 |

Not done Not done

Feature Scaling

Screen Resolution

Raspberry Pi screen layout editor for adjusting screen resolution.

When running FlightGear, using the full screen option, 1024 X 768 resolution works well. Possibly because this is FlightGear's native resolution. In order to choose this resolution go to the Raspbian program menu 'Preferences' and run 'Screen Configuration'. Now right click on the screen that needs to be adjusted to 1024 X 768, on the Screen Layout Editor seen to the right. If using two screens, it might be best to set both screens to the same resolution. Also, it is best to have the two HDMI boxes touching so that the mouse cursor doesn't have a dead spot. Click on the green check to finish.

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

1rightarrow.png See Graphics card profiles for the main article about this subject.

The following GPU profile was provided by enrogue [2]

<?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>

Interfacing

Expanding the flight simulator system beyond the primary Raspberry Pi4, that is running FlightGear, is one way to increase the computing power of such a small computer.

Avare

Avare connected to the Raspberry Pi4 and FlightGear. Avare is a moving aviation chart app.

Avare is a free aviation app, with no ads, that works well with FlightGear. It is an app that is used by many pilots. It will provide a moving map of the FlightGear aircraft, using all FAA charts and a lot more. These charts are for the USA, however some of these FAA Charts cover Puerto Rico, plus parts of Canada, Mexico and the Caribbean. For other parts of the world, there are other apps that might work. Avare can be downloaded from Google Play Store. A tablet is a good choice for running this app.

FlightGear and Avare are easy to bind together. Along with the main Avare app, the I/O app will also need to be installed on the tablet. This app is ‘Avare External I/O Plugin’. The scheme is that the Raspberry Pi4 and FlightGear will become the GPS signal used by the Avare app, this position is transferred via WiFi. So, the tablets internal GPS needs to be OFF. Avare will always prompt you to turn ON the internal GPS, so when asked to ‘Turn On GPS’, choose ‘No’. In ‘Preferances’ the GPS position source can and should be set to ‘Avare IO Module Only’, however the prompt to turn ON the internal GPS will still pop up when starting the app.

The below command tells FlightGear what to connect to and it's protocol. This can be placed in the GFly type programs or if in Terminal, place the command after fgfs. The address, 192.168.??.?, needs to be the address of the tablet running Avare. Some home networks will randomly choose an address, hence this could change. It will be displayed in the IO app. The number 49002 needs to be the same number that is in the Avare IO app. Use the Xplane option.

Comm Comm Type Direction Hertz Machine Address Port Style Protocol
--generic socket out 2 192.168.??.?? 49002 udp avare

The table above helps to explain the command line below.

--generic=socket,out,2,192.168.??.??,49002,udp,avare

After FlightGear has started with the above command, open the Avare External I/O Plugin app. Choose the Xplane option and then tap on ‘Listen’. There should be lines of communication being displayed after ‘Listen’ is enabled. Leave this running and now open the main Avare app. Do not choose to use the internal GPS. Now your FlightGear aircraft placement should be displayed on the FAA map of choice.

Official 7" Touch Screen

The Official 7" Touch Screen for the Raspberry Pi with an external numeric keypad.
Bottom view of the 7" touch screen for the Raspberry Pi.
The Phi PFD displayed on the official Raspberry Pi touch screen.

There is the Official 7” Touch Screen for the Raspberry Pi. This screen will work with a number of different models of the Raspberry Pi’s. There is a case for it (there is no Official case) and the Pi, however the new Pi4 doesn’t fit this case, seen in the photo at the right. This combination does resemble a modern aircraft instrument. There is a new case that will fit the Pi4 and other models, SmartPi Touch 2.

SmartPi Touch 2

Phi will work with almost any device with a browser. In this example the Touch Screen is used with a Raspberry Pi3 B+. There is a screen touch keyboard, however only the numeric keyboard is needed to operate the Radio Stack and the full keyboard doesn’t make efficient use of the screen area. To the right, an external numeric keypad is being used. It makes an interesting combination to touch on screen hot spots and use the external keyboard to input the radio frequencies. A numeric touch screen keypad is being looked into.

Pass the below command to FlightGear, during startup, using your favorite method:

--httpd=8080

In the browser address bar, the one with the 7” Touch Screen, type the below address. Replace the '??' with your numbers. This address needs to be the address of the Raspberry Pi4 that is running FlightGear. Some home networks randomly assign addresses, so when launching FlightGear it is good practice to check the address. To easily find this address, place the mouse cursor on the WiFi/Network icon that is on the top menu bar. It is to the far right.

192.168.??.??:8080

In order to adjust the screen brightness use the below command to write a value into the brightness file. Adjusting the number ‘128’ to a lower value will reduce the brightness of the screen.

sudo sh -c ‘echo “128”>/sys/class/backlight/rpi_backlight/brightness’

Other, less expensive, models of Raspberry Pi’s should also work. As long as it has the port for the Official Touch Screen and can run a browser. There are also third party touch screens on the market. However, purchasing official Raspberry products help to support the Raspberry Foundation promote computer education. Hopefully some of the young budding computer scientists will find value in FlightGear!

64-bit operating system

The Raspberry Pi4 can run FlightGear with a 64-bit OS.

Ubuntu Server

Unofficial distribution of Ubuntu Server 18.04.4 for Raspberry Pi 4.

FlightGear PPA for Raspberry Pi 4.

Cooling

Noctua cooling fan used to cool the Raspberry Pi4 while running FlightGear.

The video core GPU temperature can be read with the use of the terminal and the below command:

vcgencmd measure_temp

The Raspberry Pi4 starts to throttle at 80c, and will be fully throttled when it hits 85. When flying the DC-3 Dakota at a steady cruse altitude, in a low scenery dense area, the core temperature was reported to be ~75c. This was with ambient temperature of ~24c. The temperature rapidly dropped to ~45c when the cooling fan was energized. There was no heat sink installed for this test. FlightGear was running in fullscreen mode on monitor 1 and terminal was running on monitor 2. Screen resolution was possibly 1024 x 768.

The fan in the photo is a Noctua NF-A4x10 5V. It is installed with two rubber bands forming an X. Then the fan is simply sandwiched in the middle of the X. The ends of the rubber bands are looped over the ends of the four standoffs. The rubber bands, in addition to holding the fan, help to isolate vibrational noise. In this setup the fan was powered by an orphaned cell phone charger.

There are also inexpensive heat sink kits. Some opt for no after market cooling options at all, however it has been reported the the Pi4 will self cool the best when placed/mounter in the vertical direction.

Memory

SD Card

For casual running of FlightGear, a quality SD card works well. Look for Class A1 cards. The 'A' is for applications. In addition to a write speed of 10MB/s, these support at least 1500 read operations and 500 write operations per second. Do not use cheap fake SD cards. Interestingly, there is a new tool to test your SD cards. This new tool is called agnostics and can be installed with the below commands:

sudo apt update
sudo apt install agnostics

To learn much more about the SD cards and agnostics, see the below link:

SD Card Speed Test


Hard Drives

Not done Not done
  1. https://forum.flightgear.org/viewtopic.php?f=45&t=36922&start=20
  2. https://forum.flightgear.org/viewtopic.php?f=45&t=36922&p=364937#p364914