Difference between revisions of "NPS"

From PaparazziUAV
Jump to navigation Jump to search
(first attempt at cleaning up...)
Line 2: Line 2:
__TOC__
__TOC__


NPS contains a sensors model and can use [http://jsbsim.sourceforge.net/ Jsbsim] as FDM (FlightDynamicModel) to allow fairly complex models.
NPS is our advanced rotorcraft simulator with a sensor models and uses [[JSBSim]] as FDM (FlightDynamicModel) to allow fairly complex airframes.
Other FDMs can be integrated easily.
JSBSim can easily be replaced by the FDM of your choice.


=== Installation ===
Fixedwing support can also be easily added as soon as someone actually wants to use it ;-)
 
== Installation ==


See [[Installation|installation of Paparazzi]], [[JSBSim]] and optionally [[FlightGear]].
See [[Installation|installation of Paparazzi]], [[JSBSim]] and optionally [[FlightGear]].


==== Compilation ====
=== Configuration/Build ===


* Compile paparazzi
Build the nps target...
  cd paparazzi
  make


* Compile the vehicle
== Running the Simulation ==
  make AIRCRAFT=Quad_LisaM_2 clean_ac nps
Since paparazzi version ''v4.9_devel-425'' the most convenient way to start the simulation is via the ''Simulation'' session from the [[Paparazzi Center]].
Just select e.g. the Quad_LisaM_2 example airframe and start the ''Simulation'' session.


===Start Simulation===
In earlier versions, start your tools (e.g. [[GCS]], [[server]] and messages) separately, then launch the nps simulator for your aircraft:
* Start paparazzi_center if you want click to start programs
<source lang="bash">./var/Quad_LisaM_2/nps/simsitl</source>
./paparazzi


* Start messages to monitor the middleware activity ( from the tool menu of paparazzi center) or with
=== Pausing or running the sim at a different speed ===
./sw/ground_segment/tmtc/messages
You can pause the simulation with ''CTRL-z'' in the terminal. You can then enter a different time factor (default 1.0) to make the simulation run slower or faster than real-time. Hit enter to resume the simulation or ''CTRL-z'' again to suspend it like any normal Unix process (use the ''fg'' (foreground) command to un-suspend it again).


* Start the sim
=== Use a Joystick ===
./var/Quad_LisaM_2/nps/simsitl
You can use a [[joystick]] (or connect your RC transmitter as a joystick) to control the quad in the simulator.
<source lang="bash">./var/Quad_LisaM_2/nps/simsitl -j</source>
or, with a specific device index (0 is default):
<source lang="bash">./var/Quad_LisaM_2/nps/simsitl --js_dev 0</source>


You should now see activity in the "messages" window
Joystick support uses the Simple DirectMedia Layer (SDL) library. Rather than specifying an input device name as one normally does on Linux, you just supply an index value (0, 1, 2,...) of the device you wish to use. Typically, the order of devices is the order in which you plugged them into your computer. The sim will display the name of the device being used to double check. If the <tt>-j</tt> option is used with no argument, the sim defaults to using device on index 0 (which is usually correct if you have only one joystick attached).


* Plot the value of a message field.
Also see [[Joystick#Calibration]].
start 'plotter' (Real-time plotter from the tool menu of paparazzi center) or with
  ./sw/logalizer/plotter
for example drag the label 'int32 phi' from the ROTORCRAFT_FP message to the drawing area of the plotter
 
 
* Use the datalink to change the tlemetry mode
start 'settings' ( from the tool menu of paparazzi center) or with
  ./sw/ground_segment/tmtc/settings -ac Quad_LisaM_2
start 'server' to dispatch datalink messages ( from the tool menu of paparazzi center) or with
./sw/ground_segment/tmtc/server
change the field "telemetry" on the first page to "Att loop" and send by pressing the green check button. The label on the left or the drop box should change to "Att loop" confirming your essage has been received. "message" should now show that the message "STAB_ATTITUDE_INT" is received


* Use [[FlightGear]] to visualize your vehicle
=== Visualization in [[FlightGear]] ===
If you want a view of a quadrotor in flightgear, make a link from
[[FlightGear#Installation|Install]] and [[FlightGear#Using_FlightGear_for_Visualization|start flightgear]], e.g. with a quadrotor model:
/usr/share/games/flightgear/Models/Aircraft/paparazzi to PAPARAZZI_SRC/conf/simulator/flightgear/
  sudo ln -s $PAPARAZZI_SRC/conf/simulator/flightgear/ /usr/share/games/flightgear/Models/Aircraft/paparazzi
start flightgear with
  fgfs --fdm=null --native-gui=socket,in,30,,5501,udp --prop:/sim/model/path=Models/Aircraft/paparazzi/mikrokopter.xml
  fgfs --fdm=null --native-gui=socket,in,30,,5501,udp --prop:/sim/model/path=Models/Aircraft/paparazzi/mikrokopter.xml
restart your simulator with
restart your simulator with
  ./var/Quad_LisaM_2/nps/simsitl --fg_host 127.0.0.1
  ./var/Quad_LisaM_2/nps/simsitl --fg_host 127.0.0.1


* Save you session
=== Troubleshooting ===
 
==== Troubleshooting ====
* If you get an error like "JSBSim failed to open the configuration file: (null)/conf/simulator/jsbsim/aircraft/BOOZ2_A1.xml", you need to set your $PAPARAZZI_SRC and $PAPARAZZI_HOME environment variables. Add the following to your .bashrc, change paths according to where you put Paparazzi. Open a new terminal and launch the sim again.
* If you get an error like "JSBSim failed to open the configuration file: (null)/conf/simulator/jsbsim/aircraft/BOOZ2_A1.xml", you need to set your $PAPARAZZI_SRC and $PAPARAZZI_HOME environment variables. Add the following to your .bashrc, change paths according to where you put Paparazzi. Open a new terminal and launch the sim again.
  export PAPARAZZI_SRC=~/paparazzi
  export PAPARAZZI_SRC=~/paparazzi
  export PAPARAZZI_HOME=~/paparazzi
  export PAPARAZZI_HOME=~/paparazzi
 
* If you did not install the jsbsim package your JSBSim installation under /opt/jsbsim will be used and you will have to set your library path (either in your shell startup file or when running the sim on the command line), e.g.:
* If you did not install the jsbsim package your JSBSim installation under /opt/jsbsim will be used and you will have to set your library path (either in your shell startup file or when running the sim on the command line), e.g.:
  LD_LIBRARY_PATH=/opt/jsbsim/lib ./var/Quad_LisaM_2/nps/simsitl --fg_host 127.0.0.1
LD_LIBRARY_PATH=/opt/jsbsim/lib ./var/Quad_LisaM_2/nps/simsitl --fg_host 127.0.0.1
 
== Usage Examples ==
 
=== Plot the value of a message field ===
Start the [[RTPlotter|real-time plotter]] tool menu of [[Paparazzi Center]] or with
<source lang="bash">./sw/logalizer/plotter</source>
for example drag the label 'int32 phi' from the ROTORCRAFT_FP message to the drawing area of the plotter
 
* Use the datalink to change the telemetry mode
start 'settings' ( from the tool menu of paparazzi center) or with
  ./sw/ground_segment/tmtc/settings -ac Quad_LisaM_2
start 'server' to dispatch datalink messages ( from the tool menu of paparazzi center) or with
./sw/ground_segment/tmtc/server
change the field "telemetry" on the first page to "Att loop" and send by pressing the green check button. The label on the left or the drop box should change to "Att loop" confirming your message has been received. "message" should now show that the message "STAB_ATTITUDE_INT" is received


=== Pausing or running the sim at a different speed ===
You can pause the simulation with ''CTRL-z'' in the terminal. You can then enter a different time factor (default 1.0) to make the simulation run slower or faster than real-time. Hit enter to resume the simulation or ''CTRL-z'' again to suspend it like any normal Unix process (use the ''fg'' (foreground) command to un-suspend it again).


=== Tuning the attitude control loop ===
=== Tuning the attitude control loop ===
Here we are going to use the simulator to demonstrate a way of tuning the attitude control loop.
Here we are going to use the simulator to demonstrate a way of tuning the attitude control loop.


* Restart your previous session
* Restart your previous session
* Set telemetry mode to "attitude_loop"
* Set telemetry mode to "attitude_loop"
* Display two real time plotter windows
* Display two real time plotter windows


Line 79: Line 75:


In the second plotter, plot the fields "delta_a_fb" and "delta_a_ff". Those are respectively the feedback and feedforward part of our roll command. The sum of those two terms is what is used as roll command.The feedforward part is the part used to follow our trajectory and the feedback part is the part used to reject perturbations.
In the second plotter, plot the fields "delta_a_fb" and "delta_a_ff". Those are respectively the feedback and feedforward part of our roll command. The sum of those two terms is what is used as roll command.The feedforward part is the part used to follow our trajectory and the feedback part is the part used to reject perturbations.


* In "Settings", go to the "Att Loop" tab
* In "Settings", go to the "Att Loop" tab
Line 88: Line 83:
If you look at the plotter where you're plotting the commands, you'll notice that during steps, the feedback command has to work hard. This means that our feedforward command is badly tuned, and namely not working hard enough. Increase the value of the feedforward gain ('ddgain p') from 300 to 540. You'll notice that now the feedback command has become marginal during the steps. This is the right value for the gain. Anything bigger will make the feedback command fight against the feedforward command during steps, anything smaller will make the feedback command have to complement the feedforward command.
If you look at the plotter where you're plotting the commands, you'll notice that during steps, the feedback command has to work hard. This means that our feedforward command is badly tuned, and namely not working hard enough. Increase the value of the feedforward gain ('ddgain p') from 300 to 540. You'll notice that now the feedback command has become marginal during the steps. This is the right value for the gain. Anything bigger will make the feedback command fight against the feedforward command during steps, anything smaller will make the feedback command have to complement the feedforward command.


=== Something else ===
* try starting flightgear with
fgfs --fdm=null --native-gui=socket,in,30,,5501,udp --prop:/sim/model/path=Models/Aircraft/paparazzi/simple_bipe.xml
an the sim with
./var/Quad_LisaM_2/nps/simsitl --fg_host 127.0.0.1 --rc_script 1
== Use a Joystick ==
You can use a [[joystick]] (or connect your RC transmitter as a joystick) to control the quad in the simulator.
<source lang="bash">./var/Quad_LisaM_2/nps/simsitl --fg_host 127.0.0.1 -j</source>
or, with a specific device index (0 is default):
<source lang="bash">./var/Quad_LisaM_2/nps/simsitl --fg_host 127.0.0.1 --js_dev 0</source>
Joystick support uses the Simple DirectMedia Layer (SDL) library. Rather than specifying an input device name as one normally does on Linux, you just supply an index value (0, 1, 2,...) of the device you wish to use. Typically, the order of devices is the order in which you plugged them into your computer. The sim will display the name of the device being used to double check. If the <tt>-j</tt> option is used with no argument, the sim defaults to using device on index 0 (which is usually correct if you have only one joystick attached).


[[Category:Simulation]] [[Category:Software]] [[Category:User_Documentation]]
[[Category:Simulation]] [[Category:Software]] [[Category:User_Documentation]]

Revision as of 09:26, 24 January 2013

NPS is our advanced rotorcraft simulator with a sensor models and uses JSBSim as FDM (FlightDynamicModel) to allow fairly complex airframes. JSBSim can easily be replaced by the FDM of your choice.

Fixedwing support can also be easily added as soon as someone actually wants to use it ;-)

Installation

See installation of Paparazzi, JSBSim and optionally FlightGear.

Configuration/Build

Build the nps target...

Running the Simulation

Since paparazzi version v4.9_devel-425 the most convenient way to start the simulation is via the Simulation session from the Paparazzi Center. Just select e.g. the Quad_LisaM_2 example airframe and start the Simulation session.

In earlier versions, start your tools (e.g. GCS, server and messages) separately, then launch the nps simulator for your aircraft:

./var/Quad_LisaM_2/nps/simsitl

Pausing or running the sim at a different speed

You can pause the simulation with CTRL-z in the terminal. You can then enter a different time factor (default 1.0) to make the simulation run slower or faster than real-time. Hit enter to resume the simulation or CTRL-z again to suspend it like any normal Unix process (use the fg (foreground) command to un-suspend it again).

Use a Joystick

You can use a joystick (or connect your RC transmitter as a joystick) to control the quad in the simulator.

./var/Quad_LisaM_2/nps/simsitl -j

or, with a specific device index (0 is default):

./var/Quad_LisaM_2/nps/simsitl --js_dev 0

Joystick support uses the Simple DirectMedia Layer (SDL) library. Rather than specifying an input device name as one normally does on Linux, you just supply an index value (0, 1, 2,...) of the device you wish to use. Typically, the order of devices is the order in which you plugged them into your computer. The sim will display the name of the device being used to double check. If the -j option is used with no argument, the sim defaults to using device on index 0 (which is usually correct if you have only one joystick attached).

Also see Joystick#Calibration.

Visualization in FlightGear

Install and start flightgear, e.g. with a quadrotor model:

fgfs --fdm=null --native-gui=socket,in,30,,5501,udp --prop:/sim/model/path=Models/Aircraft/paparazzi/mikrokopter.xml

restart your simulator with

./var/Quad_LisaM_2/nps/simsitl --fg_host 127.0.0.1

Troubleshooting

  • If you get an error like "JSBSim failed to open the configuration file: (null)/conf/simulator/jsbsim/aircraft/BOOZ2_A1.xml", you need to set your $PAPARAZZI_SRC and $PAPARAZZI_HOME environment variables. Add the following to your .bashrc, change paths according to where you put Paparazzi. Open a new terminal and launch the sim again.
export PAPARAZZI_SRC=~/paparazzi
export PAPARAZZI_HOME=~/paparazzi
  • If you did not install the jsbsim package your JSBSim installation under /opt/jsbsim will be used and you will have to set your library path (either in your shell startup file or when running the sim on the command line), e.g.:
LD_LIBRARY_PATH=/opt/jsbsim/lib ./var/Quad_LisaM_2/nps/simsitl --fg_host 127.0.0.1

Usage Examples

Plot the value of a message field

Start the real-time plotter tool menu of Paparazzi Center or with

./sw/logalizer/plotter

for example drag the label 'int32 phi' from the ROTORCRAFT_FP message to the drawing area of the plotter

  • Use the datalink to change the telemetry mode

start 'settings' ( from the tool menu of paparazzi center) or with

 ./sw/ground_segment/tmtc/settings -ac Quad_LisaM_2

start 'server' to dispatch datalink messages ( from the tool menu of paparazzi center) or with

./sw/ground_segment/tmtc/server 

change the field "telemetry" on the first page to "Att loop" and send by pressing the green check button. The label on the left or the drop box should change to "Att loop" confirming your message has been received. "message" should now show that the message "STAB_ATTITUDE_INT" is received


Tuning the attitude control loop

Here we are going to use the simulator to demonstrate a way of tuning the attitude control loop.

  • Restart your previous session
  • Set telemetry mode to "attitude_loop"
  • Display two real time plotter windows

In the first one, plot the field "m_phi" from the "STAB_ATTITUDE_int" message. This is our estimation of roll angle. On top of that, plot the field "phi" from the "STAB_ATTITUDE_REF_INT" message. This is our reference roll angle, that is, the roll value we are trying to achieve.

In the second plotter, plot the fields "delta_a_fb" and "delta_a_ff". Those are respectively the feedback and feedforward part of our roll command. The sum of those two terms is what is used as roll command.The feedforward part is the part used to follow our trajectory and the feedback part is the part used to reject perturbations.

  • In "Settings", go to the "Att Loop" tab

We notice that the vehicle doesn't follow the step trajectory we are trying to make him do accurately.

Start by setting the value of the proportional gain ('pgain_phi') to 1000 instead of 400. The vehicle now follows the trajectory faster but overshoots. To prevent that, increase the value of the derivative gain ('dgain p') from 300 to 700.

If you look at the plotter where you're plotting the commands, you'll notice that during steps, the feedback command has to work hard. This means that our feedforward command is badly tuned, and namely not working hard enough. Increase the value of the feedforward gain ('ddgain p') from 300 to 540. You'll notice that now the feedback command has become marginal during the steps. This is the right value for the gain. Anything bigger will make the feedback command fight against the feedforward command during steps, anything smaller will make the feedback command have to complement the feedforward command.