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

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

In "PedestrianBHM", handle "SelfCategory.EVADE" correctly for the very first...

In "PedestrianBHM", handle "SelfCategory.EVADE" correctly for the very first time (but requires some refactoring)
parent d078464d
......@@ -84,7 +84,7 @@
}
},
"attributesSimulation" : {
"finishTime" : 200.0,
"finishTime" : 100.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.1,
"writeSimulationData" : true,
......
{
"name" : "BHM-Defaults-WithFloorField_CounterflowCognitionModel",
"description" : "",
"release" : "1.14",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.EventtimePedestrianIdOutputFile",
"filename" : "postvis.traj",
"processors" : [ 1, 2, 3 ]
} ],
"processors" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepProcessor",
"id" : 1
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepTargetIDProcessor",
"id" : 2
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepPsychologyStatusProcessor",
"id" : 3
} ],
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.bhm.BehaviouralHeuristicsModel",
"attributesModel" : {
"org.vadere.state.attributes.models.AttributesBHM" : {
"stepLengthIntercept" : 0.4625,
"stepLengthSlopeSpeed" : 0.2345,
"stepLengthSD" : 0.036,
"stepLengthDeviation" : false,
"navigationCluster" : false,
"navigationFollower" : false,
"followerProximityNavigation" : true,
"navigationModel" : "NavigationProximity",
"directionWallDistance" : false,
"tangentialEvasion" : true,
"sidewaysEvasion" : false,
"onlyEvadeContraFlow" : false,
"makeSmallSteps" : false,
"differentBehaviour" : false,
"differentEvasionBehaviourPercentage" : [ ],
"varyingBehaviour" : true,
"adaptiveBehaviourDensity" : false,
"adaptiveBehaviourStepsRemained" : [ ],
"switchBehaviour" : false,
"evasionDetourThreshold" : 0.1,
"onlyEvadeContraFlowAngle" : 2.0943951023931953,
"followerAngleMovement" : 1.5707963267948966,
"followerAnglePosition" : 1.5707963267948966,
"followerDistance" : 10.0,
"smallStepResolution" : 5,
"plannedStepsAhead" : 5,
"obstacleRepulsionReach" : 1.0,
"obstacleRepulsionMaxWeight" : 0.5,
"distanceToKeep" : 0.5,
"backwardsAngle" : 1.5707963267948966,
"reconsiderOldTargets" : false,
"targetThresholdX" : 1.7976931348623157E308,
"targetThresholdY" : 1.7976931348623157E308,
"spaceToKeep" : 0.01,
"stepAwayFromCollisions" : false
},
"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.2,
"type" : "DISTANCE_TO_OBSTACLES",
"obstacleDensityWeight" : 1.0,
"pedestrianSameTargetDensityWeight" : 3.5,
"pedestrianOtherTargetDensityWeight" : 3.5,
"pedestrianWeight" : 3.5,
"queueWidthLoading" : 1.0,
"pedestrianDynamicWeight" : 6.0,
"loadingType" : "CONSTANT",
"width" : 1.0,
"height" : 5.0
}
}
},
"attributesSimulation" : {
"finishTime" : 100.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.1,
"writeSimulationData" : true,
"visualizationEnabled" : true,
"printFPS" : false,
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : -8539920412942853482,
"simulationSeed" : 0
},
"attributesPsychology" : {
"usePsychologyLayer" : true,
"psychologyLayer" : {
"perception" : "SimplePerceptionModel",
"cognition" : "CounterflowCognitionModel"
}
},
"attributesStrategy" : {
"useStrategyModel" : false,
"strategyModel" : null,
"arguments" : [ ],
"requiredDataProcessorIds" : [ ]
},
"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" : 4.0,
"walkingDirectionCalculation" : "BY_TARGET_CENTER",
"walkingDirectionSameIfAngleLessOrEqual" : 45.0
},
"teleporter" : null,
"attributesCar" : null
},
"stimulusInfos" : [ ]
}
}
\ No newline at end of file
......@@ -63,7 +63,7 @@
}
},
"attributesSimulation" : {
"finishTime" : 200.0,
"finishTime" : 100.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.1,
"writeSimulationData" : true,
......
......@@ -4,8 +4,10 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.vadere.simulator.models.bhm.helpers.navigation.INavigation;
import org.vadere.simulator.models.bhm.helpers.navigation.NavigationBuilder;
import org.vadere.simulator.models.bhm.helpers.navigation.NavigationEvasion;
import org.vadere.simulator.models.bhm.helpers.targetdirection.*;
import org.vadere.simulator.models.potential.fields.IPotentialFieldTarget;
import org.vadere.simulator.utils.topography.TopographyHelper;
import org.vadere.state.attributes.models.AttributesBHM;
import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.psychology.cognition.SelfCategory;
......@@ -175,8 +177,9 @@ public class PedestrianBHM extends Pedestrian {
} else if (selfCategory == SelfCategory.WAIT) {
// do nothing
} else if (selfCategory == SelfCategory.EVADE) {
// TODO: Instantiate "NavigationEvasion" on the fly and calculate position.
nextPosition = navigation.getNavigationPosition();
INavigation evasionNavigation = new NavigationEvasion();
evasionNavigation.initialize(this, topography, null);
nextPosition = evasionNavigation.getNavigationPosition();
makeStep();
} else {
throw new IllegalArgumentException("Unsupported SelfCategory: " + selfCategory);
......@@ -334,9 +337,24 @@ public class PedestrianBHM extends Pedestrian {
* Check collisions on the path.
*/
public boolean collidesWithPedestrianOnPath(VPoint position) {
boolean isCollision = false;
Pedestrian collision = findCollisionPedestrian(position, true);
return collision != null;
if (collision != null && otherPedIsCloserToTarget(this, collision)) {
isCollision = true;
}
return isCollision;
}
private boolean otherPedIsCloserToTarget(PedestrianBHM me, Pedestrian other) {
IPotentialFieldTarget myTargetPotential = me.getPotentialFieldTarget();
double myDistanceToTarget = myTargetPotential.getPotential(me.getPosition(), me);
double otherDistanceToTarget = myTargetPotential.getPotential(other.getPosition(), other);
return otherDistanceToTarget < myDistanceToTarget;
}
/**
......@@ -396,6 +414,15 @@ public class PedestrianBHM extends Pedestrian {
}
}
// TODO: Think if method works as expected. If so, above method should use "collidesWithObstacle(pos, 0)"!
public boolean collidesWithObstacle(VPoint position, double allowedMargin) {
if (detectObstacleProximity(position, getRadius() + allowedMargin).isEmpty()) {
return false;
} else {
return true;
}
}
/**
* This does not check collisions on the path, just collisions with position!
*/
......
......@@ -59,7 +59,7 @@ public class NavigationEvasion implements INavigation {
VPoint possiblePosition = getNextPosition(currentWalkingDirection, rotation, stepLengthTrial);
if (collideWithPedestrian(possiblePosition, me.getRadius(), closePedestrians) == false) {
if (me.collidesWithObstacle(possiblePosition) == false) {
if (me.collidesWithObstacle(possiblePosition, -0.1) == false) {
nextPosition = possiblePosition;
break;
}
......
......@@ -3,6 +3,7 @@ package org.vadere.simulator.models.bhm.helpers.navigation;
import org.jetbrains.annotations.NotNull;
import org.vadere.simulator.models.bhm.PedestrianBHM;
import org.vadere.simulator.models.bhm.UtilsBHM;
import org.vadere.simulator.models.potential.fields.IPotentialFieldTarget;
import org.vadere.state.attributes.models.AttributesBHM;
import org.vadere.state.scenario.Obstacle;
import org.vadere.state.scenario.Pedestrian;
......@@ -80,6 +81,15 @@ public class NavigationProximity implements INavigation {
//return newEnd;
}
private boolean otherPedIsCloserToTarget(PedestrianBHM me, Pedestrian other) {
IPotentialFieldTarget myTargetPotential = me.getPotentialFieldTarget();
double myDistanceToTarget = myTargetPotential.getPotential(me.getPosition(), me);
double otherDistanceToTarget = myTargetPotential.getPotential(other.getPosition(), other);
return otherDistanceToTarget < myDistanceToTarget;
}
@Override
public VPoint getNavigationPosition() {
......@@ -98,7 +108,7 @@ public class NavigationProximity implements INavigation {
if (me.evadesTangentially()) {
Pedestrian collisionPed = me.findCollisionPedestrian(result, false);
if (collisionPed != null) {
if (collisionPed != null && otherPedIsCloserToTarget(me, collisionPed)) {
targetDirection = false;
// walk away if currently in a collision
......
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