Aufgrund einer Wartung wird GitLab am 25.01 zwischen 8:00 und 9:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 25.01 between 8:00 and 9:00 am.

ObstacleStrategy.emam 1.45 KB
Newer Older
Bernhard Rumpe's avatar
BR-sy    
Bernhard Rumpe committed
1
/* (c) https://github.com/MontiCore/monticore */
Jean-Marc Ronck's avatar
Jean-Marc Ronck committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package de.rwth.supermario.haller.actuator;

import de.rwth.supermario.haller.tools.OrRelation_2;
import de.rwth.supermario.haller.tools.OrRelation_5;
import de.rwth.supermario.haller.environment.Obstacle;
import de.rwth.supermario.haller.environment.ObstacleWatcher;

import de.rwth.supermario.haller.environment.HoleWatcher;

component ObstacleStrategy {
    ports
        in Z obstDistsX[5],
        in Z obstDistsY[5],
        in Z holeDistance,
        
        out Z jumpAdvice,
        out Z directionAdvice;

    //Every ObstacleWatcher watches a single Obstacle.
    //Obstacles are pipes and staircase blocks.
    instance ObstacleWatcher obstacleWatchers[5];
    connect obstDistsX[:] ->obstacleWatchers[:].ObstacleDistX;
    connect obstDistsY[:] ->obstacleWatchers[:].ObstacleDistY;
    
    //The output of all Watchers is combined via an or-relation.
    instance OrRelation_5 orR_5; 
    connect obstacleWatchers[:].inJumpRange -> orR_5.input[:];
    
    //The HoleWatcher watches the distance to the next hole.
    instance HoleWatcher holeWatch;
    connect holeDistance -> holeWatch.holeDistance;
    
    //Finally, the result from the watchers are combined via or
    instance OrRelation_2 orR_2;
    connect holeWatch.inJumpRange -> orR_2.input[1];
    connect orR_5.output -> orR_2.input[2];
    
    //This results in the final advice for obstacle handling
    connect orR_2.output -> jumpAdvice;
    
    
Bernhard Rumpe's avatar
BR-sy    
Bernhard Rumpe committed
43
}