SlideShare una empresa de Scribd logo
1 de 53
Descargar para leer sin conexión
Professional Development Short Course On:
                          Aerospace Simulations In C++



                                          Instructor:

                                   Dr. Peter Zipfel




ATI Course Schedule:                   http://www.ATIcourses.com/schedule.htm

                                       http://www.aticourses.com/aerospace_simulations_in_C++.htm
ATI's Aerospace Simulations In C++ :
Aerospace Simulations in C++
   Apply the power of C++ to simulate multi-object aerospace vehicles

                                                                                                                               $1995
                  Summary
   This four-day course introduces engineers and
programmers to object oriented programming of
aerospace vehicle simulations. Building on your
basic understanding of C++, this course will bring     Participants may bring an IBM compatible laptop with Microsoft Visual   NEW!
alive polymorphism, inheritance and encapsulation      C++ 2005 or 2008 installed (free download) or Visual FORTRAN 6.1
by hands-on experimentation with simulations of        or later (currently sold by Intel).
satellites, unmanned combat air vehicles, and air
intercept missiles. Lecture and computer lab will
guide you from single object architectures to                                                   Course Outline
multiple interacting vehicles. Demonstrations on       1. Building the Satellite Simulation. Reviewing C++ basics. Modeling
modeling of aerodynamics, propulsion, flight              three DoF equations of motions. Introducing the satellite simulation
control and navigation & guidance assume some             architecture making use of inheritance. Running your first simulation in
familiarity with these disciplines. You will take         MS Visual C++. Exploring the characteristics of satellite trajectories.
home five simulations with plotting utilities, ready   2. Building the Truck Simulation. Converting to the truck simulation.
to run, and the instructor’s textbook Modeling and        Understanding C++ input, and object replication. Experimenting with
Simulation of Aerospace Vehicle Dynamics.                 multiple vehicles moving on the ground.
                                                       3. Building the Unmanned Combat Air Vehicle (UCAV) Simulation.
                                                          Understanding aerodynamic and propulsion modeling. Applying run-time
          Hands-On Training                               polymorphism to the UCAV class hierarchy. Understanding flight control.
  During this course, under the instructor’s              Exploring utility classes and operator overloading. Using output files for
guidance, you gain extensive C++ experience               plotting. Understanding navigation and guidance. Combining UCAV and
working ‘real-world’ aerospace simulations on             truck targets for attack trajectory studies.
supplied PCs:                                          4. Merging the Satellite, Truck and UCAV Simulations. Studying the
 • Compiling and running C++ simulations in MS            run-time interface communication among the vehicles. Running multi-
   Visual C++                                             vehicle, multi-object trajectories and displaying them graphically.
 • Defining and using classes                          5. Investigating the Air Intercept Missile Simulation. Understanding a
 • Building class hierarchies                             typical six DoF missile simulation. Modeling interaction of missiles and
                                                          targets. Conducting air-to-air engagement studies.
 • Reading and writing formatted I/O
 • Applying run-time polymorphism
 • Running, plotting and interpreting satellite,       Included with this short course is the instructor’s text book
   UCAV and missile trajectories                       “Modeling and Simulation of Aerospace Vehicle Dynamics”, a
                                                       complete set of course notes, five C++ simulations, and a free
                                                       CD-ROM with CADAC-Studio for plotting.
                 Instructor
  Dr. Peter Zipfel is an Adjunct Associate
Professor at the University of Florida and has                                               What You Will Learn
taught courses in Modeling & Simulation in C++,        • Exploiting the rich features of C++ for aerospace application
Flight Dynamics, Guidance and Control for the last          • How to use classes and inheritance to build vehicle objects
twenty years. His forty years of M&S experience             • How run-time polymorphism makes multi-object simulations possible
in helicopters, missiles, aircraft and hypersonic           • How the run-time interface communicates among vehicles
vehicles was acquired at the German Helicopter
                                                       • Understanding three and six DoF aerospace simulations
Institute, the U.S. Army and U.S. Air Force and his
                                                            • How a vehicle is subdivided into subsystem modules
consulting business Modeling and Simulation                 • How aerodynamics, propulsion, guidance and control are modeled
Technologies. Having given short courses on M&S             • How C++ facilitates the data exchange between subsystems
in the UK, Germany, France and the U.S. he is an
internationally recognized lecturer. Recently he       • Running aerospace simulations
authored the text book Modeling and Simulation of           • How to set up input in C++
                                                            • How to execute and record the output
Aerospace Vehicle Dynamics.
                                                            • How to plot and interpret the trajectories of satellites, aircraft and missiles

                         Register online at www.ATIcourses.com or call ATI at 888.501.2100 or 410.531.6034
e
                                                                                         e




                                                                                        at
                                                                                      at




                                                                                    lic
                                                                                      l
                                                                                   ia
                                                                           om lic




                                                                                up
                                                                                 er
                                                                         .c up




                                                                              at




                                                                              D
                                                                       es D




                                                                          IM




                                                                           ot
                                                                   rs ot




                                                                         N
                                                               om AT
                                                                ou N




                                                                       o
                                                             Ic o




                                                                    D
                                                            .c •
                                                          AT l • D




                                                                     l
                                                                  ia
                            www.ATIcourses.com


                                                         es te




                                                                 l•




                                                               er
                                                       rs a




                                                              ia
                                                      w. a




                                                             ic




                                                            at
                                                    om er
                                                    w ri




                                                    ou pl




                                                          M
                                                   w ate




                                                  .c at
                                                  Ic u




                                                       TI
                                                       D




                                                es M
                                                     M




Boost Your Skills




                                                    •A
                                                    ot




                                             rs TI
                                                              349 Berkshire Drive
   I
AT




                                           w. N




                                         ou A




                                                 te
                                                              Riva, Maryland 21140
                                               AT

with On-Site Courses
                                      w Do




                                      Ic te •




                                      .c ca
                                                              Telephone 1-888-501-2100 / (410) 965-8805




                                             te
                                          om
                                   es li
                                          ca
                                           l•




                                  om a
                                rs up
Tailored to Your Needs
                                                              Fax (410) 956-5785
                                         w




                               .c lic
                                        ia




                               w. li




                              ou D
                                                              Email: ATI@ATIcourses.com
                              w up
                                     er




                             es up
                                  AT




                            Ic ot
                                  at




                           w D




                          rs D
                        AT N
                               M




The Applied Technology Institute specializes in training programs for technical professionals. Our courses keep you
                               ot




                       ou ot
                              o
current in the state-of-the-art technology that is essential to keep your company on the cutting edge in today’s highly
                             N
          I




                    Ic N
                    w. D
       AT




competitive marketplace. Since 1984, ATI has earned the trust of training departments nationwide, and has presented
                          o




                AT Do
                         l•
                        D




on-site training at the major Navy, Air Force and NASA centers, and for a large number of contractors. Our training
                      ia
                    l•




increases effectiveness and productivity. Learn from the proven best.




            w. •
                   er




           w ial
                  ia




                  w
                at
               er




               w



               er
For a Free On-Site Quote Visit Us At: http://www.ATIcourses.com/free_onsite_quote.asp
            IM
            at




            at
         IM




         AT




         IM
For Our Current Public Course Schedule Go To: http://www.ATIcourses.com/schedule.htm
         w
      AT




      AT
Building Aerospace Simulations in C++



                                                     Lab2 Classes
                                                      … build your world of hierarchies




Lab         Topics           Simulation   •   CRUISE is built on the Cadac hierarchy
 1
        C++ Essentials
         QuickStart
                              CRUISE      •   The classes of CADAC++
 2
             Classes
                             CRUISE_2     •   Multiple encapsulated objects
      Satellite Simulation

 3
          Modules
                             CRUISE_3
                                          •   The Cadac hierarchy
      Target Simulation
          Tables
                                          •   Abstract base class Cadac
 4                           CRUISE_4
      UAV Uncontrolled
          Events
                                          •   Round3 inherits from Cadac
 5                           CRUISE_5
       UAV Controlled
                                          •   Cruise inherits from Round3
        Polymorphism
 6                           CRUISE_6
       UAV Navigation                     •   Target inherits from Round3
          ComBus
 7                           CRUISE_7
         UAV Homing                       •   Satellite inherits from Round3
        Architectures
 8
       UAV Netcentric
                              CRUISE
                                          • What you have learned ♣
       SCHEDULE



                               Copyright © 2009 Modeling and Simulation Technologies
Lab2 Classes


                     CRUISE is built on the Cadac hierarchy
          • Cadac is the abstract base class
Classes
                – Characterized by the fact that it contains pure virtual functions

          • Round3 class is derived from Cadac
                – Provides the structure for the equations of motion

          • Cruise, Target, and Satellite classes are derived
              from Round3
                – These classes declare the vehicle types with names: CRUISE3,
                    TARGET3, and SATELLITE3

          •   Modules are member functions of the derived classes
                – They define the mathematical models of the vehicle components

          •   Other classes support the simulation architecture ♣

          MaSTech © 2009            Building Aerospace Simulations in C++             2
Lab2 Classes


                             The classes of CADAC++


                   CLASS              DESCRIPTION
 CADAC            Cadac, ...    Hierarchical class structure of vehicles
Hierarchy
                  Vehicle       Hosting a pointer array of type Cadac
                  Module        Storing module information
                  Variable      Declaring module-variables
                  Event         Storing event information
                  Packet        Declaring data packets for global communication bus
                  Datadeck      Hosting a pointer array of type Table
                  Table         Storing tabular data
                  Matrix        Storing matrix operations
                  Document      Storing module-variable definitions ♣



            MaSTech © 2009        Building Aerospace Simulations in C++         3
Lab2 Classes


                                  Multiple encapsulated objects
               •   Each aerospace vehicle is an object created from its hierarchical class
                   structure
                     –   Data and methods (member functions) are encapsulated
                             •    Aerodynamic and propulsion data tables
                             •    Vehicle characteristics are computed in module functions
                     – Cadac is the abstract base class
               •   Examples
                                 Cruise Missile                                                         Air Engagement
                                                                  Aircraft Simulation
                                  Simulation                                                               Simulation

                                     Cadac                              Cadac                               Cadac


                                    Round3                               Flat6                 Flat6                     Flat3


                    Target           Cruise       Satellite             Plane                 Missile          Recce             Target




               •   Polymorphism enables the call of the vehicle objects during run-time
 Inheritance         – Inheritance enables a derived object to acquire the properties of the base
                       object
  Run-Time
Polymorphism         – Virtual functions are overridden until the correct module is executed ♣

               MaSTech © 2009                         Building Aerospace Simulations in C++                                               4
Lab2 Classes


                                                    The Cadac hierarchy
                        Abstract base class                        Cadac
           Hierarchy                                                                                      Virtual functions

                        Derived class                             Round3                                  newton ( )
                                                                   round3 [ ]                             environment ( )
                                                                                                                              Virtual functions
                        Derived class           Target             Cruise           Satellite
                                                  target [ ]        cruise [ ]       satellite [ ]   Module-Variable arrays   aerodynamics ( )
                                                                                                                              propulsion ( )
                                                                                               SATELLITE3                     forces ( )
           Vehicle names                  TARGET3                  CRUISE3
                                                                                                                              targeting ()
                                                                                                                              seeker ( )
                                                                                                                              guidance ( )
                                                                                                                              control ( )
                                                     Communication bus combus [ ]                                             intercept ()




                       aerodynamics ( )           propulsion ( )                  forces ( )                 newton ( )           intercept ( )

                                          Modular structure                       seeker ( )

                          control ( )              guidance ( )                                            environment ( )

SCHEDULE                                                                         targeting ( )
                                                                                                                                            ♣
              MaSTech © 2009                                   Building Aerospace Simulations in C++                                        5
Lab2 Classes


                                  Abstract base class Cadac
               •   Cadac declares
                     –   Pointers of module-variable arrays
  Run-Time           –   Pure virtual functions for the executive processes
Polymorphism         –   Pure virtual functions for the modules

                class Cadac
                {
                private:
                     char name[CHARN]; //vehicle object name
                protected:
                     //module-variable array            of class 'Round3'
 CRUISE_2            Variable *round3;
                     //module-variable array            of class 'Cruise'
                     Variable *cruise;
                     //module-variable array            of class 'Target'
                     Variable *target;
                     //module-variable array            of class 'Satellite'
                     Variable *satellite;
                                                                              class Variable
                public:                                                       {
                     Cadac(){}                                                private:
                     virtual~Cadac(){};                                         char name[CHARN];
                     //executive functions                                      char type[CHARN];
                     //pure virtual functions                                   double rval;
                          virtual void sizing_arrays()=0;                       int ival;
                          ....                                                  Matrix VEC;
                     //module functions                                         Matrix MAT;
                     //... pure virtual functions                               char def[CHARL];
                };                                                              char mod[CHARN];
                                                                                char role[CHARN];
                                                                                char out[CHARN];
                                                                              public:
                                                                               //methods for initialization
                                                                               //methods for reading and loading ♣
                                                                              };

               MaSTech © 2009                      Building Aerospace Simulations in C++                             6
Lab2 Classes


                            Round3 inherits from Cadac
           •     Spherical rotating Earth, 3 degrees of freedom
           • void Round3::environment(…)
                  –   ISO 62 standard atmosphere
                  –   Newton’s gravitational acceleration (inverse square law)
           • void Round3::newton(…)
                  –   Equations of motion are integrated in inertial coordinates
                  –   Conversion of input and output from/to geographic coordinates

CRUISE_2
               class Round3:public Cadac
               {
               protected:
                    //declaring index arrays which identify module-variables for output
               public:
                    Round3();
                    virtual~Round3(){};
                    //executive functions
                    //... pure virtual functions
                    //module functions
                    //... pure virtual functions
                    //virtual functions to be defined in this class
                    virtual void def_environment();
                    virtual void init_environment(...);
                    virtual void environment(...);
                    virtual void def_newton();
                    virtual void init_newton();
                    virtual void newton(...);                                         ♣
               };

           MaSTech © 2009                   Building Aerospace Simulations in C++         7
Lab2 Classes


                        Cruise inherits from Round3
                                                                     class Cruise:public Round3
           • Bank-to-turn UAV                                        {
                                                                     protected:
                 void Cruise::aerodynamics();                              //name of “CRUISE3” vehicle object
                                                                           char cruise3_name[CHARL];
 Modules             Drag polar                                            //array pointers
                                                                           ...
                 void Cruise::propulsion(...);                       public:
                                                                           Cruise(){};
                                                                           Cruise(...);
                     Turbojet                                              virtual~Cruise();
                 void Cruise::forces();                                     //executive functions
                                                                            ...
                     Aerodynamic and propulsive
                                                                            //module functions
                 void Cruise::control(...);                                 virtual void aerodynamics();
                                                                            virtual void propulsion(...);
CRUISE_2                                                                    virtual void forces();
                     Heading, flight path, bank angle, load                 virtual void control(...);
                                                                            virtual void guidance();
                     factor, altitude hold                                  virtual void targeting(...);
                                                                            virtual void seeker(...);
                 void Cruise::guidance();                                   virtual void intercept(...);
                     Line, pro-nav, point, arc                              //functions of control module
                                                                            double control_heading(...);
                 void Cruise::targeting(...);                               double control_flightpath(...);
                                                                            double control_bank(...);
                                                                            double control_load(...);
                     Satellite targeting                                    double control_lateral(...);
                                                                            double control_altitude(...);
                 void Cruise::seeker(...);
                                                                            //functions of guidance module
                     Line-of-sight seeker                                   Matrix guidance_line();
                                                                            Matrix guidance_pronav();
                 void Cruise::intercept(...);                               Matrix guidance_point();
                                                                            double guidance_arc();
                                                                            double guidance_spline();
                     Waypoint and target miss distance
                                                                            //functions of seeker module
                                                                            void seeker_grnd_ranges(...);
                                                                            //functions of targeting module
                                                                            void targeting_satellite(...);
                                                                            void targeting_grnd_ranges(...);    ♣
                                                                     };
           MaSTech © 2009                        Building Aerospace Simulations in C++                          8
Lab2 Classes


                         Target inherits from Round3

 CADAC
                                                                      class Target:public Round3
Hierarchy
                                                                      {
                                                                      protected:
                                                                         //name of “TARGET3” vehicle object
                                                                         char target3_name[CHARL];
                                                                         //array pointers
                                                                         ...
                                                                      public:
                                                                         Target(){};
CRUISE_2
                                                                         Target(...);
                                                                         virtual~Target();

                                                                           //executive functions
                                                                           ...
            • Target over the round, rotating Earth                        //module function dummy returns
                                                                           virtual void def_aerodynamics(){};
                  void Target::forces();                                   ...
                                                                           //module functions active
                      Compensating for Coriolis and                        virtual void forces();
                      centrifugal accelerations                            virtual void intercept(...);         ♣
                                                                      };
                  void Target::intercept(...);
                      Setting target status (alive, hit, dead)




            MaSTech © 2009                        Building Aerospace Simulations in C++                         9
Lab2 Classes


                    Satellite inherits from Round3

                                                                        class Satellite:public Round3
                                                                        {
                                                                        protected:
                                                                           //name of ”SATELLITE3” vehicle object
                                                                           char satellite3_name[CHARL];
                                                                           //array pointers
                                                                           ...
                                                                        public:
                                                                           Satellite(){};
CRUISE_2
                                                                           Satellite(...);
                                                                           virtual~Satellite();

                                                                             //executive functions
                                                                             ...
                                                                             //module function dummy returns
           •   Target over the round, rotating Earth                         virtual void def_aerodynamics(){};
                  void Satellite::forces();                                  ...
                                                                             //module functions active
                      Mass properties and optional thrusting
                                                                             virtual void forces();
                  void Satellite::seeker(...);                               virtual void seeker(...);             ♣
                      Radar seeker (simplified)                         };




           MaSTech © 2009                           Building Aerospace Simulations in C++                          10
Lab2 Classes


                              What you have learned
           •   Class structure of the CADAC++ architecture

           • Cadac is an abstract base class

           •   The class hierarchy declares the vehicle objects Cruise, Target,
               and Satellite

           •   The vehicle objects are named CRUISE3, TARGET3, and
               SATELLITE3 in the ‘input.asc’ file

           •   Modules are member functions (methods) of the derived classes

           •   Use of access specifiers

           •   Use of constructors and destructors              ♣



SCHEDULE

           MaSTech © 2009            Building Aerospace Simulations in C++        11
Building Aerospace Simulations in C++



                                             Lab2 Satellite Simulation
                                             … is the simplest simulation


                                          • Features of satellite simulation
Lab         Topics           Simulation
        C++ Essentials
                                          • Class hierarchy of satellite simulation
 1                            CRUISE
         QuickStart
                                          • Equations of motions are derived from
             Classes
 2
      Satellite Simulation
                             CRUISE_2
                                            Newton’s Law
 3
          Modules
      Target Simulation
                             CRUISE_3     • Inertial and Earth coordinate systems
 4
          Tables
      UAV Uncontrolled
                             CRUISE_4     • Earth and geographic coordinate systems
 5
          Events
       UAV Controlled
                             CRUISE_5     • Geographic and flight path coordinate system
 6
        Polymorphism
                             CRUISE_6
                                          • Geographic initialization
       UAV Navigation

 7
          ComBus
                             CRUISE_7
                                          • Solving the equations of motion
         UAV Homing

        Architectures
                                          • Circular orbiting satellite over the equator
 8                            CRUISE
       UAV Netcentric
                                          • What you have learned ♣
       SCHEDULE



                               Copyright © 2009 Modeling and Simulation Technologies
Lab2 Satellite Simulation

                 Features of satellite simulation

       •    3 DoF, round, rotating Earth;

       •    Coordinates: longitude, latitude, altitude

       •    Newton’s equations solved in inertial coordinates

       •    Conversion from geographic to inertial coordinates
            and vice versa

       •    Propulsion is optional ♣




MaSTech © 2009            Building Aerospace Simulations in C++   2
Lab2 Satellite Simulation

      Class hierarchy of satellite simulation

            Abstract base class                    Cadac
                                                                               Virtual functions

            Derived class                         Round3                       newton ( )
                                                    round3 [ ]
                                                                               environment ( )

                                 Module-
            Derived class
                              Variable arrays     Satellite                    forces ()
                                                   satellite [ ]


                                                 SATELLITE3




                       environment ( )               forces ( )            newton ( )

                                                Modular structure




                                                                                                   ♣
MaSTech © 2009                     Building Aerospace Simulations in C++                           3
Lab2 Satellite Simulation

                         Equations of motions are derived from Newton’s Law


 Zipfel, p. 261 *

                                                                           Newton’s Law
                                                                                         mD I v IB = f a , p + mg

                                                                           Relationship of inertial and geographic
                                                                           velocities

                                                                                         v IB = v E + Ω EI s BI
                                                                                                  B



                         Matrix equations programmed in ‘newton’ module

                                                               (
                                    m [dvB / dt ]I = [T ]GI [T ]VG [ f a , p ]V + m [ g ]G
                                         I
                                                                                             )    I Inertial coordinates
                                    [dsBI / dt ] = [v ]
                                                 I       I I
                                                         B                                        G Geographic coordinates
  * “Modeling and                                                                                 V Flight path coordinates
    Simulation of
 Aerospace Vehicle
  Dynamics”, AIAA
Education Series, 2nd                                                                                                         ♣
    Edition, 2007

                        MaSTech © 2009                   Building Aerospace Simulations in C++                                4
Lab2 Satellite Simulation

                      Inertial and Earth coordinate systems
                                                    • Inertial coordinate system
                                                        1I axis is aligned with the Vernal Equinox
                                                        3I axis is aligned with the spin axes of the
                                                        Earth
Zipfel, p. 71




                                                    • Angle Ξ is the hour angle

                • The transformation matrix of Earth wrt inertial coordinates is


                                                  ⎡ cos Ξ sin Ξ 0⎤
                                       [T ]EI   = ⎢− sin Ξ cos Ξ 0⎥                 ♣
                                                  ⎢               ⎥
                                                  ⎢
                                                  ⎣ 0        0   1⎥
                                                                  ⎦


                MaSTech © 2009              Building Aerospace Simulations in C++                      5
Lab2 Satellite Simulation

                 Earth and geographic coordinate systems
                                                           • Earth coordinate system
                                                              1E axis is at the intersection of the Greenwich
                                                              Meridian and the equator
                                                               3E axis is aligned with the spin axis of the Earth

Zipfel, p. 72
                                                           • Geographic coordinate system
                                                              1G axis points to the north pole
                                                               3G axis point to the center of the Earth

                                                           • l longitude
                                                           • λ latitude

                 • TM sequences through two intermediate coordinate systems X and Y

                                  [T ]GE = [T (180o )]GY [T (90o − λ )]YX [T (l )]XE

                 • The TM of geographic wrt Earth coordinates is
                                            ⎡ − sin λ cos l − sin λ sin l cos λ ⎤
                                 [T ]GE   = ⎢ − sin l           cos l       0 ⎥♣
                                            ⎢                                    ⎥
                                            ⎢− cos λ cos l − cos λ sin l − sin λ ⎥
                                            ⎣                                    ⎦
                MaSTech © 2009               Building Aerospace Simulations in C++                              6
Lab2 Satellite Simulation

                    Geographic and flight path coordinate system

                                                                       • Geographic coordinate system
                                                                          1G axis points to the north pole
                                                    1V                     3G axis point to the center of the Earth

                                                                       • Flight path coordinate system
Zipfel, p. 80                                                 1G
                   2V
                                 2G              X
                                                                             1V axis parallel and in the direction of the
                   2X                           1                            velocity vector
                                                                             2V axis is horizontal and points to the right
                                            3V                               3V axis point “down”
                                                                       • χ heading angle (chi)
                                        X
                                       3 = 3G
                                                                       • γ flight-path angle

                   • The TM of flight path wrt geographic coordinates is

                  [T ]VG = [T (γ )]VX [T ( χ )] XG
                             ⎡cos γ    0 − sin γ ⎤ ⎡ cos χ             sin χ    0⎤ ⎡cos γ cos χ      cos γ sin χ   − sin γ ⎤
                   [T ]VG   =⎢ 0       1    0 ⎥ ⎢− sin χ               cos χ    0⎥ = ⎢ − sin χ          cos χ         0 ⎥          ♣
                             ⎢                   ⎥⎢                              ⎥ ⎢                                       ⎥
                             ⎢ sin γ
                             ⎣         0 cos γ ⎥ ⎣ 0
                                                 ⎦⎢                      0      1⎥ ⎢ sin γ cos χ
                                                                                 ⎦ ⎣                 sin γ sin χ    cos γ ⎥⎦

                MaSTech © 2009                           Building Aerospace Simulations in C++                                 7
Lab2 Satellite Simulation

                                        Geographic initialization
             • Geographic initialization converted to inertial position and velocity
CRUISE_2                    Implemented in: void Round3::init_newton()

                                                                                                       E         Geographic speed
                                                                                                    | vB |
                                                                                                      χ          Heading angle

                                                                                                      γ          Flight path angle
                                     | v B | , χ , γ , l, λ , h
                                         E

                                                                                                      l          Longitude

                                                                                                      λ          Latitude

                                                                                                      h          Altitude
                                          E
                                       | vB   |
                             [T ]GE = cadtge( l, λ)
                                                                                                    [ s BI ] I
                             [sBI ]E = [T ]EG[sBI ]G                                                             Inertial position
                             [vB ]G = cart_ from_ pol | vB |, χ, γ
                               E                         E
                                                                  (         )                       [v B ] I
                                                                                                       I
                                                                                                                 Inertial velocity
                             [T ] = [E]
                                IE
                                                                                                          GV
                             [T ]IG = [T ]IE[T ]EG                                                  [T ]         T.M. of geographic wrt flight path coor.

                             [vB ]I = [T ]IG[vB ]G + [ΩEI ]I [sBI ]I
                               I              E
                                                                                                    [T ] IG      T.M. of inertial wrt geographic coor.
                                VG
                             [T ]    = mat2tr( χ, γ )
                             [T ]GV = [T ]VG




                                                                                                                                                         ♣

           MaSTech © 2009                                             Building Aerospace Simulations in C++                                              8
Lab2 Satellite Simulation

                        Solving the equations of motion
             • Integrating inertial states and converting them to geographic output
CRUISE_2         Implemented in: void Round3::newton(double int_step)




                                                                                                [ f sp ]V   Propulsive specific force




                                                       (
                            [ dvB / dt ]I = [T ]IG [T ]GV [ f sp ]V + [ g ]G
                                I
                                                                                 )
                            [ dsBI / dt ]I = [ vB ]I
                                                I
                                                                                        E
                                                                                     | vB |

                        [T ] EI = cadtei (time)
                                                                                      χ
                                                                                      γ
                        [ s BI ] E = [T ] EI [ s BI ] I
                        (l , λ , h ) = cadsph ([ s BI ]E )
                                                                                       l
                                                                                       λ
                        [T ]GE = cadtge (l , λ )                                       h
                        [T ]GI = [T ]GE [T ] EI
                                                (
                        [v B ]G = [T ]GI [v B ] I − [Ω EI ] I [ s BI ] I
                           E                I
                                                                           )
                        (   | v B |, χ , γ
                                E
                                             ) = pol _ from _ cart (   [v B ]G
                                                                          E
                                                                                 )
                        [T ]   VG
                                    = mat 2tr ( χ , γ )
                        [T ]GV = [T ]VG




                                                                                                                                        ♣
           MaSTech © 2009                                       Building Aerospace Simulations in C++                                   9
Lab2 Satellite Simulation

            Circular orbiting satellite over the equator
                                Input
                               alt 300000     //Vehicle   altitude - m module newton
                               psivgx 90      //Vehicle   heading angle - deg module newton
CRUISE_2
                               thtvgx 0       //Vehicle   flight path angle - deg module newton
                               dvbe 7243.2    //Vehicle   speed - m/s module newton



                                                                           Satellite inertial
                                                                                speed
                                                                                       G×M⊕
                                                                            | v B |=
                                                                                I
                                                                                       R⊕ + alt




                                                                               Earth
                                                                          circumferential
                                                                         speed at equator
                                                                          | Δv |= (R⊕ + alt )ω EI

                                                                                                    ♣
           MaSTech © 2009   Building Aerospace Simulations in C++                                   10
Lab2 Satellite Simulation

                                What you have learned

               •   The core of the simulation, i.e., the ‘newton’ module, simulates
                   satellite orbits

               •   Key coordinate systems

                     – Inertial, Earth, geographic and flight path angle


               •   Newton’s equations of motion are integrated in inertial coordinates

               •   Input/output conversion are from geographic to inertial coordinates
                   and back ♣


HandsOn2

SCHEDULE

           MaSTech © 2009              Building Aerospace Simulations in C++          11
Building Aerospace Simulations in C++



                              Lab2 HandsOn2
                              … let’s start with a simple class structure
                                 and simulation




             • HandsOn2_1 Duplicate the satellite trajectory
             • HandsOn2_2 Add the module ‘seeker’ to the
               ‘Satellite’ class
             • HandsOn2_3 Find the constructor and destructor
               of the ‘Satellite’ class
SCHEDULE     • HandsOn2_4 Raise the satellite orbit by thrusting




           Copyright © 2009 Modeling and Simulation Technologies
HandsOn2

                HandsOn2_1 Duplicate the satellite trajectory


               1. Load the CRUISE_2 project and run the test case with input file
                  ‘input2_1.asc’

               2. Plot the trajectory with the KPLOT-GLOBE program and thus
                  duplicate the circular satellite trajectory over the equator, as shown
                  in Slide 10 of ‘Lab2 Satellite Simulation’

               3. What is the deviation in percent from the starting altitude?

               4. Reduce and increase the integration step size by an order of
                  magnitude
Result2_1            - How does the integration step size effect the accuracy? ♣




            MaSTech © 2009              Building Aerospace Simulations in C++         2
HandsOn2

            HandsOn2_2 Add the module ‘seeker’ to the ‘Satellite’ class



               •    For future usage, the ‘Satellite’ class needs a ‘seeker’ module.
                    Provide two skeleton member functions ‘def_seeker()’ and
                    ‘seeker(…)’ as place holders in the file ‘satellite_modules.cpp’

               1. In file ‘satellite_modules.cpp’ add the skeleton of ‘def_seeker()’ and
                  ‘seeker(…)’ following the example of functions ‘def_forces()’ and
                  ‘forces()’, without code inside the function scopes

               2. Declare the two new functions in the class ‘Satellite’ of the header
                  file ‘class_hierarchy.hpp’

Result2_2      3. Check your modifications by recompiling ♣




            MaSTech © 2009             Building Aerospace Simulations in C++             3
HandsOn2

                HandsOn2_3 Find the constructor and destructor of the
                                  ‘Satellite’ class




                  1. Locate the constructor of the ‘Satellite’ class
                        What is the purpose of the parameters?

                        What memory allocations occur?

                  2. Locate the destructor of the ‘Satellite’ class
Result2_3               What action does the destructor perform? ♣




            MaSTech © 2009              Building Aerospace Simulations in C++   4
HandsOn2


            HandsOn2_4 Raise the satellite orbit by thrusting



                  •   In the ‘force’ module a constant thrust force can be applied to the
                      satellite

                  1. Augment the input file ‘input2_1.asc’ with the satellite thrust
                     variable

                  2. Determine what thrust is required to increase the satellite altitude
                     by 100 km after one orbit

Result2_4         3. Make a plot with KPLOT-GLOBE ♣




SCHEDULE

            MaSTech © 2009             Building Aerospace Simulations in C++            5
Building Aerospace Simulations in C++



                               Lab2 Result2
                                … let’s start with a simple class structure and
                                   simulation




               • Result2_1 Duplicate the satellite trajectory
               • Result2_2 Add the module ‘seeker’ to the
                 Satellite class
               • Result2_3 Find the constructor and destructor
                 of the ‘Satellite’ class
SCHEDULE       • Result2_4 Raise the satellite orbit by thrusting




           Copyright © 2009 Modeling and Simulation Technologies
Result2

       Result2_1 Duplicate the satellite trajectory


      1 & 2 Self explanatory

      3. The deviation form the starting altitude is 0.33%

      4. Integration step size

          - increased by order of magnitude the error is 3.3%
          - decreased by order of magnitude the error is 0.031%




MaSTech © 2009             Building Aerospace Simulations in C++   2
Result2

              Result2_2 Add the module ‘seeker’ to the Satellite class


CRUISE_2
              •    For the implementation of the two member functions ‘def_seeker()’
                   and ‘seeker(…)’, look into the file ‘satellite_modules.cpp’ and
                   ‘class_hierarchy.hpp’ of the CRUISE simulation ♣




           MaSTech © 2009            Building Aerospace Simulations in C++         3
Result2

                 Result2_3 Find the constructor and destructor of the
                                   ‘Satellite’ class

CRUISE_2

             1. The constructor is located in file ‘class_functions.cpp’
                   The parameter list consists of the pointer to the module array and the size
                      of the module array

                   Dynamic memory allocation is made for
                            Module variable array ‘satellite’

                            Combus index arrays ‘round3_com_ind’ and ‘com_satellite3’

             2. The destructor is located in file ‘class_functions.cpp’
                   It releases the dynamic memory allocated of the ‘Satellite’ members
                            ‘satellite’, ‘round3’, ‘round3_com_ind,; ‘satellite_com_ind’, ‘com_satellite3’




           MaSTech © 2009                     Building Aerospace Simulations in C++                          4
Result2

              Result2_4 Raise the satellite orbit by thrusting

CRUISE_2




                                                                     Required thrust to raise
                                                                       satellite by 100km
SCHEDULE
                                                                     sat_thrust = 1.03 N
           MaSTech © 2009    Building Aerospace Simulations in C++                              5
Building Aerospace Simulations in C++



                                                       Lab3 Modules
                                                       … model the vehicle components


                                          •   Modules form the core of the simulation
Lab         Topics           Simulation   •   Module-variables interface between modules
        C++ Essentials
 1
         QuickStart
                              CRUISE      •   Three functions compose the ‘newton’ module
 2
             Classes
                             CRUISE_2
                                          •   Modules are called every integration cycle
      Satellite Simulation
          Modules
                                          •   Module-variables are of type Variable
 3                           CRUISE_3
      Target Simulation
                                          •   Example code of module ‘newton’
          Tables
 4
      UAV Uncontrolled
                             CRUISE_4     •   How to build a module
 5
          Events
                             CRUISE_5     •   Matrix utility operations
       UAV Controlled
        Polymorphism
                                          •   Matrix class and methods
 6                           CRUISE_6
       UAV Navigation
                                          •   More examples of Matrix methods
          ComBus
 7                           CRUISE_7
         UAV Homing                       •   Utility functions of class Matrix
         SCHEDULE
        Architectures
 8
       UAV Netcentric
                              CRUISE      •   What you have learned ♣
       SCHEDULE



                               Copyright © 2009 Modeling and Simulation Technologies
Lab3 Modules


                     Modules form the core of the simulation

           •   Modules are public functions (methods) of the classes
               Round3, Cruise, Satellite and Target
           •   The structure Module declares the type of the elements in
               the ‘module_list’ array
CRUISE_3
           •   The module list and calling sequence is established in the
               ‘input.asc’ file
           •   Coding of the modules is greatly simplified by matrix
               equations

           •   The class Matrix enables the straightforward writing of
               matrix equations ♣


           MaSTech © 2009           Building Aerospace Simulations in C++   2
Lab3 Modules


                        Module-variables interface between modules
                  •   CADAC’s modular structure mirrors the hardware components of
                      an aerospace vehicle
                        – A module is a model of a vehicle component
                              • Examples: aerodynamics, propulsion, actuator, guidance, control,…
                        – Each module consists of at least two functions and possibly four:
                              • def_module(), init_module(), module(), term_module()
                  •   The calling order of the module is controlled by the input file
Module-Variable   •   Data between modules is transferred by module-variables
   Arrays
                        – Module-variables, being the only allowed interface, are strictly controlled
                        – Each vehicle object reserves protected arrays for its module-variables
                        – There is a one-to-one relationship between the module-variable name and
                          the array location
  CRUISE_3              – The file ‘doc.asc’ documents all module-variables
                  •   Module-variables can only be of type int, double, 3x1 vector, and 3x3
                      matrix
                  •   Inside a module
                        – Module-variables are localized as input from other modules
                        – Computations create new module-variables
                        – These are loaded onto the object’s array for output ♣

                  MaSTech © 2009                Building Aerospace Simulations in C++               3
Lab3 Modules


    Three functions compose the ‘newton’ module


                                        void Round3::def_newton()
                                    Definition of module-variables used in this module




                                      void Round3::init_newton ()
                                                   Initial calculations




                               void Round3::newton(double int_step)
                                        Integrations and time-phased calculations

                 Integration loop




                                                                                         ♣
MaSTech © 2009                        Building Aerospace Simulations in C++              4
Lab3 Modules


        Modules are called every integration cycle
           Calling sequence established in
                     input.asc
            MODULES
             environment    def,init,exec                         struct Module
             aerodynamics   def,exec                              {
             propulsion     def,init,exec                           string name;
             forces         def,exec                                string definition;
             newton         def,init,exec                           string initialization;
             targeting      def,exec                                string execution;
             seeker         def,exec                                string termination;
             guidance       def,exec                              };
             control        def,exec
             intercept      def,exec
            END

                                    Loading modules into module_list
            void order_modules(fstream &input,int &num,Module *module_list)


                                             Module calling
       //Vehicle’s constructor calls module to define module-variables
       if((module_list[j].name==“newton")&&(module_list[j].definition=="def"))
          def_newton();

       //Module is initialized in ‘main()’
       if((module_list[j].name==“newton")&&(module_list[j].initialization=="init"))
          vehicle_list[i]->init_newton();

       //Every integration step, module is called in ‘execute(…)’
       if(module_list[j].name==“newton")
          vehicle_list[i]->newton(int_step);

                                                                                             ♣
MaSTech © 2009                   Building Aerospace Simulations in C++                       5
Lab3 Modules

             Module-variables are of type Variable
                                                                                     class Variable
                                                                                     {
  Defining module-variables in void Round3::def_newton()                             private:
                                                                                       char name[CHARN];
round3[19].init("lonx",0,"Vehicle longitude - deg","newton","diag","scrn,plot,com");   char type[CHARN];
                                                                                       double rval;
round3[20].init("latx",0,"Vehicle latitude - deg","newton","diag","scrn,plot,com");    int ival;
                                                                                       Matrix VEC;
round3[21].init("alt",0,"Vehicle altitude - m","newton","out","scrn,plot,com");        Matrix MAT;
                                                                                       char def[CHARL];
   Documenting module-variables in doc.asc                                             char mod[CHARN];
                                                                                       char role[CHARN];
                                                                                       char out[CHARN];
                              Round3 Module-Variable Array                           public:
                                                                                      methods to initialize
---------------------------------------------------------------------------------------------------------------------
|LOC|        NAME       |                    DEFINITION                       |       methods to read OUTPUT
                                                                                  MODULE   | PURPOSE |    and load|
---------------------------------------------------------------------------------------------------------------------
                                                                                     };
…………………………………………………………
 19 lonx                 Vehicle longitude - deg                              newton       diag      scrn,plot,com
 20 latx                 Vehicle latitude - deg                               newton       diag      scrn,plot,com
 21 alt                  Vehicle altitude - m                                 newton       out       scrn,plot,com
…………………………………………………………



                                          Using module-variables

                         void Round3::newton(double int_step)
                         {
                             //localizing module-variables
                             //input from other modules
                             double time=round3[0].real();
                             Matrix FSPV=round3[10].vec();
                             ...
                             //-----------------------------------------
                             ... computations ...
                             //-------------------------------------------
                             //loading module-variables
                             //state variables
                             round3[35].gets_vec(SBII);
                             round3[36].gets_vec(VBII);
                                                                                                                     ♣
                             ...
                         }
MaSTech © 2009                          Building Aerospace Simulations in C++                                           6
Lab3 Modules


                                   Example code of module ‘newton’
CRUISE_3                            void Round3::def_newton()
                                    {
                                                      name, value, definition, module, type, out to: screen, plot file, combus
           Definition of                //Definition of module-variables
           module-variables             round3[19].init("lonx",0,"Vehicle longitude-deg","newton","diag","scrn,plot,com");
                                        round3[20].init("latx",0,"Vehicle latitude-deg","newton","diag","scrn,plot,com");
           in array ‘round3[ ]’,        round3[21].init("alt",0,"Vehicle altitude-m","newton","out","scrn,plot,com");
            a member of class           ...
           ‘Round3’                 }void Round3::init_newton()
                                    {
                                    ........................
                                    }
                                    void Round3::newton(double int_step)
                                    {
                                        //localizing module-variables
           Getting module-              //input from other modules
                                        double time=round3[0].real();
            variables from              Matrix FSPV=round3[10].vec();
           ‘round3[ ]’ array            double grav=round3[11].real();
                                        Matrix WEII=round3[27].mat();
                                        //state variables
                                        Matrix SBII=round3[35].vec();
                                        Matrix VBII=round3[36].vec();
                                        Matrix ABII=round3[37].vec();
                                        ...
                                        //-------------------------------------------------------------------------
                                        //building gravitational vector in geographic coordinates
                                        GRAV.assign_loc(2,0,grav);

                                        //integrating inertial state variables
            Computations                ABII_NEW=TIG*((TGV*FSPV)+GRAV);
                                        VBII_NEW=integrate(ABII_NEW,ABII,VBII,int_step);
                                        SBII=integrate(VBII_NEW,VBII,SBII,int_step);
                                        ABII=ABII_NEW;
                                        VBII=VBII_NEW;
                                        ...
                                        //-------------------------------------------------------------------------
                                        //loading module-variables
           Loading module-              //state variables
            variables onto              round3[35].gets_vec(SBII);
                                        round3[36].gets_vec(VBII);
           ‘round3[ ]’ array            round3[37].gets_vec(ABII);

                   ♣
                                        ...
                                    }

            MaSTech © 2009                         Building Aerospace Simulations in C++                                         7
Lab3 Modules


                                                 How to build a module
              1. Start with sample module as template                                         Example: Newton Module
              2. Reserve contiguous slots in the module-array
              3. In ‘def_module’ categorize module-variables as                  /////////////////////////////////////////////////
                                                                                 //Definition of newton module-variables
                       "data" input data values                                  //Member function of class 'Round3'
                       "init" initialized in init_module                         //Module-variable locations are assigned
                                                                                 // to round3[17-39]
                       "state" state variables for integration                   //000624 Created by Michael Chiaramonte
                       "out" output to other modules                             /////////////////////////////////////////////////
                       "diag" diagnostic, not used by other modules              void Round3::def_newton()
                                                                                 {
                       "save" value saved for next cycle
              4. In ‘module’ localize module-variables by category                   //Definition of module-variables
                                                                                     round3[19].init("lonx",0,"Vehicle longitude-d
                       //input data                                                  round3[20].init("latx",0,"Vehicle latitude-deg
                       //restore saved values                                        round3[21].init("alt",0,"Vehicle altitude-m","
                       //state variables                                         }void Round3::init_newton()
                       //input from other modules                                {
              5. Insert computations                                             ........................
                                                                                 }
              6. In ‘module’ load module-variables by category                   void Round3::newton(double int_step)
CRUISE_3               //state variables                                         {
                       //saving values                                               //localizing module-variables
                                                                                     //input from other modules
                       //output to other modules                                     double time=round3[0].real();
                       //diagnostics                                                 Matrix FSPV=round3[10].vec();
                                                                                     double grav=round3[11].real();
              7. Incorporate new module into simulation frame                        Matrix WEII=round3[27].mat();
                                                                                     //state variables
              Definition module is called once, before ‘input.asc’                   Matrix SBII=round3[35].vec();
                                                                                     Matrix VBII=round3[36].vec();
                   Defines all module-variables                                      Matrix ABII=round3[37].vec();
                                                                                     ...
                   Directs variables to output streams                               //------------------------------------------
              Initialization module is called once, after ‘input.asc’                //building gravitational vector in geographic
                                                                                     GRAV.assign_loc(2,0,grav);
                   Executes initial calculations
              Module is called once every integration step                           //integrating inertial state variables
                                                                                     ABII_NEW=TIG*((TGV*FSPV)+GRAV);
                   Localizes module-variables                                        VBII_NEW=integrate(ABII_NEW,ABII,VBII,int_step);
                   Executes computations every integration step                      SBII=integrate(VBII_NEW,VBII,SBII,int_step);
                                                                                     ABII=ABII_NEW;
                   Integrates state variables                                        VBII=VBII_NEW;
                                                                                     ...
                   Calls other subordinate functions                                 //--------------------------------------------
                   Calls utility subroutines                                         //loading module-variables
                                                                                     //state variables
                   Performs table look-up                                            round3[35].gets_vec(SBII);
                   Loads module-variables                                            round3[36].gets_vec(VBII);
                                                                                     round3[37].gets_vec(ABII);
              Watch out                                                              ...
                   Initialize all local variables                                }
                   Don’t call other module’s subordinate functions ♣
           MaSTech © 2009                                Building Aerospace Simulations in C++                                        8
Lab3 Modules


                                  Matrix utility operations
           •   Source code should be programmed in matrices as much as possible
                 – Compact code
                 – Avoids errors
           •   Requirements of flight simulations
                 – Mostly 3x1 and 3x3 matrices, some of higher dimensions (Kalman filters)
                 – Elements of matrices are of type double
           •   Class Matrix instantiate a pointer to the matrix *pbody and
               initializes the elements to zero
           •   Examples from module Target::forces()
CRUISE_3                      //Coriolis acceleration in V-coordinates
                              WEIG=TGE*WEII*TEG;
                              CORIO_V=TVG*WEIG*VBEG*2;
                              //centrifugal acceleration in V-coordinates
                              CENTR_V=TVG*WEIG*WEIG*TGI*SBII;
           •   Special features
                 –   All matrix manipulations are carried out in pointer arithmetic
                 –   Creating a matrix returns *this of the initialized matrix
                 –   Usage of copy constructor for the matrix assignment operator
                 –   Overloaded offset operator []     ♣


           MaSTech © 2009               Building Aerospace Simulations in C++                9
Lab3 Modules

                              Matrix class and methods
                                                     class Matrix
                                                     {
           •Matrix class is global in scope          private:
                                                        //number of rows
           • Private methods declare size and           int num_row;
                                                        //number of columns
             pointer of array                           int num_col;
                                                        //total number of elements
           • Public methods are the                     int num_elem;
                                                        //pointer to array
             constructors/destructor and utility        double *pbody;
                                                     public:
             functions                                  //default constructors
                                                        Matrix();
CRUISE_3                                                //overloaded constructor
                                                        Matrix(int row_size,int col_size);
                                                        //copy constructor
                                                        Matrix(const Matrix &MAT);
                                                        //destructor
                                                        ~Matrix();
                                                    //printing matrix array to console
           ////////////////////////////////////////////
           //Absolute value of vector               void print();
           //Example: value = VEC.absolute();       //Returns absolute value of a vector VEC
           ////////////////////////////////////////////
                                                    //Example: value=VEC.absolute();
           double Matrix::absolute()                double absolute();
           {                                        …
                                                 };
              double ret=0;
              for(int i=0;i<num_elem;i++)
                 ret+=(*(pbody+i))*(*(pbody+i));
              ret=sqrt(ret);
              return ret;
           }                                                                             ♣
           MaSTech © 2009              Building Aerospace Simulations in C++                 10
Lab3 Modules

             More examples of Matrix methods

///////////////////////////////////////////////////////////////////////////////
//Returns the value at offset-row 'r‘, offset-col 'c' of MAT
//Example: value = MAT.get_loc(2,1); (3rd row, 2nd column)
//////////////////////////////////////////////////////////////////////////////
double Matrix::get_loc(const int &r,const int &c)
{
   if((r<num_row)&&(c<num_col))
     return *(pbody+r*num_col+c);
   else
     {cout<<"*** Error: invalid matrix loc. 'Matrix::get_loc()' *** ";exit(1);}
}


///////////////////////////////////////////////////////////////////////////////
//Builds a square identity matrix of object 'Matrix MAT'
//Example: MAT.identity();
///////////////////////////////////////////////////////////////////////////////
Matrix & Matrix::identity()
{
   if (num_row==num_col)
   {
     for(int r=0;r<num_row;r++)
        *(pbody+r*num_row+r)=1;
   }
   else
     {cout<<"*** Error: matrix not square 'Matrix::identiy()'*** ";exit(1);}
   return *this;
}
                                                                               ♣
MaSTech © 2009            Building Aerospace Simulations in C++                11
Lab3 Modules

                            Utility functions of class Matrix
                            Member functions
            void print();
            double absolute();
            Matrix adjoint();
            void assign_loc(…)                                               Overloaded operators
            Matrix & build_mat33(…);
            Matrix & cart_from_pol(…)                                 bool operator!=(const Matrix &B);
            Matrix col_vec(const int &col);                           Matrix operator*(const double &b);
            double determinant();
                                                                      Matrix operator*(const Matrix &B);
            Matrix diamat_vec();
            Matrix diavec_mat();                                      Matrix & operator*=(const double &b);
            void dimension(int row,int col);                          Matrix & operator*=(const Matrix &B);
            Matrix ellipse();
CRUISE_3                                                              Matrix operator+(const double &b);
            int get_cols();
                                                                      Matrix operator+(const Matrix &B);
            int get_index(const int &row,const int &col);
            double get_loc(const int &r,const int &c);                Matrix & operator+=(const double &b);
            double * get_pbody();                                     Matrix & operator+=(const Matrix &B);
            int get_rows();                                           Matrix operator-(const double &b);
            Matrix & identity();
                                                                      Matrix operator-(const Matrix &B);
            Matrix inverse();
            Matrix mat33_vec9();                                      Matrix & operator-=(const double &b);
            Matrix & ones();                                          Matrix & operator-=(const Matrix &B);
            bool operator!=(const Matrix &B);
                                                                      Matrix &operator=(const Matrix &B);
            Matrix pol_from_cart();
            Matrix row_vec(const int &row);                           bool operator==(const Matrix &B);
            Matrix skew_sym();                                        double & operator [](const int &r);
            Matrix sub_matrix(const int &row, const int &col);        double operator^(const Matrix &B);
            Matrix trans();
                                                                      Matrix operator~();
            Matrix univec3();
            Matrix & zero();
            Matrix vec9_mat33();
                                                                                                            ♣
           MaSTech © 2009                 Building Aerospace Simulations in C++                             12
Lab3 Modules


                                   What you have learned


             •   Modules mirror vehicle components

             •   Module loading and calling sequence is established in the input file

             •   Communication between modules is only by module-variables

             •   The value of module-variables is stored in protected arrays of the
                 vehicle classes

             •   Computations in modules are carried out in matrix form, where
                 applicable

SCHEDULE     •   Matrix manipulations use methods of the class Matrix ♣




           MaSTech © 2009            Building Aerospace Simulations in C++              13
Building Aerospace Simulations in C++



                                              Lab3 Target Simulation
                                              … simulates vehicles moving on the ground



Lab         Topics           Simulation

 1
        C++ Essentials
                              CRUISE
                                          • Features of target simulation
         QuickStart
             Classes
                                          • Class hierarchy of target simulation
 2                           CRUISE_2
      Satellite Simulation
          Modules
                                          • Equations of motions are compensated
 3                           CRUISE_3
      Target Simulation
                                          • Vehicles on the Earth’s surface experience
          Tables
 4
      UAV Uncontrolled
                             CRUISE_4
                                            apparent forces
 5
          Events
       UAV Controlled
                             CRUISE_5     • Calculating the acceleration compensation
 6
        Polymorphism
       UAV Navigation
                             CRUISE_6     • Straight target trajectory
 7
          ComBus
                             CRUISE_7     • What you have learned ♣
         UAV Homing

        Architectures
 8                            CRUISE
       UAV Netcentric

       SCHEDULE



                               Copyright © 2009 Modeling and Simulation Technologies
Lab3 Target Simulation

                   Features of target simulation

     •    Targets move on the surface of the round, rotating Earth
            – Fixed
            – Translating
            – Accelerating

     •    Coordinates: longitude, latitude, altitude

     •    Newton’s equations are compensated with apparent
          forces      ♣




MaSTech © 2009               Building Aerospace Simulations in C++   2
Lab3 Target Simulation

                            Class hierarchy of target simulation
CRUISE_3


               Abstract base class                     Cadac
                                                                                        Virtual functions

               Derived class                          Round3                            newton ( )
                                                                                        environment ( )
                                                       round3 [ ]
                                    Module-
               Derived class
                                 Variable arrays       Target                           forces( )
                                                        target [ ]                      intercept ( )


                                                     TARGET3




                     environment ( )               forces ( )              newton ( )                   intercept ( )


                                                           Modular structure




                                                                                                                        ♣
           MaSTech © 2009                      Building Aerospace Simulations in C++                                    3
Lab3 Target Simulation

        Equations of motions are compensated

                                      • Newton’s Law governs the motion of the target
                                      • Compensating forces are applied to constrain
                                        the target to the surface of the Earth



                                           Newton’s Law with compensation          ma comp
                                                      mD I v I = ma comp + mg
                                                             B




         Matrix equations programmed in ‘newton’ module

                                                                         I Inertial coordinates

                                       (
                 [dv B / dt ] I = [T ]GI [T ]VG [acomp ]V + [ g ]G
                     I
                                                                     )   G Geographic coordinates
                                                                         V Flight path coordinates




                                                                                                     ♣
MaSTech © 2009                   Building Aerospace Simulations in C++                               4
You have enjoyed ATI's preview of
          Aerospace Simulations In C++



    Please post your comments and questions to our blog:
http://www.aticourses.com/wordpress-2.7/weblog1/

     Sign-up for ATI's monthly Course Schedule Updates :
http://www.aticourses.com/email_signup_page.html

Más contenido relacionado

La actualidad más candente

La actualidad más candente (9)

DB 설계 과제
DB 설계 과제DB 설계 과제
DB 설계 과제
 
Block chain 101 what it is, why it matters
Block chain 101  what it is, why it mattersBlock chain 101  what it is, why it matters
Block chain 101 what it is, why it matters
 
Week 3 - Cryptocurrencies
Week 3 - CryptocurrenciesWeek 3 - Cryptocurrencies
Week 3 - Cryptocurrencies
 
Solidity Simple Tutorial EN
Solidity Simple Tutorial ENSolidity Simple Tutorial EN
Solidity Simple Tutorial EN
 
Ucp 600
Ucp 600Ucp 600
Ucp 600
 
Analyzing Bitcoin Security
Analyzing Bitcoin SecurityAnalyzing Bitcoin Security
Analyzing Bitcoin Security
 
Card payment evolution v1.0
Card payment evolution v1.0Card payment evolution v1.0
Card payment evolution v1.0
 
STOCK AND BOOK DEBT AUDIT.pptx
STOCK AND BOOK DEBT AUDIT.pptxSTOCK AND BOOK DEBT AUDIT.pptx
STOCK AND BOOK DEBT AUDIT.pptx
 
ATM
ATMATM
ATM
 

Destacado

Space power systems
Space power systemsSpace power systems
Space power systems
Jim Jenkins
 

Destacado (15)

ATI Professional Development Short Course Universal Arhitecture Description F...
ATI Professional Development Short Course Universal Arhitecture Description F...ATI Professional Development Short Course Universal Arhitecture Description F...
ATI Professional Development Short Course Universal Arhitecture Description F...
 
Space power systems
Space power systemsSpace power systems
Space power systems
 
Space Systems Fundamentals
Space Systems FundamentalsSpace Systems Fundamentals
Space Systems Fundamentals
 
Ati Professional Development Short Course Space Mission Analysis Design
Ati Professional Development Short Course Space Mission Analysis DesignAti Professional Development Short Course Space Mission Analysis Design
Ati Professional Development Short Course Space Mission Analysis Design
 
Applied Physical Oceanography And Modeling
Applied Physical Oceanography And ModelingApplied Physical Oceanography And Modeling
Applied Physical Oceanography And Modeling
 
ATI Courses Professional Development Short Course Spacecraft Quality Assuranc...
ATI Courses Professional Development Short Course Spacecraft Quality Assuranc...ATI Courses Professional Development Short Course Spacecraft Quality Assuranc...
ATI Courses Professional Development Short Course Spacecraft Quality Assuranc...
 
ATI Courses Satellite Communications Essential Introduction Professional Deve...
ATI Courses Satellite Communications Essential Introduction Professional Deve...ATI Courses Satellite Communications Essential Introduction Professional Deve...
ATI Courses Satellite Communications Essential Introduction Professional Deve...
 
ATI Technical Training Short Course Underwater Acoustics for Biologists and C...
ATI Technical Training Short Course Underwater Acoustics for Biologists and C...ATI Technical Training Short Course Underwater Acoustics for Biologists and C...
ATI Technical Training Short Course Underwater Acoustics for Biologists and C...
 
ATI Courses Professional Development Short Course Applied Measurement Engin...
ATI Courses Professional Development Short Course Applied  Measurement  Engin...ATI Courses Professional Development Short Course Applied  Measurement  Engin...
ATI Courses Professional Development Short Course Applied Measurement Engin...
 
ATI Courses Professional Development Short Course Engineering Systems Modelin...
ATI Courses Professional Development Short Course Engineering Systems Modelin...ATI Courses Professional Development Short Course Engineering Systems Modelin...
ATI Courses Professional Development Short Course Engineering Systems Modelin...
 
ATI Professional Development Technical Training Short Course on Missile Autop...
ATI Professional Development Technical Training Short Course on Missile Autop...ATI Professional Development Technical Training Short Course on Missile Autop...
ATI Professional Development Technical Training Short Course on Missile Autop...
 
ATI Professional Development Technical Training Short Course Sampler on Hyper...
ATI Professional Development Technical Training Short Course Sampler on Hyper...ATI Professional Development Technical Training Short Course Sampler on Hyper...
ATI Professional Development Technical Training Short Course Sampler on Hyper...
 
ATI Courses Professional Development Short Course Remote Sensing Information ...
ATI Courses Professional Development Short Course Remote Sensing Information ...ATI Courses Professional Development Short Course Remote Sensing Information ...
ATI Courses Professional Development Short Course Remote Sensing Information ...
 
Spacecraft Radiation Protection
Spacecraft Radiation ProtectionSpacecraft Radiation Protection
Spacecraft Radiation Protection
 
ATI Courses Satellite Communications Systems Engineering Professional Develop...
ATI Courses Satellite Communications Systems Engineering Professional Develop...ATI Courses Satellite Communications Systems Engineering Professional Develop...
ATI Courses Satellite Communications Systems Engineering Professional Develop...
 

Similar a ATI Technical Training Short Course Aerospace Simulations In C++

AE30ProjectFIFIReport
AE30ProjectFIFIReportAE30ProjectFIFIReport
AE30ProjectFIFIReport
Taylor Nguyen
 
Introduction to Programming
Introduction to ProgrammingIntroduction to Programming
Introduction to Programming
ALI RAZA
 
Lecture 11
Lecture 11Lecture 11
Lecture 11
Abbas Ajmal
 
Engineering Portfolio
Engineering PortfolioEngineering Portfolio
Engineering Portfolio
Muaz Bondokji
 
The Future of Flight Simulation (video segment)
The Future of Flight Simulation (video segment)The Future of Flight Simulation (video segment)
The Future of Flight Simulation (video segment)
benhillmedia
 
AIAA_StudentUndergraduateTeam_SilverBird
AIAA_StudentUndergraduateTeam_SilverBirdAIAA_StudentUndergraduateTeam_SilverBird
AIAA_StudentUndergraduateTeam_SilverBird
Denton Sagerman
 

Similar a ATI Technical Training Short Course Aerospace Simulations In C++ (20)

High Fidelity Wind Model Software for Real-Time Simulation Platforms
High Fidelity Wind Model Software for Real-Time Simulation PlatformsHigh Fidelity Wind Model Software for Real-Time Simulation Platforms
High Fidelity Wind Model Software for Real-Time Simulation Platforms
 
CP Handout#5
CP Handout#5CP Handout#5
CP Handout#5
 
AE30ProjectFIFIReport
AE30ProjectFIFIReportAE30ProjectFIFIReport
AE30ProjectFIFIReport
 
Introduction to Programming
Introduction to ProgrammingIntroduction to Programming
Introduction to Programming
 
Object oriented slides
Object oriented slidesObject oriented slides
Object oriented slides
 
Lecture 11
Lecture 11Lecture 11
Lecture 11
 
c-for-c-programmers.pdf
c-for-c-programmers.pdfc-for-c-programmers.pdf
c-for-c-programmers.pdf
 
The Simulated Drone Flying Championship
The Simulated Drone Flying ChampionshipThe Simulated Drone Flying Championship
The Simulated Drone Flying Championship
 
C programming
C programmingC programming
C programming
 
Mechatronics engineer
Mechatronics engineerMechatronics engineer
Mechatronics engineer
 
Unit IV Solved Question Bank- Robotics Engineering
Unit IV  Solved Question Bank-  Robotics EngineeringUnit IV  Solved Question Bank-  Robotics Engineering
Unit IV Solved Question Bank- Robotics Engineering
 
Engineering Portfolio
Engineering PortfolioEngineering Portfolio
Engineering Portfolio
 
The Future of Flight Simulation (video segment)
The Future of Flight Simulation (video segment)The Future of Flight Simulation (video segment)
The Future of Flight Simulation (video segment)
 
Minimal Introduction to C++ - Part III - Final
Minimal Introduction to C++ - Part III - FinalMinimal Introduction to C++ - Part III - Final
Minimal Introduction to C++ - Part III - Final
 
c.pdf
c.pdfc.pdf
c.pdf
 
C programming
C programmingC programming
C programming
 
AIAA_StudentUndergraduateTeam_SilverBird
AIAA_StudentUndergraduateTeam_SilverBirdAIAA_StudentUndergraduateTeam_SilverBird
AIAA_StudentUndergraduateTeam_SilverBird
 
Advanced C Language for Engineering
Advanced C Language for EngineeringAdvanced C Language for Engineering
Advanced C Language for Engineering
 
17432 object oriented programming
17432   object oriented programming17432   object oriented programming
17432 object oriented programming
 
notesnet.dk - Eclipse Modelling Tools
notesnet.dk - Eclipse Modelling Toolsnotesnet.dk - Eclipse Modelling Tools
notesnet.dk - Eclipse Modelling Tools
 

Más de Jim Jenkins

ATI_Space_Satellite_Radar_Defense_Sonar_Acoustics_Technical_Training_Courses_...
ATI_Space_Satellite_Radar_Defense_Sonar_Acoustics_Technical_Training_Courses_...ATI_Space_Satellite_Radar_Defense_Sonar_Acoustics_Technical_Training_Courses_...
ATI_Space_Satellite_Radar_Defense_Sonar_Acoustics_Technical_Training_Courses_...
Jim Jenkins
 
Ati courses technical training professional courses catalog development space...
Ati courses technical training professional courses catalog development space...Ati courses technical training professional courses catalog development space...
Ati courses technical training professional courses catalog development space...
Jim Jenkins
 

Más de Jim Jenkins (20)

Digital Signal Processing - Practical Techniques, Tips and Tricks Course Sampler
Digital Signal Processing - Practical Techniques, Tips and Tricks Course SamplerDigital Signal Processing - Practical Techniques, Tips and Tricks Course Sampler
Digital Signal Processing - Practical Techniques, Tips and Tricks Course Sampler
 
ATI Space, Satellite, Radar, Defense, Systems Engineering, Acoustics Technica...
ATI Space, Satellite, Radar, Defense, Systems Engineering, Acoustics Technica...ATI Space, Satellite, Radar, Defense, Systems Engineering, Acoustics Technica...
ATI Space, Satellite, Radar, Defense, Systems Engineering, Acoustics Technica...
 
ELINT Interception and Analysis course sampler
ELINT Interception and Analysis course samplerELINT Interception and Analysis course sampler
ELINT Interception and Analysis course sampler
 
NEW ATICourses space, satellite,aerospace, engineering, technical training co...
NEW ATICourses space, satellite,aerospace, engineering, technical training co...NEW ATICourses space, satellite,aerospace, engineering, technical training co...
NEW ATICourses space, satellite,aerospace, engineering, technical training co...
 
ATIcourses Agile, Scrum, SharePoint, Space, Satellite, Radar & Engineering Te...
ATIcourses Agile, Scrum, SharePoint, Space, Satellite, Radar & Engineering Te...ATIcourses Agile, Scrum, SharePoint, Space, Satellite, Radar & Engineering Te...
ATIcourses Agile, Scrum, SharePoint, Space, Satellite, Radar & Engineering Te...
 
Space Radiation & It's Effects On Space Systems & Astronauts Technical Traini...
Space Radiation & It's Effects On Space Systems & Astronauts Technical Traini...Space Radiation & It's Effects On Space Systems & Astronauts Technical Traini...
Space Radiation & It's Effects On Space Systems & Astronauts Technical Traini...
 
Space Systems & Space Subsystems Fundamentals Technical Training Course Sampler
Space Systems & Space Subsystems Fundamentals Technical Training Course SamplerSpace Systems & Space Subsystems Fundamentals Technical Training Course Sampler
Space Systems & Space Subsystems Fundamentals Technical Training Course Sampler
 
AESA Airborne Radar Theory and Operations Technical Training Course Sampler
AESA Airborne Radar Theory and Operations Technical Training Course SamplerAESA Airborne Radar Theory and Operations Technical Training Course Sampler
AESA Airborne Radar Theory and Operations Technical Training Course Sampler
 
Ati space, satellite,aerospace,engineering technical training courses catalog...
Ati space, satellite,aerospace,engineering technical training courses catalog...Ati space, satellite,aerospace,engineering technical training courses catalog...
Ati space, satellite,aerospace,engineering technical training courses catalog...
 
Spacecraft RF Communications Course Sampler
Spacecraft RF Communications Course SamplerSpacecraft RF Communications Course Sampler
Spacecraft RF Communications Course Sampler
 
New catalog of ATI courses on Space, Satellite, Radar, Missile, Defense & Sys...
New catalog of ATI courses on Space, Satellite, Radar, Missile, Defense & Sys...New catalog of ATI courses on Space, Satellite, Radar, Missile, Defense & Sys...
New catalog of ATI courses on Space, Satellite, Radar, Missile, Defense & Sys...
 
Communications Payload Design and Satellite System Architecture: Bent Pipe a...
Communications Payload Design and  Satellite System Architecture: Bent Pipe a...Communications Payload Design and  Satellite System Architecture: Bent Pipe a...
Communications Payload Design and Satellite System Architecture: Bent Pipe a...
 
ATI_Space_Satellite_Radar_Defense_Sonar_Acoustics_Technical_Training_Courses_...
ATI_Space_Satellite_Radar_Defense_Sonar_Acoustics_Technical_Training_Courses_...ATI_Space_Satellite_Radar_Defense_Sonar_Acoustics_Technical_Training_Courses_...
ATI_Space_Satellite_Radar_Defense_Sonar_Acoustics_Technical_Training_Courses_...
 
Ati courses technical training professional courses catalog development space...
Ati courses technical training professional courses catalog development space...Ati courses technical training professional courses catalog development space...
Ati courses technical training professional courses catalog development space...
 
Software Defined Radio Engineering course sampler
Software Defined Radio Engineering course samplerSoftware Defined Radio Engineering course sampler
Software Defined Radio Engineering course sampler
 
ATI Catalog Of Space, Satellite, Radar, Defense and Systems Engineering Techn...
ATI Catalog Of Space, Satellite, Radar, Defense and Systems Engineering Techn...ATI Catalog Of Space, Satellite, Radar, Defense and Systems Engineering Techn...
ATI Catalog Of Space, Satellite, Radar, Defense and Systems Engineering Techn...
 
Satellite RF Communications and Onboard Processing Course Sampler
Satellite RF Communications  and Onboard Processing Course SamplerSatellite RF Communications  and Onboard Processing Course Sampler
Satellite RF Communications and Onboard Processing Course Sampler
 
Fundamentals of Passive and Active Sonar Technical Training Short Course Sampler
Fundamentals of Passive and Active Sonar Technical Training Short Course SamplerFundamentals of Passive and Active Sonar Technical Training Short Course Sampler
Fundamentals of Passive and Active Sonar Technical Training Short Course Sampler
 
Space Environment & It's Effects On Space Systems course sampler
Space Environment & It's Effects On Space Systems course samplerSpace Environment & It's Effects On Space Systems course sampler
Space Environment & It's Effects On Space Systems course sampler
 
Bioastronautics: Space Exploration and its Effects on the Human Body Course S...
Bioastronautics: Space Exploration and its Effects on the Human Body Course S...Bioastronautics: Space Exploration and its Effects on the Human Body Course S...
Bioastronautics: Space Exploration and its Effects on the Human Body Course S...
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Último (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

ATI Technical Training Short Course Aerospace Simulations In C++

  • 1. Professional Development Short Course On: Aerospace Simulations In C++ Instructor: Dr. Peter Zipfel ATI Course Schedule: http://www.ATIcourses.com/schedule.htm http://www.aticourses.com/aerospace_simulations_in_C++.htm ATI's Aerospace Simulations In C++ :
  • 2. Aerospace Simulations in C++ Apply the power of C++ to simulate multi-object aerospace vehicles $1995 Summary This four-day course introduces engineers and programmers to object oriented programming of aerospace vehicle simulations. Building on your basic understanding of C++, this course will bring Participants may bring an IBM compatible laptop with Microsoft Visual NEW! alive polymorphism, inheritance and encapsulation C++ 2005 or 2008 installed (free download) or Visual FORTRAN 6.1 by hands-on experimentation with simulations of or later (currently sold by Intel). satellites, unmanned combat air vehicles, and air intercept missiles. Lecture and computer lab will guide you from single object architectures to Course Outline multiple interacting vehicles. Demonstrations on 1. Building the Satellite Simulation. Reviewing C++ basics. Modeling modeling of aerodynamics, propulsion, flight three DoF equations of motions. Introducing the satellite simulation control and navigation & guidance assume some architecture making use of inheritance. Running your first simulation in familiarity with these disciplines. You will take MS Visual C++. Exploring the characteristics of satellite trajectories. home five simulations with plotting utilities, ready 2. Building the Truck Simulation. Converting to the truck simulation. to run, and the instructor’s textbook Modeling and Understanding C++ input, and object replication. Experimenting with Simulation of Aerospace Vehicle Dynamics. multiple vehicles moving on the ground. 3. Building the Unmanned Combat Air Vehicle (UCAV) Simulation. Understanding aerodynamic and propulsion modeling. Applying run-time Hands-On Training polymorphism to the UCAV class hierarchy. Understanding flight control. During this course, under the instructor’s Exploring utility classes and operator overloading. Using output files for guidance, you gain extensive C++ experience plotting. Understanding navigation and guidance. Combining UCAV and working ‘real-world’ aerospace simulations on truck targets for attack trajectory studies. supplied PCs: 4. Merging the Satellite, Truck and UCAV Simulations. Studying the • Compiling and running C++ simulations in MS run-time interface communication among the vehicles. Running multi- Visual C++ vehicle, multi-object trajectories and displaying them graphically. • Defining and using classes 5. Investigating the Air Intercept Missile Simulation. Understanding a • Building class hierarchies typical six DoF missile simulation. Modeling interaction of missiles and targets. Conducting air-to-air engagement studies. • Reading and writing formatted I/O • Applying run-time polymorphism • Running, plotting and interpreting satellite, Included with this short course is the instructor’s text book UCAV and missile trajectories “Modeling and Simulation of Aerospace Vehicle Dynamics”, a complete set of course notes, five C++ simulations, and a free CD-ROM with CADAC-Studio for plotting. Instructor Dr. Peter Zipfel is an Adjunct Associate Professor at the University of Florida and has What You Will Learn taught courses in Modeling & Simulation in C++, • Exploiting the rich features of C++ for aerospace application Flight Dynamics, Guidance and Control for the last • How to use classes and inheritance to build vehicle objects twenty years. His forty years of M&S experience • How run-time polymorphism makes multi-object simulations possible in helicopters, missiles, aircraft and hypersonic • How the run-time interface communicates among vehicles vehicles was acquired at the German Helicopter • Understanding three and six DoF aerospace simulations Institute, the U.S. Army and U.S. Air Force and his • How a vehicle is subdivided into subsystem modules consulting business Modeling and Simulation • How aerodynamics, propulsion, guidance and control are modeled Technologies. Having given short courses on M&S • How C++ facilitates the data exchange between subsystems in the UK, Germany, France and the U.S. he is an internationally recognized lecturer. Recently he • Running aerospace simulations authored the text book Modeling and Simulation of • How to set up input in C++ • How to execute and record the output Aerospace Vehicle Dynamics. • How to plot and interpret the trajectories of satellites, aircraft and missiles Register online at www.ATIcourses.com or call ATI at 888.501.2100 or 410.531.6034
  • 3. e e at at lic l ia om lic up er .c up at D es D IM ot rs ot N om AT ou N o Ic o D .c • AT l • D l ia www.ATIcourses.com es te l• er rs a ia w. a ic at om er w ri ou pl M w ate .c at Ic u TI D es M M Boost Your Skills •A ot rs TI 349 Berkshire Drive I AT w. N ou A te Riva, Maryland 21140 AT with On-Site Courses w Do Ic te • .c ca Telephone 1-888-501-2100 / (410) 965-8805 te om es li ca l• om a rs up Tailored to Your Needs Fax (410) 956-5785 w .c lic ia w. li ou D Email: ATI@ATIcourses.com w up er es up AT Ic ot at w D rs D AT N M The Applied Technology Institute specializes in training programs for technical professionals. Our courses keep you ot ou ot o current in the state-of-the-art technology that is essential to keep your company on the cutting edge in today’s highly N I Ic N w. D AT competitive marketplace. Since 1984, ATI has earned the trust of training departments nationwide, and has presented o AT Do l• D on-site training at the major Navy, Air Force and NASA centers, and for a large number of contractors. Our training ia l• increases effectiveness and productivity. Learn from the proven best. w. • er w ial ia w at er w er For a Free On-Site Quote Visit Us At: http://www.ATIcourses.com/free_onsite_quote.asp IM at at IM AT IM For Our Current Public Course Schedule Go To: http://www.ATIcourses.com/schedule.htm w AT AT
  • 4. Building Aerospace Simulations in C++ Lab2 Classes … build your world of hierarchies Lab Topics Simulation • CRUISE is built on the Cadac hierarchy 1 C++ Essentials QuickStart CRUISE • The classes of CADAC++ 2 Classes CRUISE_2 • Multiple encapsulated objects Satellite Simulation 3 Modules CRUISE_3 • The Cadac hierarchy Target Simulation Tables • Abstract base class Cadac 4 CRUISE_4 UAV Uncontrolled Events • Round3 inherits from Cadac 5 CRUISE_5 UAV Controlled • Cruise inherits from Round3 Polymorphism 6 CRUISE_6 UAV Navigation • Target inherits from Round3 ComBus 7 CRUISE_7 UAV Homing • Satellite inherits from Round3 Architectures 8 UAV Netcentric CRUISE • What you have learned ♣ SCHEDULE Copyright © 2009 Modeling and Simulation Technologies
  • 5. Lab2 Classes CRUISE is built on the Cadac hierarchy • Cadac is the abstract base class Classes – Characterized by the fact that it contains pure virtual functions • Round3 class is derived from Cadac – Provides the structure for the equations of motion • Cruise, Target, and Satellite classes are derived from Round3 – These classes declare the vehicle types with names: CRUISE3, TARGET3, and SATELLITE3 • Modules are member functions of the derived classes – They define the mathematical models of the vehicle components • Other classes support the simulation architecture ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 2
  • 6. Lab2 Classes The classes of CADAC++ CLASS DESCRIPTION CADAC Cadac, ... Hierarchical class structure of vehicles Hierarchy Vehicle Hosting a pointer array of type Cadac Module Storing module information Variable Declaring module-variables Event Storing event information Packet Declaring data packets for global communication bus Datadeck Hosting a pointer array of type Table Table Storing tabular data Matrix Storing matrix operations Document Storing module-variable definitions ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 3
  • 7. Lab2 Classes Multiple encapsulated objects • Each aerospace vehicle is an object created from its hierarchical class structure – Data and methods (member functions) are encapsulated • Aerodynamic and propulsion data tables • Vehicle characteristics are computed in module functions – Cadac is the abstract base class • Examples Cruise Missile Air Engagement Aircraft Simulation Simulation Simulation Cadac Cadac Cadac Round3 Flat6 Flat6 Flat3 Target Cruise Satellite Plane Missile Recce Target • Polymorphism enables the call of the vehicle objects during run-time Inheritance – Inheritance enables a derived object to acquire the properties of the base object Run-Time Polymorphism – Virtual functions are overridden until the correct module is executed ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 4
  • 8. Lab2 Classes The Cadac hierarchy Abstract base class Cadac Hierarchy Virtual functions Derived class Round3 newton ( ) round3 [ ] environment ( ) Virtual functions Derived class Target Cruise Satellite target [ ] cruise [ ] satellite [ ] Module-Variable arrays aerodynamics ( ) propulsion ( ) SATELLITE3 forces ( ) Vehicle names TARGET3 CRUISE3 targeting () seeker ( ) guidance ( ) control ( ) Communication bus combus [ ] intercept () aerodynamics ( ) propulsion ( ) forces ( ) newton ( ) intercept ( ) Modular structure seeker ( ) control ( ) guidance ( ) environment ( ) SCHEDULE targeting ( ) ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 5
  • 9. Lab2 Classes Abstract base class Cadac • Cadac declares – Pointers of module-variable arrays Run-Time – Pure virtual functions for the executive processes Polymorphism – Pure virtual functions for the modules class Cadac { private: char name[CHARN]; //vehicle object name protected: //module-variable array of class 'Round3' CRUISE_2 Variable *round3; //module-variable array of class 'Cruise' Variable *cruise; //module-variable array of class 'Target' Variable *target; //module-variable array of class 'Satellite' Variable *satellite; class Variable public: { Cadac(){} private: virtual~Cadac(){}; char name[CHARN]; //executive functions char type[CHARN]; //pure virtual functions double rval; virtual void sizing_arrays()=0; int ival; .... Matrix VEC; //module functions Matrix MAT; //... pure virtual functions char def[CHARL]; }; char mod[CHARN]; char role[CHARN]; char out[CHARN]; public: //methods for initialization //methods for reading and loading ♣ }; MaSTech © 2009 Building Aerospace Simulations in C++ 6
  • 10. Lab2 Classes Round3 inherits from Cadac • Spherical rotating Earth, 3 degrees of freedom • void Round3::environment(…) – ISO 62 standard atmosphere – Newton’s gravitational acceleration (inverse square law) • void Round3::newton(…) – Equations of motion are integrated in inertial coordinates – Conversion of input and output from/to geographic coordinates CRUISE_2 class Round3:public Cadac { protected: //declaring index arrays which identify module-variables for output public: Round3(); virtual~Round3(){}; //executive functions //... pure virtual functions //module functions //... pure virtual functions //virtual functions to be defined in this class virtual void def_environment(); virtual void init_environment(...); virtual void environment(...); virtual void def_newton(); virtual void init_newton(); virtual void newton(...); ♣ }; MaSTech © 2009 Building Aerospace Simulations in C++ 7
  • 11. Lab2 Classes Cruise inherits from Round3 class Cruise:public Round3 • Bank-to-turn UAV { protected: void Cruise::aerodynamics(); //name of “CRUISE3” vehicle object char cruise3_name[CHARL]; Modules Drag polar //array pointers ... void Cruise::propulsion(...); public: Cruise(){}; Cruise(...); Turbojet virtual~Cruise(); void Cruise::forces(); //executive functions ... Aerodynamic and propulsive //module functions void Cruise::control(...); virtual void aerodynamics(); virtual void propulsion(...); CRUISE_2 virtual void forces(); Heading, flight path, bank angle, load virtual void control(...); virtual void guidance(); factor, altitude hold virtual void targeting(...); virtual void seeker(...); void Cruise::guidance(); virtual void intercept(...); Line, pro-nav, point, arc //functions of control module double control_heading(...); void Cruise::targeting(...); double control_flightpath(...); double control_bank(...); double control_load(...); Satellite targeting double control_lateral(...); double control_altitude(...); void Cruise::seeker(...); //functions of guidance module Line-of-sight seeker Matrix guidance_line(); Matrix guidance_pronav(); void Cruise::intercept(...); Matrix guidance_point(); double guidance_arc(); double guidance_spline(); Waypoint and target miss distance //functions of seeker module void seeker_grnd_ranges(...); //functions of targeting module void targeting_satellite(...); void targeting_grnd_ranges(...); ♣ }; MaSTech © 2009 Building Aerospace Simulations in C++ 8
  • 12. Lab2 Classes Target inherits from Round3 CADAC class Target:public Round3 Hierarchy { protected: //name of “TARGET3” vehicle object char target3_name[CHARL]; //array pointers ... public: Target(){}; CRUISE_2 Target(...); virtual~Target(); //executive functions ... • Target over the round, rotating Earth //module function dummy returns virtual void def_aerodynamics(){}; void Target::forces(); ... //module functions active Compensating for Coriolis and virtual void forces(); centrifugal accelerations virtual void intercept(...); ♣ }; void Target::intercept(...); Setting target status (alive, hit, dead) MaSTech © 2009 Building Aerospace Simulations in C++ 9
  • 13. Lab2 Classes Satellite inherits from Round3 class Satellite:public Round3 { protected: //name of ”SATELLITE3” vehicle object char satellite3_name[CHARL]; //array pointers ... public: Satellite(){}; CRUISE_2 Satellite(...); virtual~Satellite(); //executive functions ... //module function dummy returns • Target over the round, rotating Earth virtual void def_aerodynamics(){}; void Satellite::forces(); ... //module functions active Mass properties and optional thrusting virtual void forces(); void Satellite::seeker(...); virtual void seeker(...); ♣ Radar seeker (simplified) }; MaSTech © 2009 Building Aerospace Simulations in C++ 10
  • 14. Lab2 Classes What you have learned • Class structure of the CADAC++ architecture • Cadac is an abstract base class • The class hierarchy declares the vehicle objects Cruise, Target, and Satellite • The vehicle objects are named CRUISE3, TARGET3, and SATELLITE3 in the ‘input.asc’ file • Modules are member functions (methods) of the derived classes • Use of access specifiers • Use of constructors and destructors ♣ SCHEDULE MaSTech © 2009 Building Aerospace Simulations in C++ 11
  • 15. Building Aerospace Simulations in C++ Lab2 Satellite Simulation … is the simplest simulation • Features of satellite simulation Lab Topics Simulation C++ Essentials • Class hierarchy of satellite simulation 1 CRUISE QuickStart • Equations of motions are derived from Classes 2 Satellite Simulation CRUISE_2 Newton’s Law 3 Modules Target Simulation CRUISE_3 • Inertial and Earth coordinate systems 4 Tables UAV Uncontrolled CRUISE_4 • Earth and geographic coordinate systems 5 Events UAV Controlled CRUISE_5 • Geographic and flight path coordinate system 6 Polymorphism CRUISE_6 • Geographic initialization UAV Navigation 7 ComBus CRUISE_7 • Solving the equations of motion UAV Homing Architectures • Circular orbiting satellite over the equator 8 CRUISE UAV Netcentric • What you have learned ♣ SCHEDULE Copyright © 2009 Modeling and Simulation Technologies
  • 16. Lab2 Satellite Simulation Features of satellite simulation • 3 DoF, round, rotating Earth; • Coordinates: longitude, latitude, altitude • Newton’s equations solved in inertial coordinates • Conversion from geographic to inertial coordinates and vice versa • Propulsion is optional ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 2
  • 17. Lab2 Satellite Simulation Class hierarchy of satellite simulation Abstract base class Cadac Virtual functions Derived class Round3 newton ( ) round3 [ ] environment ( ) Module- Derived class Variable arrays Satellite forces () satellite [ ] SATELLITE3 environment ( ) forces ( ) newton ( ) Modular structure ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 3
  • 18. Lab2 Satellite Simulation Equations of motions are derived from Newton’s Law Zipfel, p. 261 * Newton’s Law mD I v IB = f a , p + mg Relationship of inertial and geographic velocities v IB = v E + Ω EI s BI B Matrix equations programmed in ‘newton’ module ( m [dvB / dt ]I = [T ]GI [T ]VG [ f a , p ]V + m [ g ]G I ) I Inertial coordinates [dsBI / dt ] = [v ] I I I B G Geographic coordinates * “Modeling and V Flight path coordinates Simulation of Aerospace Vehicle Dynamics”, AIAA Education Series, 2nd ♣ Edition, 2007 MaSTech © 2009 Building Aerospace Simulations in C++ 4
  • 19. Lab2 Satellite Simulation Inertial and Earth coordinate systems • Inertial coordinate system 1I axis is aligned with the Vernal Equinox 3I axis is aligned with the spin axes of the Earth Zipfel, p. 71 • Angle Ξ is the hour angle • The transformation matrix of Earth wrt inertial coordinates is ⎡ cos Ξ sin Ξ 0⎤ [T ]EI = ⎢− sin Ξ cos Ξ 0⎥ ♣ ⎢ ⎥ ⎢ ⎣ 0 0 1⎥ ⎦ MaSTech © 2009 Building Aerospace Simulations in C++ 5
  • 20. Lab2 Satellite Simulation Earth and geographic coordinate systems • Earth coordinate system 1E axis is at the intersection of the Greenwich Meridian and the equator 3E axis is aligned with the spin axis of the Earth Zipfel, p. 72 • Geographic coordinate system 1G axis points to the north pole 3G axis point to the center of the Earth • l longitude • λ latitude • TM sequences through two intermediate coordinate systems X and Y [T ]GE = [T (180o )]GY [T (90o − λ )]YX [T (l )]XE • The TM of geographic wrt Earth coordinates is ⎡ − sin λ cos l − sin λ sin l cos λ ⎤ [T ]GE = ⎢ − sin l cos l 0 ⎥♣ ⎢ ⎥ ⎢− cos λ cos l − cos λ sin l − sin λ ⎥ ⎣ ⎦ MaSTech © 2009 Building Aerospace Simulations in C++ 6
  • 21. Lab2 Satellite Simulation Geographic and flight path coordinate system • Geographic coordinate system 1G axis points to the north pole 1V 3G axis point to the center of the Earth • Flight path coordinate system Zipfel, p. 80 1G 2V 2G X 1V axis parallel and in the direction of the 2X 1 velocity vector 2V axis is horizontal and points to the right 3V 3V axis point “down” • χ heading angle (chi) X 3 = 3G • γ flight-path angle • The TM of flight path wrt geographic coordinates is [T ]VG = [T (γ )]VX [T ( χ )] XG ⎡cos γ 0 − sin γ ⎤ ⎡ cos χ sin χ 0⎤ ⎡cos γ cos χ cos γ sin χ − sin γ ⎤ [T ]VG =⎢ 0 1 0 ⎥ ⎢− sin χ cos χ 0⎥ = ⎢ − sin χ cos χ 0 ⎥ ♣ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ sin γ ⎣ 0 cos γ ⎥ ⎣ 0 ⎦⎢ 0 1⎥ ⎢ sin γ cos χ ⎦ ⎣ sin γ sin χ cos γ ⎥⎦ MaSTech © 2009 Building Aerospace Simulations in C++ 7
  • 22. Lab2 Satellite Simulation Geographic initialization • Geographic initialization converted to inertial position and velocity CRUISE_2 Implemented in: void Round3::init_newton() E Geographic speed | vB | χ Heading angle γ Flight path angle | v B | , χ , γ , l, λ , h E l Longitude λ Latitude h Altitude E | vB | [T ]GE = cadtge( l, λ) [ s BI ] I [sBI ]E = [T ]EG[sBI ]G Inertial position [vB ]G = cart_ from_ pol | vB |, χ, γ E E ( ) [v B ] I I Inertial velocity [T ] = [E] IE GV [T ]IG = [T ]IE[T ]EG [T ] T.M. of geographic wrt flight path coor. [vB ]I = [T ]IG[vB ]G + [ΩEI ]I [sBI ]I I E [T ] IG T.M. of inertial wrt geographic coor. VG [T ] = mat2tr( χ, γ ) [T ]GV = [T ]VG ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 8
  • 23. Lab2 Satellite Simulation Solving the equations of motion • Integrating inertial states and converting them to geographic output CRUISE_2 Implemented in: void Round3::newton(double int_step) [ f sp ]V Propulsive specific force ( [ dvB / dt ]I = [T ]IG [T ]GV [ f sp ]V + [ g ]G I ) [ dsBI / dt ]I = [ vB ]I I E | vB | [T ] EI = cadtei (time) χ γ [ s BI ] E = [T ] EI [ s BI ] I (l , λ , h ) = cadsph ([ s BI ]E ) l λ [T ]GE = cadtge (l , λ ) h [T ]GI = [T ]GE [T ] EI ( [v B ]G = [T ]GI [v B ] I − [Ω EI ] I [ s BI ] I E I ) ( | v B |, χ , γ E ) = pol _ from _ cart ( [v B ]G E ) [T ] VG = mat 2tr ( χ , γ ) [T ]GV = [T ]VG ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 9
  • 24. Lab2 Satellite Simulation Circular orbiting satellite over the equator Input alt 300000 //Vehicle altitude - m module newton psivgx 90 //Vehicle heading angle - deg module newton CRUISE_2 thtvgx 0 //Vehicle flight path angle - deg module newton dvbe 7243.2 //Vehicle speed - m/s module newton Satellite inertial speed G×M⊕ | v B |= I R⊕ + alt Earth circumferential speed at equator | Δv |= (R⊕ + alt )ω EI ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 10
  • 25. Lab2 Satellite Simulation What you have learned • The core of the simulation, i.e., the ‘newton’ module, simulates satellite orbits • Key coordinate systems – Inertial, Earth, geographic and flight path angle • Newton’s equations of motion are integrated in inertial coordinates • Input/output conversion are from geographic to inertial coordinates and back ♣ HandsOn2 SCHEDULE MaSTech © 2009 Building Aerospace Simulations in C++ 11
  • 26. Building Aerospace Simulations in C++ Lab2 HandsOn2 … let’s start with a simple class structure and simulation • HandsOn2_1 Duplicate the satellite trajectory • HandsOn2_2 Add the module ‘seeker’ to the ‘Satellite’ class • HandsOn2_3 Find the constructor and destructor of the ‘Satellite’ class SCHEDULE • HandsOn2_4 Raise the satellite orbit by thrusting Copyright © 2009 Modeling and Simulation Technologies
  • 27. HandsOn2 HandsOn2_1 Duplicate the satellite trajectory 1. Load the CRUISE_2 project and run the test case with input file ‘input2_1.asc’ 2. Plot the trajectory with the KPLOT-GLOBE program and thus duplicate the circular satellite trajectory over the equator, as shown in Slide 10 of ‘Lab2 Satellite Simulation’ 3. What is the deviation in percent from the starting altitude? 4. Reduce and increase the integration step size by an order of magnitude Result2_1 - How does the integration step size effect the accuracy? ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 2
  • 28. HandsOn2 HandsOn2_2 Add the module ‘seeker’ to the ‘Satellite’ class • For future usage, the ‘Satellite’ class needs a ‘seeker’ module. Provide two skeleton member functions ‘def_seeker()’ and ‘seeker(…)’ as place holders in the file ‘satellite_modules.cpp’ 1. In file ‘satellite_modules.cpp’ add the skeleton of ‘def_seeker()’ and ‘seeker(…)’ following the example of functions ‘def_forces()’ and ‘forces()’, without code inside the function scopes 2. Declare the two new functions in the class ‘Satellite’ of the header file ‘class_hierarchy.hpp’ Result2_2 3. Check your modifications by recompiling ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 3
  • 29. HandsOn2 HandsOn2_3 Find the constructor and destructor of the ‘Satellite’ class 1. Locate the constructor of the ‘Satellite’ class What is the purpose of the parameters? What memory allocations occur? 2. Locate the destructor of the ‘Satellite’ class Result2_3 What action does the destructor perform? ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 4
  • 30. HandsOn2 HandsOn2_4 Raise the satellite orbit by thrusting • In the ‘force’ module a constant thrust force can be applied to the satellite 1. Augment the input file ‘input2_1.asc’ with the satellite thrust variable 2. Determine what thrust is required to increase the satellite altitude by 100 km after one orbit Result2_4 3. Make a plot with KPLOT-GLOBE ♣ SCHEDULE MaSTech © 2009 Building Aerospace Simulations in C++ 5
  • 31. Building Aerospace Simulations in C++ Lab2 Result2 … let’s start with a simple class structure and simulation • Result2_1 Duplicate the satellite trajectory • Result2_2 Add the module ‘seeker’ to the Satellite class • Result2_3 Find the constructor and destructor of the ‘Satellite’ class SCHEDULE • Result2_4 Raise the satellite orbit by thrusting Copyright © 2009 Modeling and Simulation Technologies
  • 32. Result2 Result2_1 Duplicate the satellite trajectory 1 & 2 Self explanatory 3. The deviation form the starting altitude is 0.33% 4. Integration step size - increased by order of magnitude the error is 3.3% - decreased by order of magnitude the error is 0.031% MaSTech © 2009 Building Aerospace Simulations in C++ 2
  • 33. Result2 Result2_2 Add the module ‘seeker’ to the Satellite class CRUISE_2 • For the implementation of the two member functions ‘def_seeker()’ and ‘seeker(…)’, look into the file ‘satellite_modules.cpp’ and ‘class_hierarchy.hpp’ of the CRUISE simulation ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 3
  • 34. Result2 Result2_3 Find the constructor and destructor of the ‘Satellite’ class CRUISE_2 1. The constructor is located in file ‘class_functions.cpp’ The parameter list consists of the pointer to the module array and the size of the module array Dynamic memory allocation is made for Module variable array ‘satellite’ Combus index arrays ‘round3_com_ind’ and ‘com_satellite3’ 2. The destructor is located in file ‘class_functions.cpp’ It releases the dynamic memory allocated of the ‘Satellite’ members ‘satellite’, ‘round3’, ‘round3_com_ind,; ‘satellite_com_ind’, ‘com_satellite3’ MaSTech © 2009 Building Aerospace Simulations in C++ 4
  • 35. Result2 Result2_4 Raise the satellite orbit by thrusting CRUISE_2 Required thrust to raise satellite by 100km SCHEDULE sat_thrust = 1.03 N MaSTech © 2009 Building Aerospace Simulations in C++ 5
  • 36. Building Aerospace Simulations in C++ Lab3 Modules … model the vehicle components • Modules form the core of the simulation Lab Topics Simulation • Module-variables interface between modules C++ Essentials 1 QuickStart CRUISE • Three functions compose the ‘newton’ module 2 Classes CRUISE_2 • Modules are called every integration cycle Satellite Simulation Modules • Module-variables are of type Variable 3 CRUISE_3 Target Simulation • Example code of module ‘newton’ Tables 4 UAV Uncontrolled CRUISE_4 • How to build a module 5 Events CRUISE_5 • Matrix utility operations UAV Controlled Polymorphism • Matrix class and methods 6 CRUISE_6 UAV Navigation • More examples of Matrix methods ComBus 7 CRUISE_7 UAV Homing • Utility functions of class Matrix SCHEDULE Architectures 8 UAV Netcentric CRUISE • What you have learned ♣ SCHEDULE Copyright © 2009 Modeling and Simulation Technologies
  • 37. Lab3 Modules Modules form the core of the simulation • Modules are public functions (methods) of the classes Round3, Cruise, Satellite and Target • The structure Module declares the type of the elements in the ‘module_list’ array CRUISE_3 • The module list and calling sequence is established in the ‘input.asc’ file • Coding of the modules is greatly simplified by matrix equations • The class Matrix enables the straightforward writing of matrix equations ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 2
  • 38. Lab3 Modules Module-variables interface between modules • CADAC’s modular structure mirrors the hardware components of an aerospace vehicle – A module is a model of a vehicle component • Examples: aerodynamics, propulsion, actuator, guidance, control,… – Each module consists of at least two functions and possibly four: • def_module(), init_module(), module(), term_module() • The calling order of the module is controlled by the input file Module-Variable • Data between modules is transferred by module-variables Arrays – Module-variables, being the only allowed interface, are strictly controlled – Each vehicle object reserves protected arrays for its module-variables – There is a one-to-one relationship between the module-variable name and the array location CRUISE_3 – The file ‘doc.asc’ documents all module-variables • Module-variables can only be of type int, double, 3x1 vector, and 3x3 matrix • Inside a module – Module-variables are localized as input from other modules – Computations create new module-variables – These are loaded onto the object’s array for output ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 3
  • 39. Lab3 Modules Three functions compose the ‘newton’ module void Round3::def_newton() Definition of module-variables used in this module void Round3::init_newton () Initial calculations void Round3::newton(double int_step) Integrations and time-phased calculations Integration loop ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 4
  • 40. Lab3 Modules Modules are called every integration cycle Calling sequence established in input.asc MODULES environment def,init,exec struct Module aerodynamics def,exec { propulsion def,init,exec string name; forces def,exec string definition; newton def,init,exec string initialization; targeting def,exec string execution; seeker def,exec string termination; guidance def,exec }; control def,exec intercept def,exec END Loading modules into module_list void order_modules(fstream &input,int &num,Module *module_list) Module calling //Vehicle’s constructor calls module to define module-variables if((module_list[j].name==“newton")&&(module_list[j].definition=="def")) def_newton(); //Module is initialized in ‘main()’ if((module_list[j].name==“newton")&&(module_list[j].initialization=="init")) vehicle_list[i]->init_newton(); //Every integration step, module is called in ‘execute(…)’ if(module_list[j].name==“newton") vehicle_list[i]->newton(int_step); ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 5
  • 41. Lab3 Modules Module-variables are of type Variable class Variable { Defining module-variables in void Round3::def_newton() private: char name[CHARN]; round3[19].init("lonx",0,"Vehicle longitude - deg","newton","diag","scrn,plot,com"); char type[CHARN]; double rval; round3[20].init("latx",0,"Vehicle latitude - deg","newton","diag","scrn,plot,com"); int ival; Matrix VEC; round3[21].init("alt",0,"Vehicle altitude - m","newton","out","scrn,plot,com"); Matrix MAT; char def[CHARL]; Documenting module-variables in doc.asc char mod[CHARN]; char role[CHARN]; char out[CHARN]; Round3 Module-Variable Array public: methods to initialize --------------------------------------------------------------------------------------------------------------------- |LOC| NAME | DEFINITION | methods to read OUTPUT MODULE | PURPOSE | and load| --------------------------------------------------------------------------------------------------------------------- }; ………………………………………………………… 19 lonx Vehicle longitude - deg newton diag scrn,plot,com 20 latx Vehicle latitude - deg newton diag scrn,plot,com 21 alt Vehicle altitude - m newton out scrn,plot,com ………………………………………………………… Using module-variables void Round3::newton(double int_step) { //localizing module-variables //input from other modules double time=round3[0].real(); Matrix FSPV=round3[10].vec(); ... //----------------------------------------- ... computations ... //------------------------------------------- //loading module-variables //state variables round3[35].gets_vec(SBII); round3[36].gets_vec(VBII); ♣ ... } MaSTech © 2009 Building Aerospace Simulations in C++ 6
  • 42. Lab3 Modules Example code of module ‘newton’ CRUISE_3 void Round3::def_newton() { name, value, definition, module, type, out to: screen, plot file, combus Definition of //Definition of module-variables module-variables round3[19].init("lonx",0,"Vehicle longitude-deg","newton","diag","scrn,plot,com"); round3[20].init("latx",0,"Vehicle latitude-deg","newton","diag","scrn,plot,com"); in array ‘round3[ ]’, round3[21].init("alt",0,"Vehicle altitude-m","newton","out","scrn,plot,com"); a member of class ... ‘Round3’ }void Round3::init_newton() { ........................ } void Round3::newton(double int_step) { //localizing module-variables Getting module- //input from other modules double time=round3[0].real(); variables from Matrix FSPV=round3[10].vec(); ‘round3[ ]’ array double grav=round3[11].real(); Matrix WEII=round3[27].mat(); //state variables Matrix SBII=round3[35].vec(); Matrix VBII=round3[36].vec(); Matrix ABII=round3[37].vec(); ... //------------------------------------------------------------------------- //building gravitational vector in geographic coordinates GRAV.assign_loc(2,0,grav); //integrating inertial state variables Computations ABII_NEW=TIG*((TGV*FSPV)+GRAV); VBII_NEW=integrate(ABII_NEW,ABII,VBII,int_step); SBII=integrate(VBII_NEW,VBII,SBII,int_step); ABII=ABII_NEW; VBII=VBII_NEW; ... //------------------------------------------------------------------------- //loading module-variables Loading module- //state variables variables onto round3[35].gets_vec(SBII); round3[36].gets_vec(VBII); ‘round3[ ]’ array round3[37].gets_vec(ABII); ♣ ... } MaSTech © 2009 Building Aerospace Simulations in C++ 7
  • 43. Lab3 Modules How to build a module 1. Start with sample module as template Example: Newton Module 2. Reserve contiguous slots in the module-array 3. In ‘def_module’ categorize module-variables as ///////////////////////////////////////////////// //Definition of newton module-variables "data" input data values //Member function of class 'Round3' "init" initialized in init_module //Module-variable locations are assigned // to round3[17-39] "state" state variables for integration //000624 Created by Michael Chiaramonte "out" output to other modules ///////////////////////////////////////////////// "diag" diagnostic, not used by other modules void Round3::def_newton() { "save" value saved for next cycle 4. In ‘module’ localize module-variables by category //Definition of module-variables round3[19].init("lonx",0,"Vehicle longitude-d //input data round3[20].init("latx",0,"Vehicle latitude-deg //restore saved values round3[21].init("alt",0,"Vehicle altitude-m"," //state variables }void Round3::init_newton() //input from other modules { 5. Insert computations ........................ } 6. In ‘module’ load module-variables by category void Round3::newton(double int_step) CRUISE_3 //state variables { //saving values //localizing module-variables //input from other modules //output to other modules double time=round3[0].real(); //diagnostics Matrix FSPV=round3[10].vec(); double grav=round3[11].real(); 7. Incorporate new module into simulation frame Matrix WEII=round3[27].mat(); //state variables Definition module is called once, before ‘input.asc’ Matrix SBII=round3[35].vec(); Matrix VBII=round3[36].vec(); Defines all module-variables Matrix ABII=round3[37].vec(); ... Directs variables to output streams //------------------------------------------ Initialization module is called once, after ‘input.asc’ //building gravitational vector in geographic GRAV.assign_loc(2,0,grav); Executes initial calculations Module is called once every integration step //integrating inertial state variables ABII_NEW=TIG*((TGV*FSPV)+GRAV); Localizes module-variables VBII_NEW=integrate(ABII_NEW,ABII,VBII,int_step); Executes computations every integration step SBII=integrate(VBII_NEW,VBII,SBII,int_step); ABII=ABII_NEW; Integrates state variables VBII=VBII_NEW; ... Calls other subordinate functions //-------------------------------------------- Calls utility subroutines //loading module-variables //state variables Performs table look-up round3[35].gets_vec(SBII); Loads module-variables round3[36].gets_vec(VBII); round3[37].gets_vec(ABII); Watch out ... Initialize all local variables } Don’t call other module’s subordinate functions ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 8
  • 44. Lab3 Modules Matrix utility operations • Source code should be programmed in matrices as much as possible – Compact code – Avoids errors • Requirements of flight simulations – Mostly 3x1 and 3x3 matrices, some of higher dimensions (Kalman filters) – Elements of matrices are of type double • Class Matrix instantiate a pointer to the matrix *pbody and initializes the elements to zero • Examples from module Target::forces() CRUISE_3 //Coriolis acceleration in V-coordinates WEIG=TGE*WEII*TEG; CORIO_V=TVG*WEIG*VBEG*2; //centrifugal acceleration in V-coordinates CENTR_V=TVG*WEIG*WEIG*TGI*SBII; • Special features – All matrix manipulations are carried out in pointer arithmetic – Creating a matrix returns *this of the initialized matrix – Usage of copy constructor for the matrix assignment operator – Overloaded offset operator [] ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 9
  • 45. Lab3 Modules Matrix class and methods class Matrix { •Matrix class is global in scope private: //number of rows • Private methods declare size and int num_row; //number of columns pointer of array int num_col; //total number of elements • Public methods are the int num_elem; //pointer to array constructors/destructor and utility double *pbody; public: functions //default constructors Matrix(); CRUISE_3 //overloaded constructor Matrix(int row_size,int col_size); //copy constructor Matrix(const Matrix &MAT); //destructor ~Matrix(); //printing matrix array to console //////////////////////////////////////////// //Absolute value of vector void print(); //Example: value = VEC.absolute(); //Returns absolute value of a vector VEC //////////////////////////////////////////// //Example: value=VEC.absolute(); double Matrix::absolute() double absolute(); { … }; double ret=0; for(int i=0;i<num_elem;i++) ret+=(*(pbody+i))*(*(pbody+i)); ret=sqrt(ret); return ret; } ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 10
  • 46. Lab3 Modules More examples of Matrix methods /////////////////////////////////////////////////////////////////////////////// //Returns the value at offset-row 'r‘, offset-col 'c' of MAT //Example: value = MAT.get_loc(2,1); (3rd row, 2nd column) ////////////////////////////////////////////////////////////////////////////// double Matrix::get_loc(const int &r,const int &c) { if((r<num_row)&&(c<num_col)) return *(pbody+r*num_col+c); else {cout<<"*** Error: invalid matrix loc. 'Matrix::get_loc()' *** ";exit(1);} } /////////////////////////////////////////////////////////////////////////////// //Builds a square identity matrix of object 'Matrix MAT' //Example: MAT.identity(); /////////////////////////////////////////////////////////////////////////////// Matrix & Matrix::identity() { if (num_row==num_col) { for(int r=0;r<num_row;r++) *(pbody+r*num_row+r)=1; } else {cout<<"*** Error: matrix not square 'Matrix::identiy()'*** ";exit(1);} return *this; } ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 11
  • 47. Lab3 Modules Utility functions of class Matrix Member functions void print(); double absolute(); Matrix adjoint(); void assign_loc(…) Overloaded operators Matrix & build_mat33(…); Matrix & cart_from_pol(…) bool operator!=(const Matrix &B); Matrix col_vec(const int &col); Matrix operator*(const double &b); double determinant(); Matrix operator*(const Matrix &B); Matrix diamat_vec(); Matrix diavec_mat(); Matrix & operator*=(const double &b); void dimension(int row,int col); Matrix & operator*=(const Matrix &B); Matrix ellipse(); CRUISE_3 Matrix operator+(const double &b); int get_cols(); Matrix operator+(const Matrix &B); int get_index(const int &row,const int &col); double get_loc(const int &r,const int &c); Matrix & operator+=(const double &b); double * get_pbody(); Matrix & operator+=(const Matrix &B); int get_rows(); Matrix operator-(const double &b); Matrix & identity(); Matrix operator-(const Matrix &B); Matrix inverse(); Matrix mat33_vec9(); Matrix & operator-=(const double &b); Matrix & ones(); Matrix & operator-=(const Matrix &B); bool operator!=(const Matrix &B); Matrix &operator=(const Matrix &B); Matrix pol_from_cart(); Matrix row_vec(const int &row); bool operator==(const Matrix &B); Matrix skew_sym(); double & operator [](const int &r); Matrix sub_matrix(const int &row, const int &col); double operator^(const Matrix &B); Matrix trans(); Matrix operator~(); Matrix univec3(); Matrix & zero(); Matrix vec9_mat33(); ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 12
  • 48. Lab3 Modules What you have learned • Modules mirror vehicle components • Module loading and calling sequence is established in the input file • Communication between modules is only by module-variables • The value of module-variables is stored in protected arrays of the vehicle classes • Computations in modules are carried out in matrix form, where applicable SCHEDULE • Matrix manipulations use methods of the class Matrix ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 13
  • 49. Building Aerospace Simulations in C++ Lab3 Target Simulation … simulates vehicles moving on the ground Lab Topics Simulation 1 C++ Essentials CRUISE • Features of target simulation QuickStart Classes • Class hierarchy of target simulation 2 CRUISE_2 Satellite Simulation Modules • Equations of motions are compensated 3 CRUISE_3 Target Simulation • Vehicles on the Earth’s surface experience Tables 4 UAV Uncontrolled CRUISE_4 apparent forces 5 Events UAV Controlled CRUISE_5 • Calculating the acceleration compensation 6 Polymorphism UAV Navigation CRUISE_6 • Straight target trajectory 7 ComBus CRUISE_7 • What you have learned ♣ UAV Homing Architectures 8 CRUISE UAV Netcentric SCHEDULE Copyright © 2009 Modeling and Simulation Technologies
  • 50. Lab3 Target Simulation Features of target simulation • Targets move on the surface of the round, rotating Earth – Fixed – Translating – Accelerating • Coordinates: longitude, latitude, altitude • Newton’s equations are compensated with apparent forces ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 2
  • 51. Lab3 Target Simulation Class hierarchy of target simulation CRUISE_3 Abstract base class Cadac Virtual functions Derived class Round3 newton ( ) environment ( ) round3 [ ] Module- Derived class Variable arrays Target forces( ) target [ ] intercept ( ) TARGET3 environment ( ) forces ( ) newton ( ) intercept ( ) Modular structure ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 3
  • 52. Lab3 Target Simulation Equations of motions are compensated • Newton’s Law governs the motion of the target • Compensating forces are applied to constrain the target to the surface of the Earth Newton’s Law with compensation ma comp mD I v I = ma comp + mg B Matrix equations programmed in ‘newton’ module I Inertial coordinates ( [dv B / dt ] I = [T ]GI [T ]VG [acomp ]V + [ g ]G I ) G Geographic coordinates V Flight path coordinates ♣ MaSTech © 2009 Building Aerospace Simulations in C++ 4
  • 53. You have enjoyed ATI's preview of Aerospace Simulations In C++ Please post your comments and questions to our blog: http://www.aticourses.com/wordpress-2.7/weblog1/ Sign-up for ATI's monthly Course Schedule Updates : http://www.aticourses.com/email_signup_page.html