Difference between revisions of "Simulation"
Corybarton (talk | contribs) |
m (Added hint to use of the gazibo optinn) |
||
(74 intermediate revisions by 19 users not shown) | |||
Line 1: | Line 1: | ||
<categorytree style="float:right; clear:right; margin-left:1ex; border: 1px solid gray; padding: 0.7ex;" mode=pages>Simulation</categorytree> | |||
__TOC__ | |||
This page describes the steps needed to run a simulated flight with an UAS. | |||
== Available Simulators == | |||
* ''' | |||
Paparazzi currently has two different simulator targets with different degrees of realism and intended purpose: | |||
# '''sim''': The basic fixedwing simulator written in OCaml without IMU simulation or any sensor models (noise, bias, etc) and mainly intended to validate your [[Flight_Plans|flight plan]] logic. | |||
# '''nps''': [[NPS]] is a more advanced rotorcraft and fixedwing simulator with sensor models and commonly uses [[JSBSim]] as FDM ('''F'''light '''D'''ynamic '''M'''odel). Other FDM's can be integrated easily. At the moment CRRCSIM, YASIM and JSBSIM are tried as FDM backend. | |||
# '''gazebo''': [[gazebo]] . There is someting brand new developed going, using laters '''Master''' you can start using the Gazebo engine in Paparazzi. Take a look on that page to see if it offers what you are looking for. | |||
A FDM is a set of mathematical equations used to calculate the physical forces acting on a simulated aircraft, such as thrust, lift, and drag. | |||
== Compiling and starting == | |||
'''This describes the basic fixedwing sim, for rotorcraft or advanced fixedwing simulation, see [[NPS]].''' | |||
From the [[Paparazzi_Center|Paparazzi Center]] select the Microjet 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 | |||
three processes which are listed in the window below: | |||
* '''Microjet''' is the interface of a simulator program. It runs the same code as 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. | ||
* ''' | * '''Server''' is a hidden process which won't be described here (see [[Overview|the architecture of the system]]) | ||
== Start the Simulation == | == 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. If you omit the -boot option of the sim the aircraft is not automatically booted and you can first place the aircraft where you want it to start from and then boot. | |||
If the --norc option is ommited, a window for a virtual remote control (including on/off switch and a mode-switch) is started, see: [https://wiki.paparazziuav.org/wiki/Joystick#Virtual_Joystick_.28only_for_SIM_targets.29 Virtual Joystick] | |||
The lower part of the GCS displays the flight plan in a tree view. You see that the current flight plan is composed of | In the GCS the map widget is able to 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 the top right corner of 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 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 == | == Fly == | ||
In the Simulator ('''Microjet''' 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 <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. | |||
=== 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'''. | |||
[[file:PPRZ_Environment_settings_Gaia_GUI_up.png]] | |||
This interface, also known as '''Gaia''', allows the user to change: | |||
* The time-scale: This make the simulation of the flight speed up time, good if you have a extensive flightpland and you do not want to wait the real time it would taketo fly the aircraft in a real life flight. It is best not use a times-cale higher than 2x for a first tryout. | |||
* The Wind speed: Set the wind speed while simulating. Try to set it to e.g. 5m/s and observe the trajectory and the speed evolution in the aircraft strip and in the '''PFD''' page of the notebook | |||
* The Wind direction: Set the direction the wind comse from. For fun try to take of with stong wind from the side. | |||
* Wind up: Simulates updraft (e.g. by thermals) or downdraft wind (beside thunderstorms or in mountains), which could e.g. shift the UAS higher than permitted, which can be counteracted by exceptions in the flightplan. | |||
* A GPS failure: Simulate GPS loss on the aircraft ('''GPS OFF''') and observe the resulting mode ('''NO_GPS''') and trajectory. In this mode, the autopilot can for example use a 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 it's position ... The simulation is cheating here! It must, otherwise not possible to show the path in the simulator ofcourse. | |||
Environment Simulator, Gaia can also be started with initial values set by command line option. | |||
-b Bus Default is 127.255.255.255:2010 | |||
-t Set time scale (default: 1.0) | |||
-w Set wind speed (0-30m/s) | |||
-d Set wind direction 0-359 deg | |||
-g Turn off GPS | |||
-help Display this list of options | |||
--help Display this list of options | |||
If you are in the testfield and forgot the parameters, just use the "help" | |||
$ ./gaia --help | |||
This make testing more convienient since on can save a session with this parameters and on restart imidately have the same settings again. | |||
=== Example === | |||
Starting gaia with the following parameters on the command line: | |||
$ sw/simulator/gaia -t 3 -d 340 -w 11 | |||
This sets a 3x speedup of the time with wind coming from 340 degrees with a windspeed of 11m/s | |||
== | == Other navigation patterns == | ||
Using the buttons in the strip, you can play with other navigation patterns: figure of eights, oval, survey of a rectangle (with a north-south sweeping), ''Circle 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''') | |||
== | == Multiple UAV Simulation == | ||
To simulate multiple aircrafts, you just have to launch a second simulator (tools->simulator, then -a yourairframe) and the server and the GCS should take care of the rest. | |||
== View the simulation in Flight Gear == | == View the simulation in Flight Gear == | ||
To view the simulation in | To view the simulation in [[FlightGear]], do the following: | ||
* In Paparazzi Center, add the - | * [[FlightGear|install Flight Gear]] | ||
/ | * In Paparazzi Center, add the option <tt>--fg_host 127.0.0.1</tt> (replace the IP address if FG is running on another host as appropriate) to the Simulator line and restart it, e.g.: | ||
<path_to_paparazzi>/sw/simulator/pprzsim-launch --aircraft <your_ac_name> -t sim --boot --norc --fg_host 127.0.0.1 | |||
<div class="toccolours mw-collapsible mw-collapsed"> | |||
Prior to '''v5.0''' launchsitl was used instead of pprzsim-launch. Click expand to see the details. | |||
<div class="mw-collapsible-content"> | |||
<path_to_paparazzi>/sw/simulator/launchsitl -a <your_ac_name> -boot -norc -fg 127.0.0.1 | |||
</div></div> | |||
* Launch Flight Gear with the following command: | * Launch Flight Gear with the following command: | ||
fgfs --fdm=null --native-gui=socket,in,30,,5501,udp | fgfs --fdm=null --native-gui=socket,in,30,,5501,udp | ||
=== | === Old version === | ||
For Flight Gear visualization, version 2.12 or greater with rembrand visualisation options switched on is the nicest. If you wish to use a very old version, Flightgear v2.4 or lower, you must add the following to the firmware section of your airframe file: | |||
{{Box Code|conf/airframes/myplane.xml| | |||
<source lang="xml"> | |||
<firmware name="fixedwing or rotorcraft"> | |||
... | |||
<define name="FG_2_4" value="1"/> | |||
... | |||
</firmware> | |||
</source> | |||
}} | |||
=== Obtain Screenshots from FlightGear into PaparazziUAV === | |||
One can write a relatively simple module in order to obtain screenshots of the FlightGear world into the PaparazziUAV software. This can be useful to simulate low fidelity computer vision tasks with UAVs. The module requires libcurl and libpng to make the screenshot data available to PaparazziUAV. Detailed instructions are available in [[Load Screenshots from FlightGear]]. | |||
[[Category:Simulation]] [[Category:Software]] [[Category:User_Documentation]] | |||
Latest revision as of 01:00, 6 February 2018
This page describes the steps needed to run a simulated flight with an UAS.
Available Simulators
Paparazzi currently has two different simulator targets with different degrees of realism and intended purpose:
- sim: The basic fixedwing simulator written in OCaml without IMU simulation or any sensor models (noise, bias, etc) and mainly intended to validate your flight plan logic.
- nps: NPS is a more advanced rotorcraft and fixedwing simulator with sensor models and commonly uses JSBSim as FDM (Flight Dynamic Model). Other FDM's can be integrated easily. At the moment CRRCSIM, YASIM and JSBSIM are tried as FDM backend.
- gazebo: gazebo . There is someting brand new developed going, using laters Master you can start using the Gazebo engine in Paparazzi. Take a look on that page to see if it offers what you are looking for.
A FDM is a set of mathematical equations used to calculate the physical forces acting on a simulated aircraft, such as thrust, lift, and drag.
Compiling and starting
This describes the basic fixedwing sim, for rotorcraft or advanced fixedwing simulation, see NPS.
From the Paparazzi Center select the Microjet aircraft (from the A/C combo box) which is configured with the basic.xml flight plan. From the Target combo box, select sim and 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:
- Microjet is the interface of a simulator program. It runs the same code as 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. If you omit the -boot option of the sim the aircraft is not automatically booted and you can first place the aircraft where you want it to start from and then boot.
If the --norc option is ommited, a window for a virtual remote control (including on/off switch and a mode-switch) is started, see: Virtual Joystick
In the GCS the map widget is able to 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 the top right corner of 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 (Microjet 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 known as Gaia, allows the user to change:
- The time-scale: This make the simulation of the flight speed up time, good if you have a extensive flightpland and you do not want to wait the real time it would taketo fly the aircraft in a real life flight. It is best not use a times-cale higher than 2x for a first tryout.
- The Wind speed: Set the wind speed while simulating. Try to set it to e.g. 5m/s and observe the trajectory and the speed evolution in the aircraft strip and in the PFD page of the notebook
- The Wind direction: Set the direction the wind comse from. For fun try to take of with stong wind from the side.
- Wind up: Simulates updraft (e.g. by thermals) or downdraft wind (beside thunderstorms or in mountains), which could e.g. shift the UAS higher than permitted, which can be counteracted by exceptions in the flightplan.
- A GPS failure: Simulate GPS loss on the aircraft (GPS OFF) and observe the resulting mode (NO_GPS) and trajectory. In this mode, the autopilot can for example use a 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 it's position ... The simulation is cheating here! It must, otherwise not possible to show the path in the simulator ofcourse.
Environment Simulator, Gaia can also be started with initial values set by command line option.
-b Bus Default is 127.255.255.255:2010 -t Set time scale (default: 1.0) -w Set wind speed (0-30m/s) -d Set wind direction 0-359 deg -g Turn off GPS -help Display this list of options --help Display this list of options
If you are in the testfield and forgot the parameters, just use the "help"
$ ./gaia --help
This make testing more convienient since on can save a session with this parameters and on restart imidately have the same settings again.
Example
Starting gaia with the following parameters on the command line:
$ sw/simulator/gaia -t 3 -d 340 -w 11
This sets a 3x speedup of the time with wind coming from 340 degrees with a windspeed of 11m/s
Using the buttons in the strip, you can play with other navigation patterns: figure of eights, oval, survey of a rectangle (with a north-south sweeping), Circle 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)
Multiple UAV Simulation
To simulate multiple aircrafts, you just have to launch a second simulator (tools->simulator, then -a yourairframe) and the server and the GCS should take care of the rest.
View the simulation in Flight Gear
To view the simulation in FlightGear, do the following:
- install Flight Gear
- In Paparazzi Center, add the option --fg_host 127.0.0.1 (replace the IP address if FG is running on another host as appropriate) to the Simulator line and restart it, e.g.:
<path_to_paparazzi>/sw/simulator/pprzsim-launch --aircraft <your_ac_name> -t sim --boot --norc --fg_host 127.0.0.1
Prior to v5.0 launchsitl was used instead of pprzsim-launch. Click expand to see the details.
<path_to_paparazzi>/sw/simulator/launchsitl -a <your_ac_name> -boot -norc -fg 127.0.0.1
- Launch Flight Gear with the following command:
fgfs --fdm=null --native-gui=socket,in,30,,5501,udp
Old version
For Flight Gear visualization, version 2.12 or greater with rembrand visualisation options switched on is the nicest. If you wish to use a very old version, Flightgear v2.4 or lower, you must add the following to the firmware section of your airframe file:
File: conf/airframes/myplane.xml |
<firmware name="fixedwing or rotorcraft">
...
<define name="FG_2_4" value="1"/>
...
</firmware>
|
Obtain Screenshots from FlightGear into PaparazziUAV
One can write a relatively simple module in order to obtain screenshots of the FlightGear world into the PaparazziUAV software. This can be useful to simulate low fidelity computer vision tasks with UAVs. The module requires libcurl and libpng to make the screenshot data available to PaparazziUAV. Detailed instructions are available in Load Screenshots from FlightGear.