Home Robotics Pilot UAV.How to make a barrel properly

Pilot UAV.How to make a barrel properly

by admin

What do a fighter jet with a liquid storage container and a Goldberg machine have in common? It would seem only that the airplane and the barrel might be parts of a useless but mesmerizing mechanism, but no.The barrel flight figure combines all of these things and more.
Pilot UAV.How to make a barrel properly
Performing a barrel roll in no way helps a civilian aircraftto take its passengers to their destination or a fighter in combat, but requires, if done correctly, engaging all of the aircraft’s controls: ailerons, elevator, and rudder.
This publication outlines the process of turning an airplane 360 degrees around its longitudinal axis without descending in terms of a science such as flight dynamics, and provides a description of how you can get your airplane to do a barrel rollproperly.

Introduction

After completing the active phase of another project, a drone colleague and I had a question about what to do before new projects took up all our free time. In response to the question posed to the void, we got a very specific answer of "make a barrel ( do a barrel roll )". It’s true : the barrel roll is a Goldberg machine in aviation, both a complex, practically (in aerial combat) useless and aesthetically pleasing aerobatic figure. So why not teach an airplane model to do a barrel roll in automatic mode, even Google makes it.
Before we started the practical implementation, we decided to study this process using computer models, and this is what came out of it.

A bit of theory

First, a little about why airplanes fly and how an airplane’s position is described relative to the gravitational field. The airplane is held in the air by the lifting force, let’s call it Y, which is created on the wing, but here’s the thing, this force appears only when the wing is blown by an incoming airflow, so you need to accelerate the airplane accordingly. You can, of course, "run up and jump off a cliff", spend part of the potential energy of the gravitational field of the earth on acceleration and even hover for a moment, but inseparable from the lifting force arises aerodynamic resistance, let us call this force X, which will brake the plane, and lifting force will fall, and with it, we. We will fall under the force of gravity G. All normal airplanes have an engine to counteract the drag force, it creates a thrust force P, which can be used to overcome the drag force. The simplest kinematic model of an airplane describes its motion as the movement of a material point in the field of gravity of the earth. In horizontal flight at constant velocity, gravity is balanced by wing lift Y = G and drag force by engine thrust X = P.
If we look at a material point under a microscope, it turns into a material body. It is for the best: we can see the fuselage, the wing, the tail, which consists of a horizontal stabilizer and a vertical keel. There are ailerons on the left and right wing consoles, an elevator on the horizontal tail, and a rudder on the vertical tail. If you rotate all of these intensely, the vehicle will start to maneuver, and the task of making a barrel comes down to what law to change the position of the controls to achieve the necessary trajectory of the vehicle in space and relative to its own axes.
Description of coordinate systems used in describing the motion of aircraft. In the Russian/Soviet tradition, a coordinate system (CS) rigidly related to the aircraft is introduced as follows. The x-axis is directed longitudinally in the plane of symmetry of the aircraft, from the tail to the nose. Perpendicular to this axis in the upward direction, the y-axis is introduced. These two axes are complemented to the right triple vector by the z axis. It turns out that the z-axis will pass along the right wing.
The movement of a vehicle in space cannot be described using only the coordinate system associated with the aircraft, because we are interested in the position of the vehicle relative to the ground. For this purpose, a coordinate system called the "local earth coordinate system" is introduced. The X-axis of this system is in the horizontal plane and points to geographic north. The Y axis points vertically upward. The Z axis completes them to the right triple vector. The location of the associated coordinate system relative to the local earth system is determined by the roll, pitch and yaw angles. The angle between the aircraft’s longitudinal axis (in our case, the x-axis of the linked SK) and the horizontal plane XZ is called the pitch angle, and changes as the rudder deviates. The angle between the z-axis of the linked SC and the Z-axis of the local terrestrial SC, rotated so that the yaw angle is zero, is called the roll angle, it changes with aileron deviation. The angle between the X axis of the local terrestrial SC and the projection of the x axis of the associated SC onto the horizontal plane XZ is called the yaw angle, and is counted counterclockwise from the X axis of the local terrestrial SC. This formalization should be sufficient for us to describe the motion of the aircraft when doing a barrel roll, and even though, we will not use the axis letter designations further on, it is always useful to repeat the basics.
Pilot UAV.How to make a barrel properly

Toolkit

To simulate vehicle motion, we use the toolkit provided by the open-source aircraft dynamics simulation software JSBSim Plotting output is trusted gnuplot and visualization of aircraft maneuvers FlightGear As a basic dynamic model, let’s take a fighter jet North American P-51 Mustang : its maneuverability will be enough to do a barrel roll. For visualization we will use the less aggressive, sporty plane YAK-53
Description of the process of setting up the program and the output of the results. All the files you need to run the scripts are on Github repositories To replicate the steps in the article, we will need to install JSBSim , FlightGear and gnuplot All the steps will be given for the Windows operating system. I will use the following instruction from here Download and install the latest version FlightGear with www.flightgear.org and gnuplot with www.gnuplot.info Collecting JSBSim at instructions After that, we look for the two directories we need. The root directories are JSBSim. and FlightGear In the catalog FlightGeardataAircraft are the folders with the aircraft models: there you copy the model you want to use for the visualization. I use the model Yak-53 I found on the Internet. Other models can be found here In the catalog FlightGearbin is the main executable file of the simulator fgfs To visualize the dynamics we will use the startup line

fgfs --native-fdm=socket, in, 60, , 5500, tcp --fdm=external --timeofday=noon --aircraft=Yak-53 --disable-sound --disable-real-weather-fetch --disable-clouds3d --disable-clouds

In this line, the first parameters indicate the external source of aircraft dynamics data when the simulator is started. The parameter aircraft defines the required model of the aircraft. The other parameters are optional, their values can be found here Useful keyboard shortcuts :
"V" -change model view
Shift+Esc – Restarting FlightGearwith command line parameters saved
Ctrl+"R" – Starts the flight recording to repeat what you got.
That’s actually all we need in the simulator FlightGear Let’s go back to the dynamics simulator JSBSim In the catalog JSBSimaircraft contains dynamic models of airplanes. In the catalog JSBSimengine contains dynamic models of engines and propellers. The dynamic models of planes are stored in separate directories in files like name*.xml At the end of each file there is a section that is responsible for the type of simulation output. If we want the output to be in a form suitable for visualization in FlightGear , it should look like this :

<output name="localhost" type="FLIGHTGEAR" port="5500" rate="60"/>

If we want to save the data to a file, then :

<output name="p51d.csv" rate="60" type="CSV"><property> velocities/vc-kts </property><property> aero/alphadot-deg_sec </property><property> aero/betadot-deg_sec </property><property> fcs/throttle-cmd-norm </property><simulation> OFF </simulation><atmosphere> OFF </atmosphere><massprops> OFF </massprops><aerosurfaces> ON </aerosurfaces><rates> ON </rates><velocities> ON </velocities><forces> OFF </forces><moments> OFF </moments><position> ON </position><coefficients> OFF </coefficients><ground_reactions> OFF </ground_reactions><fcs> ON </fcs><propulsion> OFF </propulsion></output>

It is convenient to start the simulation process by means of a batch file located in the root folder JSBSim with the line

JSBtest.bat *script name

containing

rem Remove the old result filedel /Q aircraftp51dResults%1.csvrem Run the testDebugJSBSim--script=aircraftp51dscripts%1.xml --outputlogfile=aircraftp51dResults%1.csv> JSBSim.out --realtimerem Generate gnuplot to the screengnuplot aircraftp51dplots%1.p

This file deletes previous simulation results, runs the script located at JSBSimaircraftp51dscripts , and then runs gnuplot to draw the resulting data. Parameter realtime should be set when the data from JSBSim wants to receive data in real time, e.g., when visualizing in FlightGear
Let’s look at the contents of the script file :

<?xml version="1.0" encoding="utf-8"?><runscript><use aircraft="p51d" initialize="scripts/airborne"/><run start="0" end="5" dt="0.0166666"><!--Trim the vehicle for horizontal flight--><event name="Trims"><condition> sim-time-sec ge 0.0 </condition><set name="simulation/do_simple_trim" value="1"/></event><!--Deflect ailerons to maximum--><event><condition> sim-time-sec ge 0.5 </condition><set name="fcs/aileron-cmd-norm"value="1"/></event><!--Return aileron to original position--><event><condition> sim-time-sec ge 2.95 </condition><set name="fcs/aileron-cmd-norm"value="0"/></event></run></runscript>

For proper startup, the third line specifies the model of the aircraft to be modeled and the path to the initialization file containing

<?xml version="1.0" encoding="utf-8"?><initialize name="airborne"><!--A file with the initial parameters of the device status--><running> -1 </running><altitude unit="FT"> 325.0 </altitude><vc unit="KTS"> 210.0 </vc><latitude unit="DEG"> 42.3769 </latitude><longitude unit="DEG"> -70.9993 </longitude></initialize>

All that remains is to consider the contents of the graphing file through gnuplot :

set autoscale # scale axes automaticallyunset log # remove any log-scalingunset label # remove any previous labelsset xtic auto # set xtics automaticallyset ytic auto # set ytics automaticallyset tics font "Arial, 16"set key font "Arial, 16"set xlabel font "Arial, 16"set ylabel font "Arial, 16"# If you have graphical capabilities, you can plot on your screen# if none of the other terminals is specificed.# This is how to output the plot in PostScriptformat#set terminal postscript portrait enhanced color lw 1 "Helvetica" 14 size 8.5, 11# This is how to output the plot in PNGformat#set terminal png size 1280, 960#set output "aircraft/p51d/results/plot.png"# This is how to output the plot in PDFformat. (Not available on Mac)#set terminal pdfcairo color size 8.5, 11#set output " aircraft/p51d/results/plot.pdf"set multiplot title ""set size 1, 0.30set lmargin 10set xrange [0:4]set ytic autoset origin 0.0, 0.00set xlabel "Time, s"set ylabel"Height, m"plot "aircraft/p51d/results/trim-cruisep51d.csv" using 1:($43*0.3048) title "" with linesset origin 0.0, 0.33set ylabel "Pitch angle, °"set xlabel""plot "aircraft/p51d/results/trim-cruisep51d.csv" using 1:33 title "" with linesset origin 0.0, 0.66set ylabel "Roll angle, °"set xlabel""set yrange [-180:180]set ytics 60plot "aircraft/p51d/results/trim-cruisep51d.csv" using 1:32 title "" with linesunset multiplot # exit multiplot modepause -1 "Press ENTER to continue"

This file generates and displays three graphs: roll, pitch and altitude vs. time. The plotting data is taken from the file *script_name.csv By the way, imperial units are converted to our usual metric units. You can change the file to output the following formats PostScript , PNG or PDF by uncommenting the appropriate lines.
That’s pretty much the whole process of preparing the tools for modeling and displaying airplane movement on your own.

Simulation and results

If we imagine a "spherical", or rather an ideal airplane with the axes of the coupled coordinate system coinciding with the major axes of the ellipsoid of inertia and the controls creating moments each relative to only one of the axes, we can understand at a qualitative level how the machine will move when the controls are deflected. Suppose an airplane is flying in horizontal flight; by deflecting ailerons in opposite directions, we change the amount of lift force on the wing consoles, which results in a momentum of forces about the x-axis, and the machine will start to rotate around that axis. To do a barrel roll this is exactly what we need. We make a script where the ailerons are deflected maximally for 2.45 seconds and then return to the initial position:
Script content.

<?xml version="1.0" encoding="utf-8"?><runscript><use aircraft="p51d" initialize="scripts/airborne"/><run start="0" end="5" dt="0.0166666"><!--Trim the vehicle for horizontal flight--><event name="Trims"><condition> sim-time-sec ge 0.0 </condition><set name="simulation/do_simple_trim" value="1"/></event><!--Deflect ailerons to maximum--><event><condition> sim-time-sec ge 0.5 </condition><set name="fcs/aileron-cmd-norm"value="1"/></event><!--Return aileron to original position--><event><condition> sim-time-sec ge 2.95 </condition><set name="fcs/aileron-cmd-norm"value="0"/></event></run></runscript>

Pilot UAV.How to make a barrel properly
The results of the simulation are shown in the graph :
Pilot UAV.How to make a barrel properly
You can see that the plane turned 360 degrees on the roll, however, did this maneuver with a 40 meter descent and tilted the nose 14 degrees – this is an example of not a good barrel at all.
And it is true, if we remember that the plane from afar is a material point, then as it rotates, the projection of the lifting force on the direction of gravity decreases and the plane begins to descend, and we do not need this at all, because we want to perform a nice barrel roll without descending. To do this, before we start deflecting ailerons, we need to create a reserve of vertical speed. You take the wheel, the elevator deflects, and a torque is created relative to the z-axis. The nose of the plane rises and we begin to gain altitude – at this point it’s time to start rotation. We add to the script a deflection of the elevator by 40 percent 0.4 seconds before aileron deflection starts and return it to neutral. By 0.2 seconds before roll ends, take the wheel fully back, to avoid dropping the nose of the plane:
Script content.

<?xml version="1.0" encoding="utf-8"?><runscript><use aircraft="p51d" initialize="scripts/airborne"/><run start="0" end="5" dt="0.0166666"><!--Trim the vehicle for horizontal flight--><event name="Trims"><condition> sim-time-sec ge 0.0 </condition><set name="simulation/do_simple_trim" value="1"/></event><!--Tilt altitude rudder "towards"--><event><condition> sim-time-sec ge 0.1 </condition><set name="fcs/elevator-cmd-norm"value="-0.4"/></event><!--Deflect aileron to maximum.Return elevator to neutral.--><event>;<condition> sim-time-sec ge 0.5 </condition><set name="fcs/aileron-cmd-norm"value="1"/><set name="fcs/elevator-cmd-norm" value="0"/></event><!--Tilting the elevator "towards"--><event><condition> sim-time-sec ge 2.75 </condition><set name="fcs/elevator-cmd-norm"value="-1"/></event><!--Return aileron to neutral positionReturn elevator pitch control to neutral position.--><event>;<condition> sim-time-sec ge 2.95 </condition><set name="fcs/aileron-cmd-norm"value="0"/><set name="fcs/elevator-cmd-norm" value="0"/></event></run></runscript>

Pilot UAV.How to make a barrel properly
Let’s see what happens :
Pilot UAV.How to make a barrel properly
Here it is, a pretty decent, fast barrel roll. If we had put the elevator back in neutral a little later, the plane would have gained a little altitude and would have turned after aileron deflection. The combination of "steering back" and "aileron deflection" causes the lifting force of the wing to act along the normal to the current trajectory of the vehicle and curves it the more deflected the elevator is. You can try it for yourself and see for yourself.
The previous barrel roll was performed without descending, and the pitch angle at the exit from the barrel was not very different from the initial one. However, the altitude changed by 12 meters in the process. Let’s try to apply the controls more actively in order to minimize altitude overshoot during the performance of the figure. So that you don’t just turn the controls on the plane randomly, let’s look at Wikipedia and see how we are recommended to do a barrel roll. The basic idea behind doing a perfect barrel roll is to keep the longitudinal axis of the airplane in the horizontal plane. To do this, the elevator and rudder are used alternately. At the beginning of the barre, as usual, we use elevator to gain vertical speed. Deflect ailerons and start rotation. When the plane turns around its longitudinal axis the elevator and the rudder of the direction change places. When the roll angle reaches about 90 degrees the deflection of the rudder will raise or lower the nose of the airplane in the vertical plane. Therefore, deflect the rudder so as to prevent the nose from lowering. Then, when the roll angle reaches 180 degrees, you need to deflect the rudder away from yourself to keep the nose of the airplane in the horizontal plane in inverted flight. As you turn further, you repeat the deflection of the rudder with the opposite sign at a roll angle close to – 90 degrees and complete the barrel with a slight deviation of the elevator "towards yourself". All these steps are expressed in the script below :
Script content.

<?xml version="1.0" encoding="utf-8"?><runscript><use aircraft="p51d" initialize="scripts/airborne"/><run start="0" end="10" dt="0.0166666"><!--Trim the vehicle for horizontal flight--><event name="Trims"><condition> sim-time-sec ge 0.0 </condition><set name="simulation/do_simple_trim" value="1"/></event><!--Tilt altitude rudder "towards"--><event><condition> sim-time-sec ge 0.0 </condition><set name="fcs/elevator-cmd-norm"value="-0.05"/></event><!--Deflect aileron at maximum--><event><condition> sim-time-sec ge 0.5 </condition><set name="fcs/aileron-cmd-norm"value="1"/></event><!--Return altitude rudder to neutral position--><event><condition> sim-time-sec ge 0.6 </condition><set name="fcs/elevator-cmd-norm"value="0"/></event><!--Deflect the directional rudder--><event><condition> sim-time-sec ge 1.4 </condition><set name="fcs/rudder-cmd-norm"value="0.7"/></event><!--Return directional rudder to neutral position--><event><condition> sim-time-sec ge 1.6 </condition><set name="fcs/rudder-cmd-norm"value="0"/></event><!--Tilt altitude rudder "away"--><event><condition> sim-time-sec ge 1.65 </condition><set name="fcs/elevator-cmd-norm"value="0.5"/></event><!--Return altitude rudder to neutral position--><event><condition> sim-time-sec ge 2.35 </condition><set name="fcs/elevator-cmd-norm"value="0"/></event><!--Tilting the rudder to the opposite side--><event><condition> sim-time-sec ge 2.6 </condition><set name="fcs/rudder-cmd-norm"value="-1.0"/></event><!--Return directional rudder to neutral position--><event><condition> sim-time-sec ge 2.8 </condition><set name="fcs/rudder-cmd-norm"value="0"/></event><!--Tilt altitude rudder "towards"--><event><condition> sim-time-sec ge 2.75 </condition><set name="fcs/elevator-cmd-norm"value="-0.4"/></event><!--Return aileron to neutral position--><event><condition> sim-time-sec ge 2.95 </condition><set name="fcs/aileron-cmd-norm"value="0"/></event><!--Return altitude rudder to neutral position--><event><condition> sim-time-sec ge 3.0 </condition><set name="fcs/elevator-cmd-norm"value="0"/></event></run></runscript>

Pilot UAV.How to make a barrel properly
Run it and see what happens :
Pilot UAV.How to make a barrel properly
In terms of roll, the vehicle turned 180 degrees, with a total height change of about 2.5 meters, five times less than in the previous case. You could say we had an almost perfect barrel.

In lieu of a conclusion

So, we’ve looked at some of the principles of doing a barre aerobatic figure, and we’ve seen that, acting reasonably, we can do a good quality barre on a simulator. It would be nice to get into practice and this is what we envision doing it with – aircraft model + stm32f103 + mpu9250. All of these elements are readily available and cheap, so anyone can try to do it themselves. The results of trial and error and instructions for repetition are the subject of the following publications.

You may also like