Commit e11c4d26 authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier

Started implementing evasion behavior on locomotion layer in "OSMBehaviorController.java"

parent 842911d1
Pipeline #269561 failed with stages
in 79 minutes and 6 seconds
{
"name" : "19-CounterFlow-CounterflowCognitionModel",
"description" : "",
"release" : "1.12",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.EventtimePedestrianIdOutputFile",
"filename" : "postvis.traj",
"processors" : [ 3, 4, 5 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOverlapOutputFile",
"filename" : "overlaps.csv",
"processors" : [ 1 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.NoDataKeyOutputFile",
"filename" : "overlapCount.txt",
"processors" : [ 2 ]
} ],
"processors" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianOverlapProcessor",
"id" : 1
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.NumberOverlapsProcessor",
"id" : 2,
"attributesType" : "org.vadere.state.attributes.processor.AttributesNumberOverlapsProcessor",
"attributes" : {
"pedestrianOverlapProcessorId" : 1
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepProcessor",
"id" : 3
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepTargetIDProcessor",
"id" : 4
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepPsychologyStatusProcessor",
"id" : 5
} ],
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.osm.OptimalStepsModel",
"attributesModel" : {
"org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 4,
"numberOfCircles" : 1,
"optimizationType" : "NELDER_MEAD",
"varyStepDirection" : true,
"movementType" : "ARBITRARY",
"stepLengthIntercept" : 0.4625,
"stepLengthSlopeSpeed" : 0.2345,
"stepLengthSD" : 0.036,
"movementThreshold" : 0.0,
"minStepLength" : 0.1,
"minimumStepLength" : true,
"maxStepDuration" : 1.7976931348623157E308,
"dynamicStepLength" : true,
"updateType" : "EVENT_DRIVEN",
"seeSmallWalls" : false,
"targetPotentialModel" : "org.vadere.simulator.models.potential.fields.PotentialFieldTargetGrid",
"pedestrianPotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldPedestrianCompactSoftshell",
"obstaclePotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldObstacleCompactSoftshell",
"submodels" : [ ]
},
"org.vadere.state.attributes.models.AttributesPotentialCompactSoftshell" : {
"pedPotentialIntimateSpaceWidth" : 0.45,
"pedPotentialPersonalSpaceWidth" : 1.2,
"pedPotentialHeight" : 50.0,
"obstPotentialWidth" : 0.8,
"obstPotentialHeight" : 6.0,
"intimateSpaceFactor" : 1.2,
"personalSpacePower" : 1,
"intimateSpacePower" : 1
},
"org.vadere.state.attributes.models.AttributesFloorField" : {
"createMethod" : "HIGH_ACCURACY_FAST_MARCHING",
"potentialFieldResolution" : 0.1,
"obstacleGridPenalty" : 0.1,
"targetAttractionStrength" : 1.0,
"cacheType" : "NO_CACHE",
"cacheDir" : "",
"timeCostAttributes" : {
"standardDeviation" : 0.7,
"type" : "UNIT",
"obstacleDensityWeight" : 3.5,
"pedestrianSameTargetDensityWeight" : 3.5,
"pedestrianOtherTargetDensityWeight" : 3.5,
"pedestrianWeight" : 3.5,
"queueWidthLoading" : 1.0,
"pedestrianDynamicWeight" : 6.0,
"loadingType" : "CONSTANT",
"width" : 0.2,
"height" : 1.0
}
}
},
"attributesSimulation" : {
"finishTime" : 180.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.1,
"writeSimulationData" : true,
"visualizationEnabled" : true,
"printFPS" : false,
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 6138355022448163583,
"simulationSeed" : 6138355022448163583
},
"attributesPsychology" : {
"usePsychologyLayer" : true,
"psychologyLayer" : {
"perception" : "SimplePerceptionModel",
"cognition" : "CounterflowCognitionModel"
}
},
"topography" : {
"attributes" : {
"bounds" : {
"x" : 0.0,
"y" : 0.0,
"width" : 20.0,
"height" : 2.0
},
"boundingBoxWidth" : 0.5,
"bounded" : true,
"referenceCoordinateSystem" : null
},
"obstacles" : [ ],
"measurementAreas" : [ ],
"stairs" : [ ],
"targets" : [ {
"id" : 1,
"absorbing" : true,
"shape" : {
"x" : 18.5,
"y" : 0.5,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
}, {
"id" : 2,
"absorbing" : true,
"shape" : {
"x" : 0.5,
"y" : 0.5,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"targetChangers" : [ ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : 3,
"shape" : {
"x" : 1.6,
"y" : 0.5,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
},
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 1.0 ],
"spawnNumber" : 20,
"maxSpawnNumberTotal" : -1,
"startTime" : 0.0,
"endTime" : 0.0,
"spawnAtRandomPositions" : false,
"spawnAtGridPositionsCA" : false,
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
}, {
"id" : 4,
"shape" : {
"x" : 17.4,
"y" : 0.5,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
},
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 1.0 ],
"spawnNumber" : 20,
"maxSpawnNumberTotal" : -1,
"startTime" : 0.0,
"endTime" : 0.0,
"spawnAtRandomPositions" : false,
"spawnAtGridPositionsCA" : false,
"useFreeSpaceOnly" : true,
"targetIds" : [ 2 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.2,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.34,
"speedDistributionStandardDeviation" : 0.26,
"minimumSpeed" : 0.5,
"maximumSpeed" : 2.2,
"acceleration" : 2.0,
"footstepHistorySize" : 4,
"searchRadius" : 1.0,
"walkingDirectionCalculation" : "BY_TARGET_CENTER",
"walkingDirectionSameIfAngleLessOrEqual" : 45.0
},
"teleporter" : null,
"attributesCar" : null
},
"stimulusInfos" : [ ]
}
}
\ No newline at end of file
package org.vadere.simulator.models.osm; package org.vadere.simulator.models.osm;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.math.exception.OutOfRangeException;
import org.apache.commons.math3.distribution.BinomialDistribution;
import org.apache.commons.math3.random.JDKRandomGenerator;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.vadere.simulator.models.potential.combinedPotentials.CombinedPotentialStrategy; import org.vadere.simulator.models.potential.combinedPotentials.CombinedPotentialStrategy;
...@@ -15,8 +18,7 @@ import org.vadere.state.scenario.ScenarioElement; ...@@ -15,8 +18,7 @@ import org.vadere.state.scenario.ScenarioElement;
import org.vadere.state.scenario.Target; import org.vadere.state.scenario.Target;
import org.vadere.state.scenario.Topography; import org.vadere.state.scenario.Topography;
import org.vadere.state.simulation.FootStep; import org.vadere.state.simulation.FootStep;
import org.vadere.util.geometry.shapes.VPoint; import org.vadere.util.geometry.shapes.*;
import org.vadere.util.geometry.shapes.Vector2D;
import org.vadere.util.logging.Logger; import org.vadere.util.logging.Logger;
import java.util.LinkedList; import java.util.LinkedList;
...@@ -41,8 +43,30 @@ import java.util.stream.Collectors; ...@@ -41,8 +43,30 @@ import java.util.stream.Collectors;
*/ */
public class OSMBehaviorController { public class OSMBehaviorController {
// Static Variables
private static Logger logger = Logger.getLogger(OSMBehaviorController.class); private static Logger logger = Logger.getLogger(OSMBehaviorController.class);
private static final int BINOMIAL_DISTRIBUTION_SUCCESS_VALUE = 1;
// Member Variables
BinomialDistribution evasionDirectionDistribution;
// Constructors
public OSMBehaviorController() {
evasionDirectionDistribution = createEvasionDistribution(0, 0.8);
}
private BinomialDistribution createEvasionDistribution(int seed, double evadeRightProbability) {
if (evadeRightProbability < 0 || evadeRightProbability > 1) {
throw new OutOfRangeException(evadeRightProbability, 0, 1);
}
JDKRandomGenerator randomGenerator = new JDKRandomGenerator();
randomGenerator.setSeed(seed);
return new BinomialDistribution(randomGenerator, BINOMIAL_DISTRIBUTION_SUCCESS_VALUE, evadeRightProbability);
}
// Methods
public void makeStepToTarget(@NotNull final PedestrianOSM pedestrian, @NotNull final Topography topography) { public void makeStepToTarget(@NotNull final PedestrianOSM pedestrian, @NotNull final Topography topography) {
// this can cause problems if the pedestrian desired speed is 0 (see speed adjuster) // this can cause problems if the pedestrian desired speed is 0 (see speed adjuster)
pedestrian.updateNextPosition(); pedestrian.updateNextPosition();
...@@ -138,6 +162,64 @@ public class OSMBehaviorController { ...@@ -138,6 +162,64 @@ public class OSMBehaviorController {
pedestrian.setTimeOfNextStep(stepEndTime); pedestrian.setTimeOfNextStep(stepEndTime);
} }
/**
* 1. Use TargetAttractionAndEvasionStrategy to weight agents a little less
* 2. Use gradient to get walking direction of pedestrian
* 3. Sample "evasionDirectionDistribution" to evaluate evasion direction (right or left)
* 4. Call updateNextPosition() with adapted reachable area (use gradient and evasion direction for this)
* 5. Restore TargetAttractionStrategy
*
* @param pedestrian The pedestrian to evade
* @param topography The topography to be able to move the pedestrian within the topography
* @param timeStepInSec The current simulation time in second
*/
public void evade(PedestrianOSM pedestrian, Topography topography, double timeStepInSec) {
pedestrian.setCombinedPotentialStrategy(CombinedPotentialStrategy.TARGET_ATTRACTION_AND_EVASION_STRATEGY);
boolean evadeRight = evasionDirectionDistribution.sample() == BINOMIAL_DISTRIBUTION_SUCCESS_VALUE;
VShape reachableArea = createIsoscelesTriangleAsReachableArea(pedestrian, evadeRight);
pedestrian.updateNextPosition(reachableArea);
makeStep(pedestrian, topography, pedestrian.getDurationNextStep());
pedestrian.setTimeOfNextStep(pedestrian.getTimeOfNextStep() + pedestrian.getDurationNextStep());
pedestrian.setCombinedPotentialStrategy(CombinedPotentialStrategy.TARGET_ATTRACTION_STRATEGY);
}
/**
* Use an isosceles triangle as reachable area where the isosceles legs represent pedestrian's step length
* and the angle between both legs is 30° deg. Both legs meet at pedestrian's current position.
* This triangle is rotated by using the targetGradient plus/minus some evasion offset of 45° deg.
*
* @param pedestrian The pedestrian to derive current position and walking direction (by using the gradient)
* @param evadeRight Decides if the isosceles triangle should be rotated by +45° deg or -45° deg
* @return The new reachable area for the pedestrian as isosceles triangle
*/
public VShape createIsoscelesTriangleAsReachableArea(PedestrianOSM pedestrian, boolean evadeRight) {
double legAngleInRadians = Math.toRadians(15);
double stepSize = pedestrian.getDesiredStepSize();
double xCoord = stepSize * Math.cos(legAngleInRadians);
double yCoord = stepSize * Math.sin(legAngleInRadians);
Vector2D p1 = new Vector2D(0, 0);
Vector2D p2 = new Vector2D(xCoord, yCoord);
Vector2D p3 = new Vector2D(xCoord, -yCoord);
Vector2D targetGradient = pedestrian.getTargetGradient(pedestrian.getPosition());
Vector2D pedestrianWalkingDirection = new Vector2D(targetGradient.x * -1, targetGradient.y);
double walkingAngleRad = pedestrianWalkingDirection.angleToZero();
double evasionAngleRad = (evadeRight) ? -Math.toRadians(45) : +Math.toRadians(45);
double nextWalkingAngleRad = walkingAngleRad + evasionAngleRad;
Vector2D p1Rotated = p1.rotate(nextWalkingAngleRad);
Vector2D p2Rotated = p2.rotate(nextWalkingAngleRad);
Vector2D p3Rotated = p3.rotate(nextWalkingAngleRad);
VPoint base = pedestrian.getPosition();
VTriangle rotatedTriangleCounterClockwise = new VTriangle(base.add(p1Rotated), base.add(p3Rotated), base.add(p2Rotated));
return rotatedTriangleCounterClockwise;
}
/** /**
* Maximize distance to the threat (a threat) and increase speed. * Maximize distance to the threat (a threat) and increase speed.
* *
......
...@@ -4,11 +4,8 @@ import org.apache.commons.lang3.tuple.Pair; ...@@ -4,11 +4,8 @@ import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.vadere.simulator.models.StepSizeAdjuster; import org.vadere.simulator.models.StepSizeAdjuster;
import org.vadere.simulator.models.osm.optimization.OptimizationMetric; import org.vadere.simulator.models.osm.optimization.OptimizationMetric;
import org.vadere.simulator.models.potential.combinedPotentials.CombinedPotentialStrategy; import org.vadere.simulator.models.potential.combinedPotentials.*;
import org.vadere.simulator.models.potential.combinedPotentials.ICombinedPotentialStrategy; import org.vadere.util.geometry.shapes.*;
import org.vadere.simulator.models.potential.combinedPotentials.TargetAttractionStrategy;
import org.vadere.simulator.models.potential.combinedPotentials.TargetRepulsionStrategy;
import org.vadere.util.geometry.shapes.Vector2D;
import org.vadere.simulator.models.SpeedAdjuster; import org.vadere.simulator.models.SpeedAdjuster;
import org.vadere.simulator.models.osm.optimization.StepCircleOptimizer; import org.vadere.simulator.models.osm.optimization.StepCircleOptimizer;
import org.vadere.simulator.models.osm.stairOptimization.StairStepOptimizer; import org.vadere.simulator.models.osm.stairOptimization.StairStepOptimizer;
...@@ -23,9 +20,6 @@ import org.vadere.state.scenario.Pedestrian; ...@@ -23,9 +20,6 @@ import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Stairs; import org.vadere.state.scenario.Stairs;
import org.vadere.state.scenario.Topography; import org.vadere.state.scenario.Topography;
; ;
import org.vadere.util.geometry.shapes.IPoint;
import org.vadere.util.geometry.shapes.VCircle;
import org.vadere.util.geometry.shapes.VPoint;
import java.util.*; import java.util.*;
...@@ -194,6 +188,40 @@ public class PedestrianOSM extends Pedestrian { ...@@ -194,6 +188,40 @@ public class PedestrianOSM extends Pedestrian {
} }
public void updateNextPosition(VShape reachableArea) {
if (!hasNextTarget() || getDurationNextStep() > getAttributesOSM().getMaxStepDuration()) {
this.nextPosition = getPosition();
} else if (isCurrentTargetAnAgent() == false && topography.getTarget(getNextTargetId()).getShape().contains(getPosition())) {
this.nextPosition = getPosition();
} else {
// get stairs object an agent may be on - remains null if agent is on area
Stairs stairs = null;
for (Stairs singleStairs : topography.getStairs()) {
if (singleStairs.getShape().contains(getPosition())) {
stairs = singleStairs;
break;
}
}
if (stairs == null) { // --> agent is on area
refreshRelevantPedestrians();
nextPosition = stepCircleOptimizer.getNextPosition(this, reachableArea);
if(attributesOSM.isMinimumStepLength() && getPosition().distance(nextPosition) < minStepLength) {
nextPosition = getPosition();
}
} else {
stairStepOptimizer = new StairStepOptimizer(stairs);
reachableArea = new VCircle(getPosition(), stairs.getTreadDepth() * 1.99);
refreshRelevantPedestrians();
nextPosition = stairStepOptimizer.getNextPosition(this, reachableArea);
}
}
}
/** /**
* Returns the constant free flow step size * Returns the constant free flow step size
* *
...@@ -338,6 +366,10 @@ public class PedestrianOSM extends Pedestrian { ...@@ -338,6 +366,10 @@ public class PedestrianOSM extends Pedestrian {
this.combinedPotentialStrategy = new TargetAttractionStrategy(this.potentialFieldTarget, this.combinedPotentialStrategy = new TargetAttractionStrategy(this.potentialFieldTarget,
this.potentialFieldObstacle, this.potentialFieldObstacle,
this.potentialFieldPedestrian); this.potentialFieldPedestrian);
} else if (newStrategy == CombinedPotentialStrategy.TARGET_ATTRACTION_AND_EVASION_STRATEGY) {
this.combinedPotentialStrategy = new TargetAttractionAndEvasionStrategy(this.potentialFieldTarget,
this.potentialFieldObstacle,
this.potentialFieldPedestrian);
} else if (newStrategy == CombinedPotentialStrategy.TARGET_REPULSION_STRATEGY) { } else if (newStrategy == CombinedPotentialStrategy.TARGET_REPULSION_STRATEGY) {
this.combinedPotentialStrategy = new TargetRepulsionStrategy(this.potentialFieldTarget, this.combinedPotentialStrategy = new TargetRepulsionStrategy(this.potentialFieldTarget,
this.potentialFieldObstacle, this.potentialFieldObstacle,
......
...@@ -62,6 +62,8 @@ public class UpdateSchemeEventDriven implements UpdateSchemeOSM { ...@@ -62,6 +62,8 @@ public class UpdateSchemeEventDriven implements UpdateSchemeOSM {
} else { } else {
osmBehaviorController.makeStepToTarget(pedestrian, topography); osmBehaviorController.makeStepToTarget(pedestrian, topography);
} }
} else if (selfCategory == SelfCategory.EVADE) {
osmBehaviorController.evade(pedestrian, topography, timeStepInSec);
} else if (selfCategory == SelfCategory.INSIDE_THREAT_AREA) { } else if (selfCategory == SelfCategory.INSIDE_THREAT_AREA) {
osmBehaviorController.changeToTargetRepulsionStrategyAndIncreaseSpeed(pedestrian, topography); osmBehaviorController.changeToTargetRepulsionStrategyAndIncreaseSpeed(pedestrian, topography);
osmBehaviorController.makeStepToTarget(pedestrian, topography); osmBehaviorController.makeStepToTarget(pedestrian, topography);
......
...@@ -8,5 +8,6 @@ package org.vadere.simulator.models.potential.combinedPotentials; ...@@ -8,5 +8,6 @@ package org.vadere.simulator.models.potential.combinedPotentials;
*/ */
public enum CombinedPotentialStrategy { public enum CombinedPotentialStrategy {
TARGET_ATTRACTION_STRATEGY, TARGET_ATTRACTION_STRATEGY,
TARGET_ATTRACTION_AND_EVASION_STRATEGY,
TARGET_REPULSION_STRATEGY TARGET_REPULSION_STRATEGY
} }
package org.vadere.simulator.models.potential.combinedPotentials;
import org.vadere.simulator.models.potential.fields.IPotentialFieldTarget;
import org.vadere.simulator.models.potential.fields.PotentialFieldAgent;
import org.vadere.simulator.models.potential.fields.PotentialFieldObstacle;
import org.vadere.state.scenario.Agent;
import org.vadere.util.geometry.shapes.IPoint;
import java.util.Collection;
/**
* Combine potential so that agents are attracted by targets
* but other agents are less weighted.
*/
public class TargetAttractionAndEvasionStrategy implements ICombinedPotentialStrategy {
private IPotentialFieldTarget potentialFieldTarget;
private PotentialFieldObstacle potentialFieldObstacle;
private PotentialFieldAgent potentialFieldAgent;
public TargetAttractionAndEvasionStrategy(IPotentialFieldTarget potentialFieldTarget, PotentialFieldObstacle potentialFieldObstacle, PotentialFieldAgent potentialFieldAgent) {
this.potentialFieldTarget = potentialFieldTarget;
this.potentialFieldObstacle = potentialFieldObstacle;
this.potentialFieldAgent = potentialFieldAgent;
}
@Override
public double getValue(IPoint newPos, Agent thisAgent, Collection<? extends Agent> otherAgents) {
double targetPotential = potentialFieldTarget.getPotential(newPos, thisAgent);
double obstaclePotential = potentialFieldObstacle.getObstaclePotential(newPos, thisAgent);
double agentPotential = potentialFieldAgent.getAgentPotential(newPos, thisAgent, otherAgents);
agentPotential = agentPotential * 0.8;
return targetPotential + agentPotential + obstaclePotential;
}
}
...@@ -12,9 +12,7 @@ import org.vadere.state.attributes.scenario.AttributesTarget; ...@@ -12,9 +12,7 @@ import org.vadere.state.attributes.scenario.AttributesTarget;
import org.vadere.state.psychology.cognition.SelfCategory; import org.vadere.state.psychology.cognition.SelfCategory;
import org.vadere.state.scenario.Target; import org.vadere.state.scenario.Target;
import org.vadere.state.scenario.Topography; import org.vadere.state.scenario.Topography;
import org.vadere.util.geometry.shapes.VCircle; import org.vadere.util.geometry.shapes.*;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VRectangle;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
...@@ -622,4 +620,29 @@ public class OSMBehaviorControllerTest { ...@@ -622,4 +620,29 @@ public class OSMBehaviorControllerTest {
double expectedTimeOfNextStep = currentSimTimeInSec + timeOfNextStep; double expectedTimeOfNextStep = currentSimTimeInSec + timeOfNextStep;
assertEquals(expectedTimeOfNextStep, pedestrian1.getTimeOfNextStep(), ALLOWED_DOUBLE_TOLERANCE); assertEquals(expectedTimeOfNextStep, pedestrian1.getTimeOfNextStep(), ALLOWED_DOUBLE_TOLERANCE);
} }
@Test
public void createIsoscelesTriangleAsReachableAreaReturnsTriangleTypes() {
createOppositeDirectionVariation1Topography();
boolean evadeRight = true;
OSMBehaviorController controllerUnderTest = new OSMBehaviorController();
for (int i = 0; i < 5; i++) {
VShape reachableArea = controllerUnderTest.createIsoscelesTriangleAsReachableArea(pedestrian1, evadeRight);
assertTrue(reachableArea instanceof VTriangle);
}
}
@Test
public void createIsoscelesTriangleAsReachableAreaReturnsACorrectTriangleForPedestrian1() {
createOppositeDirectionVariation1Topography();
boolean evadeRight = true;
OSMBehaviorController controllerUnderTest = new OSMBehaviorController();
// Ped1 walks from (0,0) to (-1,0) => walking direction (gradient) is roughly (-1, 0).
VShape reachableArea = controllerUnderTest.createIsoscelesTriangleAsReachableArea(pedestrian2, evadeRight);
// TODO Assert that coordinates match roughly the expectation.
}
} }
\ No newline at end of file
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