Skip to content

tutorial_component_development

m0rsch1 edited this page Jun 26, 2018 · 24 revisions

Create a project

After installig ESROCOS, step into the esrocos workspace and source the environment script to provide access to the ESROCOS workflow tools . env.sh. Then call esrocos_create_project with the argument "tutorial-driver" to create your first esrocos component.

Enter dependencies

The ESROCOS project creation workflow starts with an interactive dialogue questioning for some information about you and the project. Most important however is the information on other packages the new project should depend on. For this tutorial our project depends on only one package: types/base a package which provides the most central ESROCOS data types.

enter dependencies

With that information, the ESROCOS tool will do some processing and will create a project folder together with the first artifacts and files.

esrocos_create_project

Artifacts in the new project

Step into the projects folder you just created and have a look around.

esrocos_create_project

Of all the files, the esrocos.yml is the most central: In it, you will find all the information you entered during project creation. Here you can add/edit the description of the project as well as the dependencies, the format of the yml structures correspond to the configuration files found in Autoproj, so don't let it's syntax confuse you.

esrocos.yml

Fetch dependencies

After every time you edit the esrocos.yml or just after creating a project (like now) you have to call esrocos_fetch_dependencies to let autoproj checkout and install the stated dependencies. Also all data types will be compiled by asn2aadlplus into one <projectname>_dv.aadl file, so the types will be provided to the taste GUI.

Edit project via TASTE-GUI

Next, call esrocos_edit_project to open your project in the TASTE GUI. On the left side under the bullet "dataview" you will find all the data types you imported to the project which are now usable within the TASTE GUI.

On the canvas to the right, create a TASTE function by using the context menu (right click) and choose new function or using the FU button in the toolbar on top. Various settings can be set for the function by right-clicking on it and selecting "edit properties". Rename it to driver and set the source language to C++ (cpp).

create a function

A taste project is made up of functions connected over Required Interfaces (RI) and Provided Interfaces (PI). We begin with adding an PI to our new driver function and editing its properties. A PI is an ingoing connection, in this case it is supposed to be called not from external modules but cyclic to drive our system. We set the name to clock and the period and the other time settings to 100ms each.

create a function

Analogous we add an RI which is an outgoing connection. It can be called from within the function and will in turn call the code of the method it is later connected to. Edit its properties by right-clicking and selecting edit properties and set inherits from PI to false and rename it to trigger_out. Further settings include the parameters the RI-Method needs to be called with.

create a function

Generate Skeletons

Save your work and return to the shell. Call esrocos_generate_skeletons to generate code skeletons for your functions. There will be a new folder driver with automatically generated driver.cc and driver.h. The header file normally needs no manipulation. Open and edit the code of driver.cc to call the RI method defined in the header:

#include "driver.h"

void driver_startup()
{
    /* Write your initialization code here,
       but do not make any call to a required interface. */
}

void driver_PI_clock()
{
  driver_RI_trigger_out();    
}

Type amake to compile the code. Go back to edit mode via esrocos_edit_project:

  • In the Interface view editor, double-click on the function to edit the properties, right click on Source Text and select the file named "driver.zip" that you just created. Use the one inside the build-folder!

Prepare CMakeLists.txt

The building and installation of ESROCOS relies on CMake. That's why you find a CMakeLists.txt template in your projects folder. Edit it with your favourite text editor and make sure it has the following contents:

cmake_minimum_required(VERSION 3.2)

project(tutorial-driver)

include($ENV{ESROCOS_CMAKE})

#required function call to set up esrocos
esrocos_init()

esrocos_export_function("driver" "tutorial/driver")

The last line will zip the folder driver and install it at the local workspace install folder in the subdirectory tutorial/driver from which it can be imported into the projects. As the driver component is not dependend on other library, exporting linking information is not neccessary.

Congratulations, you developed a driver component and exported it on your system so it can be reused in future system integration.

Clone this wiki locally