11.08., 9:00 - 11:00: Due to updates GitLab will be unavailable for some minutes between 09:00 and 11:00.

Commit 732a862f authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier

Refined method "OSMBehaviorController.evaded()" to get first working simulation

parent c8bddfb5
Pipeline #272883 passed with stages
in 139 minutes and 28 seconds
...@@ -221,7 +221,7 @@ ...@@ -221,7 +221,7 @@
"maximumSpeed" : 2.2, "maximumSpeed" : 2.2,
"acceleration" : 2.0, "acceleration" : 2.0,
"footstepHistorySize" : 4, "footstepHistorySize" : 4,
"searchRadius" : 1.0, "searchRadius" : 4.0,
"walkingDirectionCalculation" : "BY_TARGET_CENTER", "walkingDirectionCalculation" : "BY_TARGET_CENTER",
"walkingDirectionSameIfAngleLessOrEqual" : 45.0 "walkingDirectionSameIfAngleLessOrEqual" : 45.0
}, },
......
...@@ -21,6 +21,7 @@ import org.vadere.state.simulation.FootStep; ...@@ -21,6 +21,7 @@ import org.vadere.state.simulation.FootStep;
import org.vadere.util.geometry.shapes.*; import org.vadere.util.geometry.shapes.*;
import org.vadere.util.logging.Logger; import org.vadere.util.logging.Logger;
import java.awt.geom.Rectangle2D;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Vector; import java.util.Vector;
...@@ -180,7 +181,13 @@ public class OSMBehaviorController { ...@@ -180,7 +181,13 @@ public class OSMBehaviorController {
boolean evadeRight = evasionDirectionDistribution.sample() == BINOMIAL_DISTRIBUTION_SUCCESS_VALUE; boolean evadeRight = evasionDirectionDistribution.sample() == BINOMIAL_DISTRIBUTION_SUCCESS_VALUE;
VShape reachableArea = createCircularReachableAreaInEvasionDirection(pedestrian, evadeRight); VShape reachableArea = createCircularReachableAreaInEvasionDirection(pedestrian, evadeRight);
pedestrian.updateNextPosition(reachableArea); // TODO Only the colliding agents could evade tangentially.
// Other evading agents could follow the foremost evading agent.
if (topographyContainsReachableArea(topography, reachableArea)) {
pedestrian.setNextPosition(reachableArea.getCentroid());
} else {
pedestrian.updateNextPosition(reachableArea);
}
makeStep(pedestrian, topography, pedestrian.getDurationNextStep()); makeStep(pedestrian, topography, pedestrian.getDurationNextStep());
pedestrian.setTimeOfNextStep(pedestrian.getTimeOfNextStep() + pedestrian.getDurationNextStep()); pedestrian.setTimeOfNextStep(pedestrian.getTimeOfNextStep() + pedestrian.getDurationNextStep());
...@@ -201,6 +208,16 @@ public class OSMBehaviorController { ...@@ -201,6 +208,16 @@ public class OSMBehaviorController {
return reachableArea; return reachableArea;
} }
private boolean topographyContainsReachableArea(Topography topography, VShape reachableArea) {
Rectangle2D.Double bounds = topography.getBounds();
double boundsWidth = topography.getBoundingBoxWidth();
Rectangle2D.Double validArea = new Rectangle2D.Double(bounds.x + boundsWidth, bounds.y + boundsWidth, bounds.width - 2 * boundsWidth, bounds.height - 2 * boundsWidth);
boolean reachableAreaInsideBoundary = validArea.contains(reachableArea.getCentroid().x, reachableArea.getCentroid().y);
return reachableAreaInsideBoundary;
}
// TODO: Maybe, remove this method because low-level (optimization) code expects "reachableArea" to be of type "VCircle". :/ // TODO: Maybe, remove this method because low-level (optimization) code expects "reachableArea" to be of type "VCircle". :/
/** /**
* Use an isosceles triangle as reachable area where the isosceles legs represent pedestrian's step length * Use an isosceles triangle as reachable area where the isosceles legs represent pedestrian's step length
......
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