Difference between pages "QGen" and "Main Page"

From TASTE
(Difference between pages)
Jump to: navigation, search
 
(Documentation and presentations)
 
Line 1: Line 1:
= TASTE/QGen integration: a demo setup =
+
= TASTE =
 +
Welcome to the [https://taste.tools/ TASTE] wiki!
  
== Introduction ==
 
  
This article contains a simple demo workflow based on the Simulink models used in the UPMSat-2 Attitude Control System (ACS).
+
'''TASTE''' is a set of freely-available tools dedicated to the development of embedded, real-time systems. It is developed by the [https://esa.int/ European Space Agency] together with a set of partners from the space industry.  
The main objective of the demo is to illustrate the bindings between the architectural modelling in TASTE and corresponding Simulink functional models.
 
  
The QGen toolset is used to generate C code taking the ACS Simulink model as the input.
 
  
== Required tools ==
+
'''TASTE''' promotes the combined use of '''formal description techniques''' (AADL, SDL, MSC, ASN.1) with strongly typed programming languages (Ada) and other system-level modelling tools (Simulink, VHDL) and coding languages (C, C++).
Apart from the TASTE [[Virtual Machine]] in its latest version (v10), you need to install:
 
* ''MatLab'', version R2020b is recommended and used in this tutorial.
 
* ''Simulink''.
 
* ''QGenc'', version 21.0 or superior (22.0 is used in this tutorial).
 
  
== Overview of the Simulink models ==
 
  
This demo includes Simulink models used in the UPMSat-2 microsatellite. The control and aerospace engineers from the "Ignacio Da Riva" Institute at the Technical University of Madrid have implemented these models, which are publically available in [https://github.com/STR-UPM/OBDH_LABS/blob/master/LAB7/ACS_PIL/ACS_PIL.slx this GitHub repository]. In essence, the UPMSat-2 ACS subsystem determines the satellite's attitude, that is, its orientation relative to the Earth's surface. To do so, the satellite is equipped with three magnetometers, each measuring all three axes, and three magnetic torquers (AKA magnetorquers), one per axes.
+
The tools run on the '''Debian Linux''' operating system and are available in a pre-installed virtual machine.  
  
=== Simulation environment model for the ACS ===
 
  
The <code>ACS_SIL.slx</code> Simulink model contains blocks that simulate the satellite environment (Earth and Sun), the On-Board Computer (OBC), and relevant equipment for the ACS such as magnetometers and magnetorquers.
+
'''TASTE''' addresses system architecture, data and '''behavior modelling''' and allows to generate low-level code for micro-controllers and distributed, communicating systems. Various platform are supported : x86/Linux, Raspberry Pi, ESP430 with FreeRTOS, STM32 with the GNAT Runtime or FreeRTOS, Leon2/Leon3 with RTEMS, as well as targets including FPGA components. It is '''open''' and extensible.
The entire model was developed following a hierarchical structure. The following figure depicts the internals of the <code>ACS_SIL/UPMSat_2/OBC/Nominal Attitude Control</code> subsystem.
 
  
[[File:PIL_Model_UPMSat2_ACS.png|1250px|Simulated environment]]
 
  
In brief, this subsystem is composed of two blocks:
+
TASTE fields of research include '''simulation''', '''model checking''', software correctness by construction, documentation generation, and in general improvement of the software development lifecycle through '''automation'''.
* The <code>Sensor</code> block (red) on the left is in charge of the data acquisition, i.e.: reading five samples from the three magnetometers. These readings are sent as an array of 15 elements (5 samples &times; 3 readings/magnetometer) through the <code>B_b_T</code> output signal.
 
* On the right, the <code>PWM</code> block (red) controls the magnetorquers via Pulse Width Modulation (PWM). The actual command is read from the <code>Control</code> input signal.
 
  
The original model contained the ''Control'' block in the middle. This block implemented the actual control algorithm and is described in the next subsection. Since this demo includes the Control algorithm as part of the TASTE model, we had to replace the Control block with TCP/IP blocks. This way, the <code>Sensor</code> and <code>PWM</code> blocks shown above will communicate with our TASTE model by means of TCP/IP sockets.
 
  
=== ACS Control algorithm ===
 
  
The following figure shows the ACS (closed-loop) control algorithm implemented in Simulink. On the left side, there are five input signals that represent the MGMs readings (<code>B_b_T</code>) and configuration parameters; for example; <code>Omega</code> (input port 2) which specifies the setpoint (the desired angular velocity from the vehicle), or the <code>MT_working</code> (input port 6) array that specifies the working MGTs in the attitude control. On the right side, there is only one output signal that holds the values that control the actuators (MTTs) according to the input values.
+
== TASTE Ecosystem, Overview and Screenshots ==
 +
* [[Latest news]]
 +
* [[Overview]]
 +
* [[TASTE consortium]]
  
[[File:UPMSat2_ACS_Control_Model.png|1200px|ACS Simulink model]]
+
== Tool availability ==
  
== Modelling workflow ==
+
* [[Virtual Machine]]
 +
* [[Manual installation on a native platform]]
 +
* [[Installation using a lxc container]]
  
=== Prepare the TASTE models ===
+
== Documentation and presentations ==
So far, we have seen an overview of the environment and control Simulink models. We have to create the TASTE project that (1) will contain the control algorithm and (2) communicate with the simulated environment. These two functional aspects suggest the following decomposition for the '''Interface View''':
+
* [[Architecture Overview]]
 +
* [[Supported target architectures]]
 +
* [[Case studies]]
 +
* [[Media]] and [[Publications related to TASTE]]
 +
* [[Tools documentation]]
 +
* [[TASTE Semantics]]
 +
* [[IF model-checking]]
 +
* [[Technical topic: Advanced testing with MSC and Python scripts]]
 +
* [[Technical topic: OpenGEODE, an SDL editor for TASTE]]
 +
* Technical Topic : [[Detailed_SDL_tutorial]]
 +
* Technical Topic : [[MSC tutorial]]
 +
* [[Technical topic: OpenGEODE - Design pattern: How to emulate the SAVE symbol]]
 +
* [[Technical topic: OpenGEODE - SDL Operators: How to work with data]]
 +
* [[Technical topic: ASN1SCC - ESA's ASN.1 Compiler for safety-critical embedded platforms]]
 +
* [[Technical topic: ASN.1 - An introduction to ACN]]
 +
* [[Technical topic: Hints to model complex packet encodings with ASN.1 and ACN]]
 +
* [[Technical topic: ASN.1 and ACN - How to add a CRC value to an encoded packet]]
 +
* [[Technical topic: ASN.1 and SQL mapping]]
 +
* [[Technical topic: Using SQL Databases in TASTE]]
 +
* [[Technical topic: Customizing the ASN.1 compiler (ASN1SCC) with your own templates]]
 +
* [[Technical topic: Use of timers in user code with TASTE]]
 +
* [[Technical topic: Extend your models with your own property sets to hook your own tools]]
 +
* [[Technical topic: Test your Leon2/Leon3 applications with QEMU]]
 +
* [[Technical topic: Manage interface priorities]]
 +
* [[Technical topic: Work with sockets]]
 +
* [[Technical topic: FPGAs in TASTE]]
 +
* [[Technical topic: Code Coverage]]
 +
* [[Technical topic: Add a new target platform to TASTE]]
 +
* Technical topic: [[Kazoo]] templating engine
 +
* Technical topic: [[Port a legacy TASTE project to Kazoo]]
 +
* Technical topic: [[Understand the code generation strategy]]
 +
* Technical topic: use the new qualifiable [[QGen]] code generator for Simulink with TASTE
 +
* [[Technical topic: TASTE on MSP430 with FreeRTOS]]
 +
* [[Technical topic: C++ Components and AIR IO Partitions]]
 +
* Technical topic: [[Import/Export of Components in TASTE]]
 +
* Technical topic: [[Customize auto-generated GUIs with custom widgets]]
 +
* Scheduling analysis with the [[TASTE CV Graphical Editor]]
 +
* [[Work in progress: Integrating SDL and VDM]]
  
# <code>Simulated ACS HW</code>: This TASTE Function is in charge of the communication with the simulated environment utilizing a TCP/IP socket. It will act as the server end of the communication and offer two Provided Interfaces (PI): <code>Read_MGM</code> to read the magnetometers, and <code>Control MGT</code> to send the magnetorquers commands.
+
== Management and release process ==
# <code>ACS</code>: This is a composite TASTE function that will implement the ACS algorithm; thereby, it is composed of:
 
## <code>ACS Algorithm</code>, this is a QGenC component that holds the control algorithm previously described. Therefore it offers the Step unprotected PI that receives the six input signals as input parameters and returns the Control signal through an output parameter.
 
## <code>Measurer And Actuator</code>, this is the active component and orchestrates the traditional control steps: read, control, actuate. This sequence is performed by the <code>Tick</code> cyclic PI.
 
  
[[File:QGen_demo_IV.png|none|thumbnail|600px|TASTE IV for this demo]]
+
* [[Building a TASTE-y RTEMS]]
 +
* [[Taming the stack usage of embedded applications]]
  
There is one execution flow activated every 2 seconds by the <code>Tick</code> PI from <code>Measurer And Actuator</code>:
+
== Support ==
# Read the magnetometers invoking the <code>Read_MGM</code> interface,
+
* [[Contribute to the wiki]]
# pass these readings to the control algorithm invoking the <code>Step</code> interface, and
+
* [[Submit a bug]]
# call the <code>control MGT</code> interface to send the command returned previously by the Step interface.
+
* [[Technical FAQ]]
 +
* [[taste-users]] mailing-list
 +
* [[taste-dev]] mailing-list
 +
* [https://www.openhub.net/p/taste-esa Source code metrics] on [https://www.openhub.net OpenHub]
 +
* [[Troubleshooting Device Driver issues on the Gaisler Boards]]
  
To fully define the '''Interface View''' of our model, we have to define the data types in ASN.1 used for these functions based on the Simulink models in/output parameters. The following listing shows the entire '''Data View''':
+
== Other information ==
<nowiki>
 
QGEN-TUTORIAL-DATAVIEW DEFINITIONS ::=
 
BEGIN
 
    -------------------------
 
    -- Reusable data types --
 
    -------------------------
 
    T-Float  ::= REAL (-3.4e+38 .. 3.4e+38)
 
     
 
    -------------------------------------------
 
    -- Data types used for the ACS component --
 
    -------------------------------------------
 
    -- Input types:
 
    T-B-b-T      ::= SEQUENCE (SIZE(15)) OF T-Float
 
    T-Omega      ::= SEQUENCE (SIZE(3))  OF T-Float
 
    T-MT-Working ::= SEQUENCE (SIZE(3))  OF T-Float
 
  
    -- Output types:
+
* [[ASN.1 generators|ASN.1 Compiler and ASN.1 glue generators]]
    T-Control    ::= SEQUENCE (SIZE(3))  OF T-Float
+
* [[Ocarina]]
END </nowiki>
+
* [[Orchestrator]]
 +
* [[PolyORB-HI-Ada]]
 +
* [[PolyORB-HI-C]]
 +
* [[tasted]] (TASTE daemon - deprecated)
 +
* [[Cross-development toolchains]]
 +
* [[TASTE Graphical Editors]]
 +
* [[TASTE GUI for Windows]] (experimental)
 +
* [[Software requirements for TASTE GUI for Windows]] (experimental)
 +
* [[Using TASTE GUI for Windows]] (experimental)
 +
* [[Build TASTE on QEMU 1.0 for Windows platforms]] (experimental)
 +
* [[Software requirements for MSC Editor]]
 +
* [[Create an .exe file from the TASTE GUI for Windows sources]] (experimental)
 +
* [[Create an installer for TASTE GUI for Windows]] (experimental)
 +
* [[Create a binary file from the TASTE GUI for Windows sources for Linux]] (experimental)
 +
* [[How to make proper connections in CASE tools]]
  
Finally, the following table presents in detail the interfaces from all our TASTE functions:
+
* [[ESA Summer of Code in Space - Project ideas]]
{| class="wikitable"
 
|+ Provided Interfaces (PI) detailed description
 
|-
 
! rowspan="2"|PI Name          !! rowspan="2"|PI Type    !! colspan="3"|Parameters
 
|-
 
!                                                            Name      !! Type        !! Direction
 
|-
 
| <code>Read_MGM</code>        || Unprotected            || BBT        || T-B-b-T      || OUT
 
|-
 
| <code>Control_MGT</code>      || Unprotected            || Control    || T-Control    || IN
 
|-
 
| rowspan="7"|<code>Step</code> || rowspan="7"|Unprotected || BBT        || T-B-b-T      || IN
 
|-
 
|                                                            Omega      || T-Float      || IN
 
|-
 
|                                                            K_PB      || T-Float      || IN
 
|-
 
|                                                            K_PE      || T-Float      || IN
 
|-
 
|                                                            M_M        || T-Float      || IN
 
|-
 
|                                                            MT_Working || T-MT-Working || IN
 
|-
 
|                                                            Control    || T-Control    || OUT
 
|-
 
| <code>Tick</code>            || Cyclic                  || &#8709;    || &#8709;      || &#8709;
 
|}
 
 
 
=== Implement the TASTE functions ===
 
The next step is to implement all our TASTE functions defined previously. Since TASTE is a heterogeneous toolchain, it allows the implementation of a function in different programming and modelling languages. In this demo, we will show the C implementations of the <code>Measurer_And_Actuator</code>, and <code>Simulated_ACS_HW</code>; their Ada counterpart is available in the GitHub repository. Finally, the <code>ACS_Algorithm</code> is implemented as a QGenC function.
 
 
 
==== Simulated ACS Hardware ====
 
This function acts as a TCP/IP server to communicate with the simulated environment implemented in Simulink. The general data flow from all these functions is depicted in the figure below. In this figure, we can observe that the Simulated ACS Hardware is the functional element that abstracts the access to the Simulink environment. If the communication were achieved by serial ports, then we would have to implement our function accordingly. The whole function implementation is available on the GitHub repo.
 
 
 
[[File:Dataflow_ACS_TASTE.png]]
 
 
 
'''''NOTE''''': ''An alternative would be to integrate the simulated environment as a set of TASTE Functions. This way we wouldn't have to code the underlying communication aspects between the Simulink model and TASTE.''
 
 
 
==== Measurer and Actuator ====
 
 
 
This is the only active object from the whole system, i.e.: it contains one thread. This function has to implement the control steps (<code>Tick</code>) invoking its Required Interfaces (RI). The following excerpt of code shows the implementation of the Tick function in ''C'':
 
 
 
<source lang="c">
 
void measurer_and_actuator_PI_Tick(void) {
 
  // IN params:
 
  static asn1SccT_B_b_T bbt;
 
  static asn1SccT_Omega omega = {
 
      .arr = {0.0, 0.0, 0.1}
 
  };
 
  static asn1SccT_Float k_pb = 2.0;
 
  static asn1SccT_Float k_pe = 8.0;
 
  static asn1SccT_Float m_m  = 15.0;
 
  static asn1SccT_MT_Working mt_working = {
 
      .arr = {1.0, 1.0, 1.0}
 
  };
 
 
 
  // OUT params:
 
  static asn1SccT_Control control;
 
 
 
  // Traditional control loop:
 
  measurer_and_actuator_RI_Read_MGM(&bbt);
 
  measurer_and_actuator_RI_Step(&bbt, &omega, &k_pb, &k_pe, &m_m, &mt_working, &control);
 
  measurer_and_actuator_RI_control_MGT(&control);
 
}
 
</source>
 
 
 
As you can see in the <code>omega</code> parameter, we have set the ACS algorithm to stabilize the vehicle spinning at ''1.0 rad/second'' in the Z-axis.
 
 
 
==== ACS Algorithm ====
 
 
 
Among the other things, TASTE generates MatLab scripts for Simulink model provided interfaces (one per component). Currently, the metamodel is restricted to one PI per function and no RIs. These scripts create a model for each component (if it does not exist) and a port for each interface parameter from the Interface View.
 
 
 
As for this demo, the Simulink models for components already exist. The ports simply need to be reconnected to make sure that the interfaces of the Simulink model can be correctly bound to those in the TASTE interface model. To do it, follow the next steps:
 
# Double left-click the <code>ACS_Algorithm</code> function, select QGenC in the ''Language'' drop menu from the ''Implementation'' tab.
 
# Richt click the <code>ACS_Algorithm</code> function and select the option: ''Edit implementation''. This will open MatLab in the corresponding working directory.
 
# Load the autogenerated Simulink (.sl) model for the <code>Step</code> function. This model contains the wrapper (i.e.: input and output ports) regarding the configuration from the IV.
 
# Open in another window the Control model shown in section ''ACS Control algorithm'' and copy this model (click <code>Ctrl + c</code>)
 
# Inside the autogenerated Simulink wrapper from step ''3'':
 
## Create a subsystem named <code>control</code>, for instance, and click inside.
 
## Then, paste this model into the subsystem you have just created.
 
# Reconnect inputs and outputs to the functional block in/outputs, and save the model.
 
 
 
'''''NOTE''''': ''There is a mismatch between the ports (Double) and control algorithm types (Single), thus, you need to make the cast from Double to Single and vice versa''
 
 
 
You should get a model similar to the following one, a set of wrappers connected to the actual control algorithm:
 
 
 
[[File:Control_Wrapper_Model.png|1250px|Simulated environment]]
 
 
 
== Execution of the Demo ==
 
 
 
The last step is to test this demo. To do so you first need to generate the code and binary; there are two alternatives:
 
* The first one is by the terminal or console. You have to run <code>make</code> in the root directory from your project.
 
* This is the easiest one. Click on the hammer symbol from the Qt Creator IDE (alternatively, click <code>Ctrl + B</code>).
 
 
 
We choose the first option. If successful, it is time to run our demo:
 
# First, run the generated binary located in the <code>work/binaries/</code> directory.
 
# Since we are simulating the satellite platform in Simulink you need to start it by clicking on the play symbol.
 
 
 
At this point, the demo binary and the Simulink model should be running and connected employing TCP/IP sockets.
 
 
 
To visually inspect the correctness of the algorithm, have a look at the ''angular velocity'' scope. The setpoint established in the control loop was specified in the omega parameter (the second one) from the <code>Tick</code> PI. As you can see in the following figure, the angular velocity on the Z-axis is ''1 rad/sec'' approx and ''0 rad/sec'' on the X and Y-axis.
 
 
 
[[File:Angular_Velocity.png|frame|none|alt=|Angular velocity evolution (Simulink Scope)]]
 

Revision as of 08:57, 7 June 2022

TASTE

Welcome to the TASTE wiki!


TASTE is a set of freely-available tools dedicated to the development of embedded, real-time systems. It is developed by the European Space Agency together with a set of partners from the space industry.


TASTE promotes the combined use of formal description techniques (AADL, SDL, MSC, ASN.1) with strongly typed programming languages (Ada) and other system-level modelling tools (Simulink, VHDL) and coding languages (C, C++).


The tools run on the Debian Linux operating system and are available in a pre-installed virtual machine.


TASTE addresses system architecture, data and behavior modelling and allows to generate low-level code for micro-controllers and distributed, communicating systems. Various platform are supported : x86/Linux, Raspberry Pi, ESP430 with FreeRTOS, STM32 with the GNAT Runtime or FreeRTOS, Leon2/Leon3 with RTEMS, as well as targets including FPGA components. It is open and extensible.


TASTE fields of research include simulation, model checking, software correctness by construction, documentation generation, and in general improvement of the software development lifecycle through automation.


TASTE Ecosystem, Overview and Screenshots

Tool availability

Documentation and presentations

Management and release process

Support

Other information