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

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

Finished very first version of evasion behavior in "PedestrianBHM" and added...

Finished very first version of evasion behavior in "PedestrianBHM" and added "BHM-Defaults-WithFloorField.scenario
parent 7467e928
{
"name" : "BHM-Defaults-WithFloorField",
"description" : "",
"release" : "1.14",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.EventtimePedestrianIdOutputFile",
"filename" : "postvis.traj",
"processors" : [ 1, 2 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOverlapOutputFile",
"filename" : "overlaps.csv",
"processors" : [ 3 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.NoDataKeyOutputFile",
"filename" : "overlapCount.txt",
"processors" : [ 4 ]
} ],
"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.PedestrianOverlapProcessor",
"id" : 3
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.NumberOverlapsProcessor",
"id" : 4,
"attributesType" : "org.vadere.state.attributes.processor.AttributesNumberOverlapsProcessor",
"attributes" : {
"pedestrianOverlapProcessorId" : 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,
"directionWallDistance" : false,
"tangentialEvasion" : true,
"sidewaysEvasion" : false,
"onlyEvadeContraFlow" : false,
"makeSmallSteps" : false,
"followerProximityNavigation" : true,
"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" : 200.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.1,
"writeSimulationData" : true,
"visualizationEnabled" : true,
"printFPS" : false,
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : -8539920412942853482,
"simulationSeed" : 0
},
"attributesPsychology" : {
"usePsychologyLayer" : false,
"psychologyLayer" : {
"perception" : "SimplePerceptionModel",
"cognition" : "SimpleCognitionModel"
}
},
"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
......@@ -76,6 +76,10 @@ public class PedestrianBHM extends Pedestrian {
// model building ...
// TODO: Implement a model builder class similar to "CognitionModelBuilder".
// Select a "Navigation" class by passing a simple string.
this.navigation = new NavigationEvasion(this, topography);
/*
if (attributesBHM.isNavigationCluster()) {
this.navigation = new NavigationCluster(this, topography, random);
if (attributesBHM.isNavigationFollower()) {
......@@ -91,6 +95,7 @@ public class PedestrianBHM extends Pedestrian {
} else {
this.navigation = new NavigationProximity(this, random);
}
*/
if (attributesBHM.isDirectionWallDistance()) {
directionAddends.add(new DirectionAddendObstacle(this));
......@@ -188,6 +193,8 @@ public class PedestrianBHM extends Pedestrian {
} else if (selfCategory == SelfCategory.EVADE) {
// TODO: Force tangential or sideways evasion using BHM's internal methods
// or by implementing "Navigation" interface myself and always evade to the right hand side.
nextPosition = navigation.getNavigationPosition();
makeStep();
}
else {
throw new IllegalArgumentException("Unsupported SelfCategory: " + selfCategory);
......
......@@ -262,7 +262,7 @@ public class NavigationEvasionTest {
}
@Test
public void getNavigationPositionReturnsTangentialPositionHalfSpeedIfNotOccupied() {
public void getNavigationPositionReturnsTangentialPositionHalfSpeedIfFullSpeedOccupied() {
createOppositeDirectionVariation1Topography();
// Occupy tangential/full speed position
......@@ -284,4 +284,28 @@ public class NavigationEvasionTest {
assertEquals(expectedTangentialHalfSpeedPosition.y, newPosition.y, ALLOWED_DOUBLE_ERROR);
}
@Test
public void getNavigationPositionReturnsSidestepPositionHalfSpeedIfTangentialOccupied() {
createOppositeDirectionVariation1Topography();
// Occupy tangential full and half speed position
VPoint oldPosition = pedestrian1.getPosition();
VPoint walkingDirection = new VPoint(-1 ,0);
VPoint tangentialPositionFullSpeed = oldPosition.add(walkingDirection.norm().rotate(Math.toRadians(-45)).scalarMultiply(pedestrian1.getStepLength()));
VPoint tangentialPositionHalfSpeed = oldPosition.add(walkingDirection.norm().rotate(Math.toRadians(-45)).scalarMultiply(pedestrian1.getStepLength() * 0.5));
int startPedestrianId = 3;
List<PedestrianBHM> pedestrians = createTwoPedestrianBHM(tangentialPositionFullSpeed, tangentialPositionHalfSpeed, startPedestrianId, topography);
pedestrians.stream().forEach(pedestrian -> topography.addElement(pedestrian));
NavigationEvasion navigationUnderTest = new NavigationEvasion(pedestrian1, topography);
VPoint newPosition = navigationUnderTest.getNavigationPosition();
VPoint expectedTangentialHalfSpeedPosition = oldPosition.add(walkingDirection.norm().rotate(Math.toRadians(-90)).scalarMultiply(pedestrian1.getStepLength() * 0.5));
assertEquals(expectedTangentialHalfSpeedPosition.x, newPosition.x, ALLOWED_DOUBLE_ERROR);
assertEquals(expectedTangentialHalfSpeedPosition.y, newPosition.y, ALLOWED_DOUBLE_ERROR);
}
}
\ 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