Difference between revisions of "Simulation"

From PaparazziUAV
Jump to navigation Jump to search
Line 1: Line 1:
This page describes the steps needed to run a flight simulation from a new install.
This page describes the steps needed to run a flight simulation.


== Initializing a New Installation ==  
==Compiling and starting==
<tt>paparazzi-make init</tt>
to initialize your configuration files (in the <tt>~/paparazzi</tt> directory)
and then
<tt>paparazzi-make demo</tt>
If you are working in the <tt>paparazzi3</tt> source code, just start with <tt>make demo</tt>.


A '''control panel''' window is opened. Under the '''Sessions''' menu, choose '''Muret Sim''' ([http://maps.google.com/maps?f=q&hl=en&q=Muret,+France&ie=UTF8&om=1&z=13&iwloc=A Muret] is a village near Toulouse, France). This spawns several programs :
From the [[Paparazzi_Center|Paparazzi Center]] select the MJ5 aircraft (from the '''A/C''' combo box) which is configured with the <tt>basic.xml</tt> flight plan. From the '''Target''' combo box, select <tt>sim</tt>and click the '''Build''' button to compile the airbone code to be run on your Linux box. From the '''Session''' combo box, select <tt>Simulation</tt> entry and click '''Execute''' to start the simulation. It will start
* '''Aircraft MJ5''' is the interface of a simulator program. It runs the same code than the one for the autopilot processor plus a rudimentary flight dynamic model. it allows you to test the interactions with the UAV and the flight plan execution.
three processes which are listed in the window below:
* '''cockpitMM MJ5''' is a representation of a radio control transmitter used with this aircraft. It allows you to test the interactions available through that device.
* '''MJ5''' is the interface of a simulator program. It runs the same code than the one for the autopilot processor plus a rudimentary flight dynamic model. it allows you to test the interactions with the UAV and the flight plan execution.
* '''GCS''' ([[GCS|Ground Control Station]]) is the main window. It displays the track of the aircraft, as well as informations about the execution of its flight plans. This program provide menus for the datalink functions and is able to edit a flight plan.
* '''GCS''' ([[GCS|Ground Control Station]]) is the main window. It displays the track of the aircraft, as well as informations about the execution of its flight plans. This program provide menus for the datalink functions and is able to edit a flight plan.
* '''Gaia''' is the interface of the world simulator. It will distribute time ticks to the aircrafts simulator and allow acces to global parameters like wind, temperature used by the infrared sensor, and GPS coverage.
* '''Server''' is a hidden process which won't be described here (see [[Overview|the architecture of the system]])


== Start the Simulation ==
== Start the Simulation ==


Click the '''Boot''' button on the aircraft window. This boots your aircraft, as if you were powering the autopilot. The aircraft starts to send messages to the ground station. Its position and its flight parameters are displayed in the GCS window.
The aircraft has automatically been booted, as if the autopilot board had been powered. Its position and its flight parameters are displayed in the GCS window.


The map widget is able use many map formats and display them according to many projections. To make things simple, we start by using images from [http://maps.google.com Google]. Under the '''Maps''' menu in the GCS, choose '''GoogleMaps Fill'''. The program attempts to download the required satellite images from the Google servers. If it succeeds, you should now see the nice countryside of Muret. Navigation and other features of the map are described on the [[GCS#map|GCS]] page.
The map widget is able use many map formats and display them according to many projections. To make things simple, we start by using images from [http://maps.google.com Google]. From the toolbar in theUnder the GCS, click the Google Earth icon ('''Google maps fill'''). The program attempts to download the required satellite images from the Google servers. If it succeeds, you should now see the nice countryside of Muret (a city close to Toulouse, France). Navigation and other features of the map are described on the [[GCS#map|GCS]] page.


The lower part of the GCS displays the flight plan in a tree view. You see that the current flight plan is composed of four ''blocks'':
The lower part of the GCS displays the flight plan in a tree view. You see that the current flight plan is composed of several ''blocks'':
* '''survey road 1'''
* '''wait GPS''' and '''geo init''' which are instructions to run this flight plan anywhere in the world, by translating the waypoints around the current location of aircraft as soon as it is reported by the GPS.
* '''survey road 2'''
* '''Holding point''' (it  should be the current active block) which instructs the autopilot to wait for launch. 
* '''wait'''
* '''Takeoff''' which will instruct the aircraft to climb full throttle to a security altitude
* '''go too far'''
* '''Standby''' which is a simple circle around the '''STDBY''' waypoint.
Open the active block: the active ''stage'' in the block is highlighted.
 
Switch to the '''Takeoff''' block by a double click on the line or using the corresponding button (an icon figuring an airway) on the left side of the strip.


== Fly ==
== Fly ==


<tt><block name="survey road 1">
In the Simulator ('''MJ5''' window), press the '''Launch''' button to simulate a hand launch or click the launch button in the GCS (the green aircraft icon). The autopilot detects the launch by monitoring the groundspeed. The flight time (in the aircraft label on the GCS) then starts to count.
  <go wp="road_start"/>
  <go wp="road_end"/>
</block></tt>


This block is about the simplest you can write. It flies the aircraft to waypoint '''road_start''', then to waypoint '''road_end'''. The vertical control mode is unspecified and defaults to '''altitude hold'''. Being unspecified, the target altitude is the waypoint's one (250m for these two waypoints).
Position of the aircraft is displayed on the map: the aircraft goes to the '''CLIMB''' waypoint (to the norht-west) and then around the '''STDBY''' waypoint. Current block also changes accordingly in the flight plan display.


In the Simulator, press the '''Launch''' button to simulate a hand launch. The autopilot detects the launch by monitoring the groundspeed. The flight time (in the aircraft label on the GCS) then starts to count.
The orange triangle (the carrot) on the map is the point that the aircraft is navigating toward.


Position of the aircraft is displayed on the map: the aircraft goes to the '''road_start''' waypoint (to the west) and then to the '''road_end''' waypoint (to the east). Current stage also changes accordingly in the flight plan display.
== Line ==


The orange triangle (the carrot) on the map is the point that the aircraft is navigating toward. The aircraft proceeds through the two waypoints then proceeds on to the next block.
Jump to this block with double-click on the <tt>Line 1-2</tt> line in the flight plan or using the corresponding button in the strip (figuring a blue line between two white points). The aircraft will try to follow a line joining the waypoints '''1''' and '''2''', doing nice U-turns at both ends.


== Fly forever ==
=== Move waypoints ===


<tt><while cond="TRUE">
While the aircraft is flying (or here while the simulator is integrating differential equations), you can move the waypoints on the GCS interface by cliking and dragging (with the left button). When the mouse button is released, a popup window allows you to change the altitude of the waypoint. After validation, the waypoint changes are sent to the autopilot and the followed track is changed accordingly.
  <go wp="road_start" from="road_end" hmode="route"/>
  <go wp="road_end" from="road_start" hmode="route"/>
</while></tt>


This block is not much more complicated than the previous one. It shows another horizontal mode which is named '''route'''. The aircraft returns to waypoint '''road_start''' and then proceeds to '''road_end''' staying on the line between the waypoints. It is displayed on the map by a green line where the target point (the orange triangle) is moving along.
=== Coming back around ===


The two <tt>go</tt> stages are here inserted into a <tt>while</tt> element with an ever-true condition: the aircraft loops forever between the two waypoints.
Select the '''Standby''' block (the ''home'' blue icon) to instruct the aircraft to fly around the '''STDBY''' waypoint.


== Fly too far ==


== Circle ==
If you unzoom the map (using the PageDown key or he mouse wheel), you will see a large circle around the waypoints. This circle show the allowed flying zone that the autopilot must not leave or it will enter an emergency navigation mode and circles the '''HOME''' waypoint until the further direction is received.


<tt><block name="circle">
Move the waypoint '''2''' out of this circle (close to the circle in the north-east corner) and switch back to the 'Line 1-2''' block to force the plane to get out of this safety zone.
  <circle wp="road_end" ALT="ground_alt+50" radius="75"/>
</block></tt>


Jump to this block with double-click on the <tt>block</tt> line (or using the '''MJ5''' aircraft menu, '''Datalink''', '''Jump to block''', '''circle'''). The aircraft circles clockwise around the '''road_end''' waypoint.
The aircraft flies to the '''2''' waypoint, cross the protection enveloppe and switches to ''home'' mode: the AP mode in the aircraft strip switches from '''AUTO2''' to '''HOME'''.


== Fly too far ==
To get out of this mode and switch back to the default '''AUTO2''', click on the '''AUTO2''' button in the aircraft strip. The aircraft then flies again towards '''too far''' and again swithes to '''HOME''' mode.


<tt>go wp="too far"
== Change the environment ==
circle wp="too far" radius="50"</tt>


This block is here to demonstrate the ''home mode'' feature of the autopilot. The navigation system has a an allowed zone that it must not leave or it will enter an emergency navigation mode and circles the '''HOME''' waypoint until the further direction is received. This safety zone is displayed as a circle on the map.
Launch the '''Environment Simulator''' from the '''Tools' menu in the '''Paparazzi Center'''.


Jump to this block by double-cliking on it.
This interface (also called'''Gaia''') allows the user to change:
 
* The wind: Set up a wind speed of 5m/s and observe the trajectory and the speed evolution (in the aircraft strip and in the '''PFD''' page of the notebook).
The aircraft flies to the '''too far''' waypoint, cross the protection enveloppe and switches to ''home'' mode: the AP mode in the aircraft strip switches from '''AUTO2''' to '''HOME'''.
* The GPS coverage: Shut down the GPS ('''GPS OFF''') and observe the resulting mode ('''NO_GPS''') and trajectory. In this mode, the autopilot uses the failsafe roll, pitch and throttle settings defined in the airframe file. Note that in a real flight, an aircraft without GPS won't be able to send its position ... The simulation is cheating here !
 
* The time scale: If you are in a hurry ... Do not use a time higher than 2 for this first demonstration.
To get out of this mode and switch back to the default '''AUTO2''', click on the '''AUTO2''' button in the aircraft strip. The aircraft then flies again towards '''too far''' and again swithes to '''HOME''' mode.


== Move the waypoint ==
== Other navigation patterns ==


Waypoints are moveable during flight: You can left-click and drag the '''too far''' waypoint inside the blue safety circle. Get out of the '''HOME''' mode ('''AUTO2''' button) and the aircraft will go circling around the now not '''too far''' waypoint.
Using the buttons in the strip, you can play with other navigation patterns: eigh figure, oval, survey of a rectangle (with a north-south sweeping), ''Turn around here'' (which sets a waypoint to the current location of the plane and flies a circle around).


Click on the '''too far''' waypoint; A dialog box pops up. You can change the altitude of the waypoin by editing it with the keyboard or using the '''-10''' and '''+10''' buttons. CLick '''Ok''' and '''Send WPs'''. You can look at the altitude change in the aircraft strip.
== Landing ==


You now can survey the line you want with the '''survey road 2''' block by moving the two waypoints. You can move them while the aircraft is flying from one to the other and the line will be updated in real-time.
To automatically land the aircraft:
* Set the '''TD''' (Touch Down) waypoint where you want to land. Be sure that the waypoint is on the ground (185m in Muret)
* Set the '''AF''' (Approach Fix) waypoint where you want to start the final descent (the ''glide''). If you have set some wind with Gaia, you probably want to fly '''AF-TD''' upwind (an estimation of the wind experienced by the aircraft is displayed in the left-upper corner of the map).
* Switch to the '''Land right''' or the '''Land left''' block (icons in the strip) according to the direction of the last turn you want to do (for example, if '''AF''' is on the east side of '''TD''' and you want to maneuvre from the north, choose a '''Land right''')


== Change the environment ==
The '''Gaia''' interface allows the user to change:
* The wind: Set up a wind speed of 5m/s and observe the trajectory and the speed evolution (in the aircraft strip and in the '''PFD''' page of the notebook).
* The GPS coverage: Shut down the GPS ('''GPS OFF''') and observe the resulting mode ('''NO_GPS''') and trajectory. In this mode, the autopilot uses the failsafe roll, pitch and throttle settings defined in the airframe file. Note that in a real flight, an aircraft without GPS won't be able to send its position ... The simulation is cheating here !
* The time scale: If you are in a hurry ... (bug: adjusting the time scale may affect the navigation behavior)


== View the simulation in Flight Gear ==
== View the simulation in Flight Gear ==

Revision as of 10:06, 18 April 2009

This page describes the steps needed to run a flight simulation.

Compiling and starting

From the Paparazzi Center select the MJ5 aircraft (from the A/C combo box) which is configured with the basic.xml flight plan. From the Target combo box, select simand click the Build button to compile the airbone code to be run on your Linux box. From the Session combo box, select Simulation entry and click Execute to start the simulation. It will start three processes which are listed in the window below:

  • MJ5 is the interface of a simulator program. It runs the same code than the one for the autopilot processor plus a rudimentary flight dynamic model. it allows you to test the interactions with the UAV and the flight plan execution.
  • GCS (Ground Control Station) is the main window. It displays the track of the aircraft, as well as informations about the execution of its flight plans. This program provide menus for the datalink functions and is able to edit a flight plan.
  • Server is a hidden process which won't be described here (see the architecture of the system)

Start the Simulation

The aircraft has automatically been booted, as if the autopilot board had been powered. Its position and its flight parameters are displayed in the GCS window.

The map widget is able use many map formats and display them according to many projections. To make things simple, we start by using images from Google. From the toolbar in theUnder the GCS, click the Google Earth icon (Google maps fill). The program attempts to download the required satellite images from the Google servers. If it succeeds, you should now see the nice countryside of Muret (a city close to Toulouse, France). Navigation and other features of the map are described on the GCS page.

The lower part of the GCS displays the flight plan in a tree view. You see that the current flight plan is composed of several blocks:

  • wait GPS and geo init which are instructions to run this flight plan anywhere in the world, by translating the waypoints around the current location of aircraft as soon as it is reported by the GPS.
  • Holding point (it should be the current active block) which instructs the autopilot to wait for launch.
  • Takeoff which will instruct the aircraft to climb full throttle to a security altitude
  • Standby which is a simple circle around the STDBY waypoint.

Switch to the Takeoff block by a double click on the line or using the corresponding button (an icon figuring an airway) on the left side of the strip.

Fly

In the Simulator (MJ5 window), press the Launch button to simulate a hand launch or click the launch button in the GCS (the green aircraft icon). The autopilot detects the launch by monitoring the groundspeed. The flight time (in the aircraft label on the GCS) then starts to count.

Position of the aircraft is displayed on the map: the aircraft goes to the CLIMB waypoint (to the norht-west) and then around the STDBY waypoint. Current block also changes accordingly in the flight plan display.

The orange triangle (the carrot) on the map is the point that the aircraft is navigating toward.

Line

Jump to this block with double-click on the Line 1-2 line in the flight plan or using the corresponding button in the strip (figuring a blue line between two white points). The aircraft will try to follow a line joining the waypoints 1 and 2, doing nice U-turns at both ends.

Move waypoints

While the aircraft is flying (or here while the simulator is integrating differential equations), you can move the waypoints on the GCS interface by cliking and dragging (with the left button). When the mouse button is released, a popup window allows you to change the altitude of the waypoint. After validation, the waypoint changes are sent to the autopilot and the followed track is changed accordingly.

Coming back around

Select the Standby block (the home blue icon) to instruct the aircraft to fly around the STDBY waypoint.

Fly too far

If you unzoom the map (using the PageDown key or he mouse wheel), you will see a large circle around the waypoints. This circle show the allowed flying zone that the autopilot must not leave or it will enter an emergency navigation mode and circles the HOME waypoint until the further direction is received.

Move the waypoint 2 out of this circle (close to the circle in the north-east corner) and switch back to the 'Line 1-2 block to force the plane to get out of this safety zone.

The aircraft flies to the 2 waypoint, cross the protection enveloppe and switches to home mode: the AP mode in the aircraft strip switches from AUTO2 to HOME.

To get out of this mode and switch back to the default AUTO2, click on the AUTO2 button in the aircraft strip. The aircraft then flies again towards too far and again swithes to HOME mode.

Change the environment

Launch the Environment Simulator from the Tools' menu in the Paparazzi Center.

This interface (also calledGaia) allows the user to change:

  • The wind: Set up a wind speed of 5m/s and observe the trajectory and the speed evolution (in the aircraft strip and in the PFD page of the notebook).
  • The GPS coverage: Shut down the GPS (GPS OFF) and observe the resulting mode (NO_GPS) and trajectory. In this mode, the autopilot uses the failsafe roll, pitch and throttle settings defined in the airframe file. Note that in a real flight, an aircraft without GPS won't be able to send its position ... The simulation is cheating here !
  • The time scale: If you are in a hurry ... Do not use a time higher than 2 for this first demonstration.

Other navigation patterns

Using the buttons in the strip, you can play with other navigation patterns: eigh figure, oval, survey of a rectangle (with a north-south sweeping), Turn around here (which sets a waypoint to the current location of the plane and flies a circle around).

Landing

To automatically land the aircraft:

  • Set the TD (Touch Down) waypoint where you want to land. Be sure that the waypoint is on the ground (185m in Muret)
  • Set the AF (Approach Fix) waypoint where you want to start the final descent (the glide). If you have set some wind with Gaia, you probably want to fly AF-TD upwind (an estimation of the wind experienced by the aircraft is displayed in the left-upper corner of the map).
  • Switch to the Land right or the Land left block (icons in the strip) according to the direction of the last turn you want to do (for example, if AF is on the east side of TD and you want to maneuvre from the north, choose a Land right)


View the simulation in Flight Gear

To view the simulation in Flight Gear, do the following:

  • In Paparazzi Center, add the -fg option plus the IP address of the machine running flightgear:
/home/your_username/paparazzi/paparazzi3/sw/simulator/launchsitl -a TJ1 -fg 127.0.0.1 -boot -norc
  • Launch Flight Gear with the following command:
fgfs --fdm=null --native-gui=socket,in,30,,5501,udp

Why is it night in Flight Gear, if my sim is flying during the day?

The time that is sent to Flight Gear is hard coded into the code, so if you try to view the output of the simulation and your simulated flight is located far from France, in Flight Gear, everything may be dark. If your simulated flight is in France, then you will always have daylight in Flight Gear. To fix this, do the following (you will need to have paparazzi-dev installed to do this):

  • Get the Unix time during your local daylight hours by running the following command in your terminal:
date +%s
  • In the file: paparazzi3/sw/simulator/fg.c find the line(line 44):
msg.cur_time = 3213092700ul;//time(NULL);
  • Paste the output from "date +%s" in place of "3213092700"
  • Now you will have to rebuild paparazzi, so in the terminal change to the paparazzi3 directory and run:
make clean
make
  • In Paparazzi Center clean and rebuild your simulation
  • Launch the simulation and Flight Gear, and Flight Gear should be flying in daylight.