Commit d4cc81be authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier
Browse files

In "ThreatCognitionModel.java", implemented Gerta's wish and added...

In "ThreatCognitionModel.java", implemented Gerta's wish and added "pedestrianIsBlockedByObstacle()"
parent ba7239b7
Pipeline #257435 passed with stages
in 139 minutes and 51 seconds
......@@ -129,7 +129,37 @@
"bounded" : true,
"referenceCoordinateSystem" : null
},
"obstacles" : [ ],
"obstacles" : [ {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 23.0,
"y" : 3.75
}, {
"x" : 24.5,
"y" : 3.75
}, {
"x" : 24.5,
"y" : 5.5
}, {
"x" : 23.0,
"y" : 5.5
}, {
"x" : 23.0,
"y" : 6.5
}, {
"x" : 25.5,
"y" : 6.5
}, {
"x" : 25.5,
"y" : 3.0
}, {
"x" : 23.0,
"y" : 3.0
} ]
},
"id" : 7
} ],
"measurementAreas" : [ ],
"stairs" : [ ],
"targets" : [ {
......
......@@ -7,6 +7,7 @@ import org.vadere.state.psychology.perception.types.Stimulus;
import org.vadere.state.psychology.perception.types.Threat;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Topography;
import org.vadere.state.simulation.FootstepHistory;
import org.vadere.util.geometry.shapes.VPoint;
import java.util.Collection;
......@@ -94,14 +95,39 @@ public class ThreatCognitionModel implements ICognitionModel {
double distanceToThreat = threatOrigin.distance(pedestrian.getPosition());
boolean pedestrianIsInsideThreatArea = (distanceToThreat <= latestThreat.getRadius());
boolean pedestrianIsBlockedByObstacle = pedestrianIsBlockedByObstacle(pedestrian, topography);
if (pedestrianIsInsideThreatArea) {
// Gerta suggests to apply SelfCategory.OUTSIDE_THREAT_AREA to agents if they are blocked by a wall.
if (pedestrianIsInsideThreatArea && pedestrianIsBlockedByObstacle == false) {
pedestrian.setSelfCategory(SelfCategory.INSIDE_THREAT_AREA);
} else {
pedestrian.setSelfCategory(SelfCategory.OUTSIDE_THREAT_AREA);
}
}
// TODO Write unit tests!
private boolean pedestrianIsBlockedByObstacle(Pedestrian pedestrian, Topography topography) {
boolean isBlocked = false;
int requiredFootSteps = 2;
double requiredSpeedToBeBlocked = 0.05;
double requiredDistanceToObstacle = 1.0;
FootstepHistory footstepHistory = pedestrian.getFootstepHistory();
if (footstepHistory.size() >= requiredFootSteps) {
if (footstepHistory.getAverageSpeedInMeterPerSecond() <= requiredSpeedToBeBlocked) {
// Watch out: This is probably a very expensive call but Gerta suggests to include it to get a realistic behavior!
if (topography.distanceToObstacle(pedestrian.getPosition()) <= requiredDistanceToObstacle) {
isBlocked = true;
}
}
}
return isBlocked;
}
/**
* If a threatened ingroup pedestrian is nearby, use the same reaction as if
* the current "pedestrian" would have perceived the same threat. I.e, imitate
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment