Difference between revisions of "NPS"

From PaparazziUAV
Jump to navigation Jump to search
m (moved Booz/Simulator to NPS: this is not really called booz sim anymore....)
(updated for nps, current message names, etc...)
Line 2: Line 2:
__TOC__
__TOC__


Booz contains a sensors model and can use [http://jsbsim.sourceforge.net/ Jsbsim] to allow arbitrarily complex flight dynamic models.
NPS contains a sensors model and can use [http://jsbsim.sourceforge.net/ Jsbsim] to allow fairly complex flight dynamic models.


=== Installation ===
=== Installation ===


[[Installation|Install]] Paparazzi from source.
See [[Installation]] of Paparazzi.


==== JSBSim ====
==== JSBSim ====
You can either install the paparazzi jsbsim package
You can either install the paparazzi-jsbsim package (Debian/Ubuntu)
For Natty and later distros (only works for i386. For amd64, it will install, but give you compile errors, try manual install as below):
  sudo apt-get install paparazzi-jsbsim
  sudo apt-get install paparazzi-jsbsim
For Maverick and earlier distros
'''or''' Compile JSBSIM from source (with specified date to make sure it works and API hasn't changed)
sudo apt-get install jsbsim
   cvs -z3 -d:pserver:anonymous@jsbsim.cvs.sourceforge.net:/cvsroot/jsbsim co -D "12 Jun 2012" -P JSBSim  
'''or''' Compile JSBSIM from the latest source
   cvs -z3 -d:pserver:anonymous@jsbsim.cvs.sourceforge.net:/cvsroot/jsbsim co -P JSBSim  
   cd JSBSim
   cd JSBSim
   ./autogen.sh
   ./autogen.sh
Line 21: Line 18:
   make
   make
   sudo make install
   sudo make install
Remark: I had to download the version dated 2011-07-15, since GetPQRDot() was removed from jsbsim some time ago (Thanks to Dirk Dokter for pointig out this). So you may want to try:
  cvs -z3 -d:pserver:anonymous@jsbsim.cvs.sourceforge.net:/cvsroot/jsbsim co -D20110715 -P JSBSim


Here is an optional ''[[Media:‎Jsbsim silent warnings.patch.gz.jpg|patch]]'' to silent warnings.
Here is an optional ''[[Media:‎Jsbsim silent warnings.patch.gz.jpg|patch]]'' to silent warnings.
Line 34: Line 28:


* Compile the vehicle
* Compile the vehicle
   make AIRCRAFT=BOOZ2_A1 clean_ac sim
   make AIRCRAFT=Quad_LisaM_2 clean_ac nps


===Start Simulation===
===Start Simulation===
Line 44: Line 38:


* Start the sim
* Start the sim
  ./var/BOOZ2_A1/sim/simsitl
  ./var/Quad_LisaM_2/nps/simsitl


You should now see activity in the "messages" window
You should now see activity in the "messages" window
Line 51: Line 45:
start 'plotter' (Real-time plotter from the tool menu of paparazzi center) or with
start 'plotter' (Real-time plotter from the tool menu of paparazzi center) or with
   ./sw/logalizer/plotter
   ./sw/logalizer/plotter
for example drag the label 'int32 phi' from the BOOZ2_FP message to the drawing area of the 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
* Use the datalink to change the tlemetry mode
start 'settings' ( from the tool menu of paparazzi center) or with
start 'settings' ( from the tool menu of paparazzi center) or with
   ./sw/ground_segment/tmtc/settings -ac BOOZ2_A1
   ./sw/ground_segment/tmtc/settings -ac Quad_LisaM_2
start 'server' to dispatch datalink messages ( from the tool menu of paparazzi center) or with
start 'server' to dispatch datalink messages ( from the tool menu of paparazzi center) or with
  ./sw/ground_segment/tmtc/server  
  ./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 "BOOZ2_STAB_ATTITUDE" is received
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
* Use flightgear to visualize your vehicle
Line 68: Line 62:
  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/BOOZ2_A1/sim/simsitl --fg_host 127.0.0.1
   ./var/Quad_LisaM_2/nps/simsitl --fg_host 127.0.0.1


* Save you session
* Save you session
Line 78: Line 72:
   
   
* 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/BOOZ2_A1/sim/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


=== Tunning the attitude control loop ===
=== Tunning the attitude control loop ===
Line 90: Line 84:
* Display two real time plotter windows
* Display two real time plotter windows


In the first one, plot the field "m_phi" from the "BOOZ2_STAB_ATTITUDE" message. This is our estimation of roll angle.
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 "BOOZ2_STAB_ATTITUDE_REFERENCE" message. This is our reference roll angle, that is, the roll value we are trying to achieve.
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 feddback 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 feddback 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.
Line 99: Line 93:
We notice that the vehicle doesn't follow accurately the step trajectory we are trying to make him do.
We notice that the vehicle doesn't follow accurately the step trajectory we are trying to make him do.
   
   
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.
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 ploting the commands, you'll notice that during steps, the feedback command has to work hard. This means that our feedforward command is badly tunned, 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 becomed 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 ploting the commands, you'll notice that during steps, the feedback command has to work hard. This means that our feedforward command is badly tunned, 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 becomed 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.
Line 111: Line 105:
an the sim with
an the sim with


  ./var/BOOZ2_A1/sim/simsitl --fg_host 127.0.0.1 --rc_script 1
  ./var/Quad_LisaM_2/nps/simsitl --fg_host 127.0.0.1 --rc_script 1


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


   ./var/BOOZ2_A1/sim/simsitl --fg_host 127.0.0.1 --js_dev /dev/input/js0
   ./var/Quad_LisaM_2/nps/simsitl --fg_host 127.0.0.1 --js_dev /dev/input/js0


Depending on your joystick it might be mapped to some different device (check with dmesg) or have a look in /dev/input/by-id/<your-joystick>
Depending on your joystick it might be mapped to some different device (check with dmesg) or have a look in /dev/input/by-id/<your-joystick>


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

Revision as of 17:09, 20 June 2012

NPS contains a sensors model and can use Jsbsim to allow fairly complex flight dynamic models.

Installation

See Installation of Paparazzi.

JSBSim

You can either install the paparazzi-jsbsim package (Debian/Ubuntu)

sudo apt-get install paparazzi-jsbsim

or Compile JSBSIM from source (with specified date to make sure it works and API hasn't changed)

 cvs -z3 -d:pserver:anonymous@jsbsim.cvs.sourceforge.net:/cvsroot/jsbsim co -D "12 Jun 2012" -P JSBSim 
 cd JSBSim
 ./autogen.sh
 ./configure --enable-libraries --enable-shared --prefix=/opt/jsbsim
 make
 sudo make install

Here is an optional patch to silent warnings.

Compilation

  • Compile paparazzi
 cd paparazzi
 make
  • Compile the vehicle
 make AIRCRAFT=Quad_LisaM_2 clean_ac nps

Start Simulation

  • Start paparazzi_center if you want click to start programs
./paparazzi
  • Start messages to monitor the middleware activity ( from the tool menu of paparazzi center) or with
./sw/ground_segment/tmtc/messages 
  • Start the sim
./var/Quad_LisaM_2/nps/simsitl

You should now see activity in the "messages" window

  • Plot the value of a message field.

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

If you want a view of a quadrotor in flightgear, make a link from /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 flighgear with

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
  • Save you session

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

Tunning the attitude control loop

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

  • Restart your previous session
  • Set telemetry mode to "Att 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 feddback 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 accurately the step trajectory we are trying to make him do.

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 ploting the commands, you'll notice that during steps, the feedback command has to work hard. This means that our feedforward command is badly tunned, 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 becomed 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.

 ./var/Quad_LisaM_2/nps/simsitl --fg_host 127.0.0.1 --js_dev /dev/input/js0

Depending on your joystick it might be mapped to some different device (check with dmesg) or have a look in /dev/input/by-id/<your-joystick>