DUECA/DUSIME
Simulation example

This section describes a large part of the SpacePlane model simulation that has been used as an example in this manual.

This simulation derived from an experiment implemented on the Human-Machine Systems lab of the Control and Simulation Division, Faculty of Aerospace Engineering The simulation model of the equations of motion of the spaceplane, including the control augmentation system, was programmed in one Simulink model. Using the Real-Time Workshop (RTW) toolbox, C code was generated for this Simulink model. Input of the RTW code are the pitch and roll stick inputs, and the output of the code is an output vector with all spaceplane motions.

The simulation was controlled with a control loaded side stick. This stick uses a hydraulic servo motor to simulate mechanical properties, in this case the mechanical properties of a passive (mass, spring and damper) stick.

Instrument display was done on a PC with a fast graphics card. The display is drawn using the output of the RTW model.

In addition to the display output, output to file was needed. The stick force and position data, and the spaceplane model output data, were recorded at a 50 Hz rate. Output to the control position of the experiment leader was also needed, during the run some key variables were shown in a window at the experiment leader's position, and key variables at certain points in the experiment (points along the pre-defined trajectory) were also shown and recorded. In this way it was for example possible to see the sink rate at touch down directly after a run.

example_flow

Data Flow diagram

Modules (or Blocks)

The first step in designing the simulation is setting up a (DUECA) data flow diagram. This diagram defines the modules used in the simulation, and the data (types) they send to each other.

spaceplane.png
DUECA data flow diagram for the spaceplane

The data flow diagram contains the following blocks:

These are all the modules that are needed from a model point-of-view. One other module is added for practical reasons. As will be explained in the following, the stick control loading and the spaceplane model run on different computers. The control loading has to run at a high update rate (2000 Hz), and it also produces data at 2000 Hz. The spaceplane model runs slower (50 Hz), and thus it needs every 40th output of the control loading model. Now, without modifications, DUECA would send the stick data at 2000 Hz to the other computers, where only 1/40 th of this data would be used. An additional routine, called RateReduction, which runs in the computer with the stick module, reads the stick data and writes with only 50 Hz.

Data types communicated over channels

The following model-related data types were communicated over the channels:

Here is the file input for the code generator:

(Type double)

(EventAndStream PrimaryControls
        (double stick_roll )
        (double stick_pitch )
        (double roll_moment)
        (double pitch_moment)
        (double roll_rate)
        (double pitch_rate))

(EventAndStream SpacePlaneY
        (double Y 29 ))

(Type int )
(Event DisplaySelect
        (int type ))

Header and implementation files

Here are all header and implementation files for the modules.

You see that there is certainly some code writing in making a module. Fortunately, most of the code can be generated by the script "newModule". This script is installed with the dueca program. Run it with the name of your new module (e.g. MyModule), and it will produce a MyModule.cxx and a MyModule.hxx file. The comments in these files should guide you with the job of tailoring the module to your application.

Model configuration file.

The example simulation runs on 3 PC's, connected with fast ethernet. The division of modules over the PCs is as follows:

Scheme is a full-fledged programming language, and therefore the model configuration file in fact contains a simple program. To make life a bit easier, we can define often-used variables in the model configuration file as Scheme variables. That is what this first part of the configuration file does:

;; document the set-up of the simulation
;; nodes
(define ecs-node 0) ; ecs, dutmms1, send order 1
(define cl-node 1) ; control loading dutmms4, send order 0
(define pfd-node 2) ; primary flight display dutmms2, send order 2
;; default priority set-up
(define admin-priority (make-priority-spec 0 0)) ; admin, interface, logging
(define sim-priority (make-priority-spec 1 0)) ; simulation, unpacking
;; difference; control loading
(if (equal? this-node-id cl-node)
(list
(define stick-priority (make-priority-spec 3 0)) ; cl simulation
)
)
;; timing parameters, basis is a granule size of 500 us
(define stick-timing (make-time-spec 0 1)) ; cl calculation, 2000 Hz
(define sim-timing (make-time-spec 0 40)) ; sim, 50 Hz
(define feedback-timing (make-time-spec 0 400)) ; eval feedback, 5 Hz

Dueca itself also needs some modules. Here they are:

;;; the modules needed for dueca itself
;;; the modules needed for dueca itself
(dueca-list
(make-entity "dueca"
(if (equal? 0 this-node-id)
(list
(make-module 'dusime "" admin-priority 'min-interval 4000)
(make-module 'dueca-view "" admin-priority)
(make-module 'activity-view "" admin-priority)
(make-module 'timing-view "" admin-priority)
)
(list)
)))

And then the modules for the spaceplane are created.

;;; the spaceplane
(define spaceplane
(make-entity "spaceplane"
(if (equal? this-node-id ecs-node)
(list
(make-module 'space-plane "" sim-priority
'set-timing sim-timing 'set-stop-height 0.6)
(make-module 'numeric-plane-output "" sim-priority
'set-output-file "dump")
(make-module 'evaluator "" subsim-priority
'set-path "path1.txt"
'set-flare 7331 'set-final 3879
'set-path "path2.txt"
'set-flare 9280 'set-final 4673
'set-path "path3.txt"
'set-flare 11416 'set-final 5971
'set-feedback-timing feedback-timing
'set-stop-height 0.6)
(make-module 'spaceplane-control "" admin-priority)
)
)
(if (equal? this-node-id 1)
(list
(make-module 'mmslab-stick "stick" stick-priority
'set-timing stick-timing)
(make-module 'rate-reduction "" stick-priority
'set-timing sim-timing)
)
)
(if (equal? this-node-id 2)
(list
(make-module 'display-space "" admin-priority
'set-fullscreen #t)
)
)
(list) ; for nodes that get no modules, empty list
)) ; spaceplane-complete

Notice the use of the "if (equal? this-node-id cl-node)" construction. All modules defined within the if statement are designated for that node. If this is not used, the modules will be created in all nodes in parallel, and this would certainly give channel conflicts.