blob: b2c410bf40049d5212efd71750657c632a2770f3 [file] [log] [blame]
<!DOCTYPE html><html lang="en-us" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="generator" content="Source Themes Academic 4.8.0">
<meta name="author" content="Fraunhofer FOKUS">
<meta name="description" content="">
<link rel="alternate" hreflang="en-us" href="https://www.eclipse.org/mosaic/tutorials/tiergarten/">
<meta name="theme-color" content="#68145C">
<script src="/mosaic/js/mathjax-config.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/academicons/1.8.6/css/academicons.min.css" integrity="sha512-MCWBwPSput2UWNwyznVFLbD2iUc1e5VsdD1zahsWVzkDSUzyHhMZ4kCS3wgYSRm0mU+glwD/Q9lSJrDPwbUL2A==" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-1/css/all.min.css" integrity="sha512-ZYg+hQvLlM0W9C3P6vTpes5LmJ66G2EsroxDNzwD6qiulckldb29eD9I672HL2X+LH5nRhY1sQqZLJGB+aUUPg==" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css" integrity="sha512-H9jrZiiopUdsLpg94A333EfumgUBpO9MdbxStdeITo+KEIMaNfHNvwyjjDJb+ERPaRS6DpyRlKbvPUasNItRyw==" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/styles/atom-one-light.min.css" crossorigin="anonymous" title="hl-light">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/styles/atom-one-light.min.css" crossorigin="anonymous" title="hl-dark" disabled>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.5.1/leaflet.css" integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ==" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/lazysizes/5.2.2/lazysizes.min.js" integrity="sha512-TmDwFLhg3UA4ZG0Eb4MIyT1O1Mb+Oww5kFG0uHqXsdbyZz9DcvYQhKpGgNkamAI6h2lGGZq2X8ftOJvF/XjTUg==" crossorigin="anonymous" async></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.1.0/es5/tex-chtml.min.js" integrity="sha512-uwL1UtpYdWra2iqJlAW8Ts0s9Os6IxWLDJDF/BnWdhDmT7DEMFba3GPsFwmV3QiTNcUyl2GB5vsgycB/MOvo9g==" crossorigin="anonymous" async></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,400i,700,700i%7CRoboto+Mono&display=swap">
<link rel="stylesheet" href="/mosaic/css/academic.css">
<link rel="alternate" href="/mosaic/tutorials/tiergarten/index.xml" type="application/rss+xml" title="Eclipse MOSAIC – A Multi-Domain and Multi-Scale Simulation Framework for Connected and Automated Mobility">
<link rel="manifest" href="/mosaic/index.webmanifest">
<link rel="icon" type="image/png" href="/mosaic/images/icon_hu6bdfb97c7e23190c70e41ca0e15a9fce_30436_32x32_fill_lanczos_center_2.png">
<link rel="apple-touch-icon" type="image/png" href="/mosaic/images/icon_hu6bdfb97c7e23190c70e41ca0e15a9fce_30436_192x192_fill_lanczos_center_2.png">
<link rel="canonical" href="https://www.eclipse.org/mosaic/tutorials/tiergarten/">
<meta property="twitter:card" content="summary">
<meta property="og:site_name" content="Eclipse MOSAIC – A Multi-Domain and Multi-Scale Simulation Framework for Connected and Automated Mobility">
<meta property="og:url" content="https://www.eclipse.org/mosaic/tutorials/tiergarten/">
<meta property="og:title" content="Tiergarten | Eclipse MOSAIC – A Multi-Domain and Multi-Scale Simulation Framework for Connected and Automated Mobility">
<meta property="og:description" content=""><meta property="og:image" content="https://www.eclipse.org/mosaic/images/logo.svg">
<meta property="twitter:image" content="https://www.eclipse.org/mosaic/images/logo.svg"><meta property="og:locale" content="en-us">
<meta property="og:updated_time" content="2019-05-05T00:00:00&#43;01:00">
<title>Tiergarten | Eclipse MOSAIC – A Multi-Domain and Multi-Scale Simulation Framework for Connected and Automated Mobility</title>
</head>
<body id="top" data-spy="scroll" data-offset="70" data-target="#TableOfContents" class=" page-mosaic page-tutorials page-tiergarten ">
<aside class="search-results" id="search">
<div class="container">
<section class="search-header">
<div class="row no-gutters justify-content-between mb-3">
<div class="col-10 col-md-3">
<div class="logo" style="background-image: url(/mosaic/img/logos/mosaic/EclipseMOSAIC-Logo-RGB-positiv.svg)"></div>
</div>
<div class="col-2 col-md-4 col-search-close">
<a class="js-search" href="#"><i class="fas fa-times-circle text-muted" aria-hidden="true"></i></a>
</div>
</div>
<div id="search-box">
<input name="q" id="search-query" placeholder="Search..." autocapitalize="off"
autocomplete="off" autocorrect="off" spellcheck="false" type="search">
</div>
</section>
<section class="section-search-results">
<div id="search-hits">
</div>
</section>
</div>
</aside>
<nav class="navbar navbar-expand-lg navbar-light compensate-for-scrollbar" id="navbar-main">
<div class="container">
<div class="d-none d-lg-inline-flex">
<a style="visibility:visible;" class="navbar-brand" href="/mosaic/"><img src="/mosaic/images/logo.svg" alt="Eclipse MOSAIC – A Multi-Domain and Multi-Scale Simulation Framework for Connected and Automated Mobility"></a>
</div>
<button type="button" class="navbar-toggler" data-bs-toggle="collapse" data-bs-target="#navbar-content-mobile" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
<span><i class="fas fa-bars"></i></span>
</button>
<div class="navbar-brand-mobile-wrapper d-inline-flex d-lg-none">
<a class="navbar-brand" href="/mosaic/"><img src="/mosaic/images/logo.svg" alt="Eclipse MOSAIC – A Multi-Domain and Multi-Scale Simulation Framework for Connected and Automated Mobility"></a>
</div>
<div id="navbar-content" class="navbar-collapse main-menu-item collapse justify-content-start">
<ul class="navbar-nav d-md-inline-flex">
<li class="nav-item">
<a class="nav-link " href="/mosaic/about/"><span>About</span></a>
</li>
<li class="nav-item">
<a class="nav-link " href="/mosaic/news/"><span>News</span></a>
</li>
<li class="nav-item">
<a class="nav-link " href="/mosaic/docs/"><span>Documentation</span></a>
</li>
<li class="nav-item">
<a class="nav-link active" href="/mosaic/tutorials/"><span>Tutorials</span></a>
</li>
<li class="nav-item">
<a class="nav-link " href="/mosaic/download/"><span>Download</span></a>
</li>
<li class="nav-item">
<a class="nav-link " href="/mosaic/community/"><span>Community</span></a>
</li>
</ul>
</div>
<ul class="nav-icons navbar-nav flex-row ml-auto d-flex pl-md-2">
<li class="nav-item">
<a class="nav-link js-search" href="#" aria-label="Search"><i class="fas fa-search" aria-hidden="true"></i></a>
</li>
<li class="nav-item ">
<a href="https://github.com/eclipse/mosaic" target="blank">
<i class="fab fa-github" aria-hidden="true"></i>
</a>
</li>
</ul>
<div id="navbar-content-mobile" class="navbar-collapse main-menu-item collapse justify-content-start d-lg-none">
<ul class="navbar-nav d-inline-flex">
<li class="nav-item">
<a class="nav-link " href="/mosaic/about/"><span>About</span></a>
</li>
<li class="nav-item">
<a class="nav-link " href="/mosaic/news/"><span>News</span></a>
</li>
<li class="nav-item">
<a class="nav-link " href="/mosaic/docs/"><span>Documentation</span></a>
</li>
<li class="nav-item">
<a class="nav-link active" href="/mosaic/tutorials/"><span>Tutorials</span></a>
</li>
<li class="nav-item">
<a class="nav-link " href="/mosaic/download/"><span>Download</span></a>
</li>
<li class="nav-item">
<a class="nav-link " href="/mosaic/community/"><span>Community</span></a>
</li>
</ul>
</div>
</div>
</nav>
<div class="universal-wrapper pt-3">
<h1>Tiergarten</h1>
</div>
<div class="universal-wrapper">
<div class="article-style"><div class="alert alert-note">
<div>
<p>All files you need for this tutorial are included in the Eclipse MOSAIC zip file:<br>
<strong><a href="/download">Download Eclipse MOSAIC</a></strong></p>
</div>
</div>
<p>This tutorial aims to provide a general overview of the Eclipse MOSAIC application concept and shows two examples that
involve ad hoc communication via <code>IEEE</code> 802.11p between different participants and message passing from one application
to another that run on the same vehicle. The tutorial is split up into five main parts:</p>
<ol>
<li>How to equip a vehicle with one or more applications. This process is called <code>mapping</code>.</li>
<li>An example application that shows how to implement communication between different vehicles via a wireless ad hoc network.</li>
<li>The next part of the tutorial shows how to accomplish message passing between two applications that run on the same vehicle.</li>
<li>An overview of the traffic light application and a summary about what can be done with the traffic light from within the application.</li>
<li>The last part of the tutorial shows how to retrieve the results of a simulation run.</li>
</ol>
<p>The scenario itself consists of three vehicles that drive down a road in consecutive
order and pass a Road Side Unit (RSU) that emits messages in a fixed interval. The
vehicles will receive the messages from the RSU as soon as they are in communication range.</p>
<figure id="figure-overview-of-tiergarten-tutorial-scenario">
<a data-fancybox="" href="images/tiergartenOverview.png" data-caption="Overview of Tiergarten tutorial scenario">
<img src="images/tiergartenOverview.png" alt="" >
</a>
<figcaption data-pre="Figure " data-post=":" class="numbered">
Overview of Tiergarten tutorial scenario
</figcaption>
</figure>
<p>After completing this tutorial the reader should be able to deploy own applications
according to his needs and make use of ad hoc communication among vehicles and intra-vehicle
communication among applications on the same vehicle. The
<a href="/mosaic/docs/simulators/network_simulator_cell/">
Eclipse MOSAIC Cell
</a>
simulator that is used to simulate cellular network communication will be covered in tutorial 2.</p>
<h2 id="mapping-configuration">Mapping Configuration</h2>
<div class="alert alert-tip">
<div>
<p>Read the detailed documentation of the <a href="/docs/mosaic_configuration/mapping_ambassador_config">Mapping Configuration</a>.</p>
</div>
</div>
<p>In order to use applications they have to be assigned (<code>mapped</code> in Eclipse MOSAIC terminology) to a simulation entity.
In this tutorial, we will assign applications to an RSU that is placed along the road (the red symbol in the top
picture) and to the vehicles. In order to do this the following steps are necessary:</p>
<ol>
<li>Navigate to the <code>mapping</code> folder of the Tiergarten tutorial scenario.</li>
<li>Edit the <code>mapping_config.json</code> to let it point to the correct classes
for your application, define prototypes and to add entities to the simulation.</li>
</ol>
<p>The mapping is already configured correctly, so we will continue with a description
of the important parts of the mapping configuration.</p>
<h4 id="prototype-section">Prototype Section</h4>
<p>This section contains the properties of the simulated entities, including their applications.
You can, for example, configure the maximum speed and the length of a vehicle. Normally, the
default values are fine here. In order to map one or more applications you have to fill in
the complete class identifier including the package in the <code>applications</code> array.
In this tutorial, we have mapped two applications to the vehicles and one application to the RSU.</p>
<p>Mapping for the vehicles:</p>
<pre><code class="language-json">&quot;applications&quot;: [
&quot;com.dcaiti.vsimrti.app.tutorials.tiergarten.vehicle.TiergartenVehicle&quot;,
&quot;com.dcaiti.vsimrti.app.tutorials.tiergarten.vehicle.TiergartenVehicleSlave&quot;
]
</code></pre>
<p>Mapping for the RSU:</p>
<pre><code class="language-json">&quot;applications&quot;: [
&quot;com.dcaiti.vsimrti.app.tutorials.tiergarten.rsu.TiergartenRSU&quot;
]
</code></pre>
<p>In order for Eclipse MOSAIC to be able to locate these classes, the resulting .jar archive should be placed
in the <code>application</code> folder of your scenario. For our tutorial we have packaged the needed
classes <code>TiergartenVehicle</code>, <code>TiergartenVehicleSlave</code> and <code>TiergartenRSU</code> into one
.jar file. However, this isn&rsquo;t a strict requirement. What these classes actually do and how they are
implemented will be covered in the next two parts of this tutorial.</p>
<h4 id="vehicle-and-rsu-sections">Vehicle and RSU sections</h4>
<p>This part of the mapping is used to actually bring entities like vehicles and RSUs into the simulation.
For example, we placed the RSU that is equipped with the <code>TiergartenRSU</code> application at the
specific geo coordinate with <strong>latitude = 52.5130607</strong> and <strong>longitude = 13.328910</strong>.
Usually, this and the mapping of its application is all that is necessary to make use of an RSU.
For this tutorial we go with just one RSU but analogous to adding multiple vehicles we could also
add more of them if the need arises.</p>
<p>Spawning vehicles is a little bit more complex than adding a RSU. Vehicles are configured as groups
from which we have three in this tutorial scenario. Exemplary, we will describe one of these groups
in more detail:</p>
<pre><code class="language-json">&quot;vehicles&quot;: [
{
&quot;startingTime&quot;: 1.0,
&quot;route&quot;: 0,
&quot;maxNumberVehicles&quot;: 1,
&quot;types&quot;: [ { &quot;name&quot;: &quot;PKW&quot; } ]
},
...
]
</code></pre>
<ul>
<li><code>startingTime</code>: Defines at which second the vehicle is spawned, in this case one second
after the beginning of the simulation.</li>
<li><code>route</code>: Describes which route these vehicle group should use. For now it is
sufficient to know that there is one route with the id 0 that leads the vehicles near the RSU
that is already defined in this tutorial scenario.</li>
<li><code>maxNumberVehicles</code>: Used to determine how many vehicles should be in that group.
Here, we go with just one single vehicle.</li>
<li><code>types</code>: This array maps to the defined <code>PKW</code> (german for passenger car)
prototype from the <code>prototypes</code>-section of the mapping.</li>
</ul>
<h2 id="inter-vehicle-communication">Inter-Vehicle Communication</h2>
<p>This second part describes the <code>TiergartenVehicle</code> and <code>TiergartenRSU</code> applications
which are used for inter-vehicle communication in more detail. As a coarse overview, the
<code>TiergartenRSU</code> application sends out a defined message at a fixed interval. These messages
are received and written to the log file by the TiergartenVehicle application. First, we start
off with the class definition and will run through the methods we have to implement in order
to get the communication working.</p>
<h4 id="class-definition">Class definition</h4>
<pre><code class="language-java">public class TiergartenVehicle extends AbstractApplication&lt;VehicleOperatingSystem&gt;
implements VehicleApplication, CommunicationApplication {
// to be implemented
}
</code></pre>
<p>In general, every vehicle application will extend the <code>AbstractApplication</code> abstract class with the
VehicleOperatingSystem type parameter. The VehicleOperatingSystem is the main way to interact with
the underlying vehicle and gives a wide array of functionality to the user. Also, depending on the needs of the
application, several interfaces have to be implemented. For our scenario we implement <code>VehicleApplication</code>
to denote that the application is intended to run on a vehicle and <code>CommunicationApplication</code> to be able
to use the actual communication facilities we need for this tutorial. In general, it makes sense to let the
IDE generate the bodies of the methods that need implementation and fill them with functionality if needed or
letting them empty otherwise.</p>
<h4 id="application-initialization">Application initialization</h4>
<p>During the initialization procedure of communicating applications,
the communication modules (WLANModule or CellModule) need to be activated. For example, activating the
WLAN module can be achieved with the following code snipped:</p>
<pre><code class="language-java">@Override
public void onStartup() {
getLog().infoSimTime(this, &quot;Initialize application&quot;);
getOperatingSystem().getAdHocModule().enable(
new AdHocModuleConfiguration().addRadio().channel(AdHocChannel.CCH).power(50).create()
);
getLog().infoSimTime(this, &quot;Activated AdHoc Module&quot;);
}
</code></pre>
<p>Since we want to communicate over ad hoc Wifi we have to turn on the Wifi-module of the car. Here you can
specify the mode of operation. The first argument says if the vehicle should be able to receive messages,
how strong the Wifi antenna is (50mW in this case) and which ad hoc channel to use.
<strong>Note</strong>: The honoring of these arguments depends on the underlying network simulator. Currently, <em>ns-3</em> and
<em>OMNeT++</em> make use of these arguments. For <em>SNS</em>, the method <code>distance(250)</code> shall be used instead of <code>power(50)</code>.</p>
<h3 id="receiving-the-v2x-messages">Receiving the V2X messages</h3>
<p>In order to act upon received messages from other simulation entities, the <code>receiveV2XMessage</code> from
the <code>CommunicationApplication</code> interface is used. In our tutorial scenario we don&rsquo;t do something special upon message receiving
and just write the name of the sender into the log file.</p>
<pre><code class="language-java">@Override
public void receiveV2XMessage(ReceivedV2XMessage receivedV2XMessage) {
getLog().infoSimTime(this, &quot;Received V2X Message from {}&quot;,
receivedV2XMessage.getMessage().getRouting().getSourceAddressContainer().getSourceName()
);
}
</code></pre>
<p>This is basically all it takes to receive messages from another simulation entity.
Normally, the application author uses an own message class that derives from V2XMessage and casts it
to his specific class in order to handle messages easier.</p>
<h3 id="sending-the-v2x-messages">Sending the V2X messages</h3>
<figure id="figure-example-of-rsu-communication-range">
<a data-fancybox="" href="images/tiergartenRSU.png" data-caption="Example of RSU communication range">
<img src="images/tiergartenRSU.png" alt="" >
</a>
<figcaption data-pre="Figure " data-post=":" class="numbered">
Example of RSU communication range
</figcaption>
</figure>
<p>Since the receiving application is now set up we move on to the sending side of this tutorial.
The sending takes place from the RSU via a broadcast, so every vehicle in transmission range
will receive the message sent by it. The picture above shows the communication range of the RSU
which is dependent from the settings in the communication simulator.
The actual sending takes place in the <code>TiergartenRSU</code> application which is equipped to the RSU
via the mapping configuration.</p>
<h4 id="application-simulator-event-model">Application simulator event model</h4>
<p>In order to send messages at a fixed interval we make use of the event based model of the
<a href="/mosaic/docs/simulators/application_simulator/#eclipse-mosaic-application-simulator">
Eclipse MOSAIC Application Simulator
</a>
.
A high level description in what we need to do in order to send messages at a specific interval can be summarized as follows:</p>
<ul>
<li>Line up an event every X seconds. For this tutorial an interval of two seconds was chosen.</li>
<li>Once the event gets processed in the <code>processEvent()</code>-method the actual sending of the message will be triggered.</li>
<li>All information necessary for the sending will be assembled in <code>sendAdHocBroadcast()</code> and the message gets actually sent out.</li>
</ul>
<h4 id="application-setup">Application Setup</h4>
<pre><code class="language-java">@Override
public void onStartup() {
getLog().infoSimTime(this, &quot;Initialize application&quot;);
getOperatingSystem().getAdHocModule().enable(
new AdHocModuleConfiguration().addRadio().channel(AdHocChannel.CCH).power(50).create()
);
getLog().infoSimTime(this, &quot;Activated WLAN Module&quot;);
sample();
}
</code></pre>
<p>The setup for the RSU is the same as for the vehicle where we activate the Wifi module. Additionally, the <code>sample()</code>
method gets called which is responsible for the events.</p>
<h4 id="event-scheduling">Event scheduling</h4>
<p>The next step is to line up the event at the interval we desire. The method we use for that, <code>sample()</code>, looks like this:</p>
<pre><code class="language-java">public void sample() {
final Event event = new Event(getOperatingSystem().getSimulationTime() + TIME_INTERVAL, this);
getOperatingSystem().getEventManager().addEvent(event);
getLog().infoSimTime(this, &quot;Sending out AdHoc broadcast&quot;);
sendAdHocBroadcast();
}
</code></pre>
<p>Here, an <code>Event</code> is created which will be received at the current time in simulation plus the defined interval which is
set to two seconds. The second argument for the event creation is a reference to the originating class instance. For our
tutorial, the <code>this</code> reference is sufficient here. After we created the event, it is added to the event queue via
<code>addEvent()</code> which will result in a call to <code>processEvent()</code> at the given interval.</p>
<h4 id="message-sending">Message sending</h4>
<p>After we made sure the method that does the actual sending of the message is called at the specified interval, we take a
closer look at the <code>sendAdHocBroadcast()</code> method we defined in the <code>TiergartenRSU</code> class:</p>
<pre><code class="language-java">private void sendAdHocBroadcast() {
final MessageRouting routing = getOs().getAdHocModule().createMessageRouting().topoBroadCast(AdHocChannel.CCH);
final InterVehicleMsg message = new InterVehicleMsg(routing, getOs().getPosition());
getOs().getAdHocModule().sendV2XMessage(message);
}
</code></pre>
<p>This method has basically three tasks to solve:</p>
<ul>
<li>Firstly, a routing description has to be created, which defines the communication type, the source and destination for
the message, and additional properties like the maximum number of hops and the communication channel. In this specific case,
<code>topoBroadcast(AdHocChannel.CCH)</code> creates a message routing which includes the IP address of the <em>RSU</em> as the source,
the broadcast address as the destination, and a communication path using the present ad-hoc topology with only one hop.</li>
<li>Secondly, the message to be send is created. The previously created message routing description is passed to this
custom <em>V2X</em> message.</li>
<li>Finally, the message is send using the ad-hoc module of the <em>RSU</em>.</li>
</ul>
<p>These steps conclude the sending of the message. The procedure is the same for sending
messages from a vehicle instead of a RSU.</p>
<h2 id="intra-vehicle-communication">Intra-Vehicle Communication</h2>
<p>This part of the tutorial describes the steps necessary for letting two applications to communicate
with each other on the same vehicle. Here, we use the <code>TiergartenVehicle</code> application as the sender
and <code>TiergartenVehicleSlave</code> as the receiver.
In general, the approach is similar to the sending of a V2X message and also makes use of the event system.</p>
<h4 id="message-sending-1">Message sending</h4>
<p>First, we start off with the sending side. The event code should look familiar:</p>
<pre><code class="language-java">@Override
public void afterUpdateVehicleInfo() {
final List&lt;? extends Application&gt; applications = getOperatingSystem().getApplications();
final IntraVehicleMsg message = new IntraVehicleMsg(getOperatingSystem().getId(),
random.nextInt(MAX_ID));
for (Application application : applications) {
final Event event = new Event(getOperatingSystem().getSimulationTime() + 1, application, message);
this.getOperatingSystem().getEventManager().addEvent(event);
}
}
</code></pre>
<p>One noteworthy thing is that we use the <code>afterUpdateVehicleInfo()</code>-method to line up a new event.
This method is called automatically if the vehicle info (for example, speed or heading) gets updated, which
usually takes place at every time step of the simulation.</p>
<p>The general approach works like this:</p>
<ol>
<li>Get a list of all applications that run on the vehicle using <code>getApplications()</code>.</li>
<li>Create a new message. Here we use our own custom message called <code>IntraVehicleMsg</code> which
takes a randomly generated id and the name of the vehicle as payload. Again, this is for tutorial
purposes and could be anything.</li>
<li>After that we iterate over every application that runs on the vehicle, in this case two:
<ul>
<li><code>TiergartenVehicle</code></li>
<li><code>TiergartenVehicleSlave</code></li>
</ul>
</li>
<li>Then, an event is constructed for each app running on the vehicle and added to the event queue
the same way as in the inter-vehicle example.</li>
</ol>
<h4 id="receiving-the-message">Receiving the message</h4>
<p>The actual receiving of the message takes place in the <code>TiergartenVehicleSlave</code> application.
Since the intra vehicle messages are basically treated as an event, the code is straight forward here:</p>
<pre><code class="language-java">@Override
public void processEvent(Event event) throws Exception {
Object resource = event.getResource();
if (resource != null &amp;&amp; resource instanceof IntraVehicleMsg) {
final IntraVehicleMsg message = (IntraVehicleMsg) resource;
if (message.getOrigin().equals(getOperatingSystem().getId())) {
getLog().infoSimTime(this, &quot;Received message from another application&quot;);
}
}
}
</code></pre>
<p>The general concept here is that the payload is wrapped as an object in the actual event. The procedure
here is as follows:</p>
<ul>
<li>Retrieve the resource from the event using <code>getResource()</code></li>
<li>Check if there is actually some kind of payload</li>
<li>Make sure the payload is of the expected type</li>
<li>Cast the payload to an actual class and do something with it.</li>
</ul>
<h3 id="the-traffic-light-application">The traffic light application</h3>
<p>As can be seen in the mapping configuration there is an additional prototype defined for traffic lights:</p>
<pre><code class="language-json">{
&quot;applications&quot;: [ &quot;com.dcaiti.vsimrti.app.tutorials.tiergarten.trafficLight.TrafficLightApp&quot; ],
&quot;name&quot;: &quot;TrafficLight&quot;
}
</code></pre>
<p>These prototype is used to map the referenced application onto two specific traffic lights, as shown in the following listing.</p>
<pre><code class="language-json">&quot;trafficLights&quot;: [
{
&quot;tlName&quot;: &quot;27011311&quot;,
&quot;name&quot;: &quot;TrafficLight&quot;
},
{
&quot;tlName&quot;: &quot;252864801&quot;,
&quot;name&quot;: &quot;TrafficLight&quot;
}
]
</code></pre>
<p>The use case shown for tutorial purposes here is simple: The two traffic lights referenced in the mapping default to
<em>always red</em>. Their application then waits for a V2X message with a <em>secret</em> payload in it (the <code>GreenWaveMsg</code>, sent by
a vehicle equipped with an <code>VehicleToTrafficLightApp</code>) and switches the traffic light program to <em>always green</em> upon
receiving that message. The application mapped onto the traffic light then switches back to its previous program after
20 simulation time steps have passed.</p>
<h2 id="interpretation-of-simulation-results">Interpretation of simulation results</h2>
<p>The last part of the tutorial describes how to retrieve the actual simulation results. For this tutorial,
the results are quite simple and simply show the arrival of the Inter- and IntraVehicle messages. So after
executing the simulation using the following command:</p>
<pre><code class="language-unix/mac">./mosaic.sh -u &lt;user&gt; -s Tiergarten
</code></pre>
<pre><code class="language-windows">mosaic.bat -u &lt;user&gt; -s Tiergarten
</code></pre>
<p>Afterwards, in the log directory of <code>Eclipse MOSAIC</code> a new folder should be created containing all log files of
the simulation run. Within, the sub-folder <code>appsNT</code> contains the log files for each simulation unit and its application.
For example, for the vehicles we end up with two log files: <code>TiergartenVehicle.log</code> and <code>TiergartenVehicleSlave.log</code>.</p>
<p>This following snippet shows the receiving of the V2X messages that were sent by the RSU:</p>
<pre><code>INFO - Initialize application (at simulation time 6.000,000,000 s)
INFO - Activated AdHoc Module (at simulation time 6.000,000,000 s)
INFO - Received V2X Message from rsu_0 (at simulation time 18.000,400,000 s)
INFO - Received V2X Message from rsu_0 (at simulation time 20.000,400,000 s)
</code></pre>
<p>Next, we see the contents of the <code>IntraVehicleMessage</code> that originates from another app on the vehicle:</p>
<pre><code>INFO - Initialize application (at simulation time 2.000,000,000 s)
INFO - Received message from another application: IntraVehicleMsg{origin='veh_0', id=631} ...
</code></pre>
<p>The following log was generated by the RSU application and logs the sending of each
ad hoc broadcast:</p>
<pre><code>INFO - Initialize application (at simulation time 0.000,000,000 s)
INFO - Activated WLAN Module (at simulation time 0.000,000,000 s)
INFO - Sending out AdHoc broadcast (at simulation time 0.000,000,000 s)
INFO - Sending out AdHoc broadcast (at simulation time 2.000,000,000 s)
</code></pre>
<p>This concludes the first tutorial and hopefully gave an idea on how to use the
<a href="/mosaic/docs/simulators/application_simulator/">
Eclipse MOSAIC Application Simulator
</a>
to send out and
receiving messages to other simulation entities or inside the same vehicle.</p>
<p>The <code>OperatingSystem.log</code> files do not contain specific application output and is mainly used for debugging purposes and
won&rsquo;t be discussed in this tutorial.</p>
<h2 id="conclusion">Conclusion</h2>
<p>The Tiergarten tutorial shows detailed the configuration capability and how the communication types can be used. The
following list sums up the things we have covered in this tutorial:</p>
<ul>
<li>Achieving inter- and intra-application communication via AdHoc networks.</li>
<li>How to find and process the results of a simulation run with the help of generated log files.</li>
<li>Integrate of external applications (Traffic Lights).</li>
</ul>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha384-vk5WoKIaW/vJyUAd9n/wmopsmNhiy+L2Z+SBxGYnUkunIxVxAv/UtMOhba/xskxh" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.6.0/umd/popper.min.js" integrity="sha512-BmM0/BQlqh02wuK5Gz9yrbe7VyIVwOzD1o40yi1IsTjriX/NGF37NyXHfmFzIlMmoSIBXgqDiG1VNU6kB5dBbA==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.imagesloaded/4.1.4/imagesloaded.pkgd.min.js" integrity="sha512-S5PZ9GxJZO16tT9r3WJp/Safn31eu8uWrzglMahDT4dsmgqWonRY9grk3j+3tfuPr9WJNsfooOR7Gi7HL5W2jw==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.isotope/3.0.6/isotope.pkgd.min.js" integrity="sha512-Zq2BOxyhvnRFXu0+WE6ojpZLOU2jdnqbrM1hmVdGzyeCa1DgM3X5Q4A/Is9xA1IkbUeDd7755dNNI/PzSf2Pew==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js" integrity="sha512-uURl+ZXMBrF4AwGaWmEetzrd+J5/8NRkWAvJx5sbPSSuOb0bZLqf+tOzniObO00BjHa/dD7gub9oCGMLPQHtQA==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/8.4.8/mermaid.min.js" integrity="sha512-1tS1YUns336Mtxl+vkaLcADPwE1CPNVy3WEf7nrI7DGMMb6/FAVBgL2IzAWVBkB6vVuK94s2zVoiXcw1QZ9S1g==" crossorigin="anonymous" title="mermaid"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/highlight.min.js" integrity="sha512-1LdB3V708w6G4QRl7NsVdTr7MDibyRXr9stQZ+EGjEE0ZPMZkA//ir7kCWmFyxdAJNIRXdR/ZeJmCV0boyiCXw==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/languages/java.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/languages/json.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/languages/xml.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/languages/shell.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/languages/dos.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.5.1/leaflet.js" integrity="sha512-GffPMF3RvMeYyc1LWMHtK8EbPv0iNZ8/oTtHPx9/cc2ILxQ+u905qIwdpULaqDkyBKgOaB57QTMg7ztg8Jm2Og==" crossorigin="anonymous"></script>
<script>const code_highlighting = true;</script>
<script>const isSiteThemeDark = false;</script>
<script>
const search_config = {"indexURI":"/mosaic/index.json","minLength":1,"threshold":0.3};
const i18n = {"no_results":"No results found","placeholder":"Search...","results":"results found"};
const content_type = {
'post': "Posts",
'project': "Projects",
'publication' : "Publications",
'talk' : "Talks"
};
</script>
<script id="search-hit-fuse-template" type="text/x-template">
<div class="search-hit" id="summary-{{key}}">
<div class="search-hit-content">
<div class="search-hit-name">
<a href="{{relpermalink}}">{{title}}</a>
<div class="article-metadata search-hit-type">{{type}}</div>
<p class="search-hit-description">{{snippet}}</p>
</div>
</div>
</div>
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/3.2.1/fuse.min.js" integrity="sha512-o38bmzBGX+hD3JHWUFCDA09btWaqrNmoJ3RXLlrysA7PP01Kgs4UlE4MhelE1v5dJR3+cxlR4qQlotsW7jKsnw==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/jquery.mark.min.js" integrity="sha512-mhbv5DqBMgrWL+32MmsDOt/OAvqr/cHimk6B8y/bx/xS88MVkYGPiVv2ixKVrkywF2qHplNRUvFsAHUdxZ3Krg==" crossorigin="anonymous"></script>
<script type="application/javascript" src="/mosaic/js/academic.min.0992ad8b8d033c3858bb90b03966346a.js"></script>
<script type="application/javascript" src="/mosaic/js/mosaic-wg-cards.js"></script>
<script>
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
tooltipTriggerList.map(function (tooltipTriggerEl) {
return new window.bootstrap.Tooltip(tooltipTriggerEl)
})
</script>
<div class="footer-wrap">
<div class="container">
<footer class="site-footer">
<div class="row">
<div class="col-sm-4 mb-3 mb-md-0">
<b>Eclipse MOSAIC</b>
<ul>
<li>
<a href="/mosaic/download/" title="Download Eclipse MOSAIC" >
Download Eclipse MOSAIC
</a>
</li>
<li>
<a href="/mosaic/docs/" title="Documentation" >
Documentation
</a>
</li>
<li>
<a href="/mosaic/tutorials/" title="Tutorials" >
Tutorials
</a>
</li>
<li>
<a href="/mosaic/community/#projects" title="Projects" >
Projects
</a>
</li>
<li>
<a href="/mosaic/publications/" title="Publications" >
Publications
</a>
</li>
</ul>
</div>
<div class="col-sm-4 mb-3 mb-md-0">
<b>Community</b>
<ul>
<li>
<a href="/mosaic/community/" title="Eclipse MOSAIC Community" >
Eclipse MOSAIC Community
</a>
</li>
<li>
<a href="/mosaic/contribution/" title="How to contribute" >
How to contribute
</a>
</li>
<li>
<a href="https://github.com/eclipse/mosaic" title="Github" target="_blank" rel="noopener">
Github
</a>
</li>
<li>
<a href="/mosaic/get_in_contact/" title="Contact &amp; Mailing list" >
Contact & Mailing list
</a>
</li>
</ul>
</div>
<div class="col-sm-4 mb-3 mb-md-0">
<b>Eclipse Foundation</b>
<ul>
<li>
<a href="https://www.eclipse.org/" title="About Eclipse Foundation" target="_blank" rel="noopener">
About Eclipse Foundation
</a>
</li>
<li>
<a href="https://www.eclipse.org/legal/privacy.php" title="Privacy Policy" target="_blank" rel="noopener">
Privacy Policy
</a>
</li>
<li>
<a href="https://www.eclipse.org/legal/termsofuse.php" title="Website terms of use" target="_blank" rel="noopener">
Website terms of use
</a>
</li>
<li>
<a href="https://www.eclipse.org/legal/copyright.php" title="Copyright" target="_blank" rel="noopener">
Copyright
</a>
</li>
<li>
<a href="https://www.eclipse.org/legal" title="Legal" target="_blank" rel="noopener">
Legal
</a>
</li>
</ul>
</div>
</div>
<div class="row justify-content-center mt-3 position-relative">
<p class="powered-by text-center font-italic mb-0 pb-0">
Powered by the
<a href="https://sourcethemes.com/academic/" target="_blank" rel="noopener">Academic theme</a> for
<a href="https://gohugo.io" target="_blank" rel="noopener">Hugo</a>.
<br>
Header image &#169; fanjianhua/ iStock
</p>
<span class="position-absolute mr-3 mr-md-0" aria-hidden="true" style="right: 0;">
<a href="#" class="back-to-top">
<span class="button_icon">
<i class="fas fa-chevron-up fa-2x"></i>
</span>
</a>
</span>
</div>
</footer>
</div>
</div>
<div id="modal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Cite</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<pre><code class="tex hljs"></code></pre>
</div>
<div class="modal-footer">
<a class="btn btn-outline-primary my-1 js-copy-cite" href="#" target="_blank">
<i class="fas fa-copy"></i> Copy
</a>
<a class="btn btn-outline-primary my-1 js-download-cite" href="#" target="_blank">
<i class="fas fa-download"></i> Download
</a>
<div id="modal-error"></div>
</div>
</div>
</div>
</div>
</body>
</html>