Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
a58595fa
Commit
a58595fa
authored
Jan 24, 2020
by
Benedikt Kleinmeier
Browse files
Implemented "ThreatMemory" and use it in "PsychologyStatus" and "ThreatCognitionModel"
parent
44679653
Pipeline
#206691
failed with stages
in 75 minutes and 58 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Scenarios/ModelTests/TestPsychology/Stimuli/VariousStimuli/scenarios/08-Threat-SelfCatThreatModel.scenario
→
Scenarios/ModelTests/TestPsychology/Stimuli/VariousStimuli/scenarios/08-Threat
Short
-SelfCatThreatModel.scenario
View file @
a58595fa
{
"name" : "08-Threat-SelfCatThreatModel",
"name" : "08-Threat
Short
-SelfCatThreatModel",
"description" : "",
"release" : "1.8",
"processWriters" : {
...
...
@@ -276,7 +276,7 @@
} ],
"dynamicElements" : [ {
"attributes" : {
"id" :
3
,
"id" :
4
,
"radius" : 0.2,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.34,
...
...
@@ -294,21 +294,24 @@
"nextTargetListIndex" : 0,
"isCurrentTargetAnAgent" : false,
"position" : {
"x" : 2
2
.2,
"y" : 4.
6
"x" : 2
3
.2,
"y" : 4.
7
},
"velocity" : {
"x" : 0.0,
"y" : 0.0
},
"freeFlowSpeed" : 1.
5462627717320168
,
"freeFlowSpeed" : 1.
2525182703548774
,
"followers" : [ ],
"idAsTarget" : -1,
"isChild" : false,
"isLikelyInjured" : false,
"psychologyStatus" : {
"mostImportantStimulus" : null,
"perceivedThreat" : null,
"threatMemory" : {
"allThreats" : [ ],
"latestThreatHandled" : true
},
"selfCategory" : "TARGET_ORIENTED",
"groupMembership" : "OUT_GROUP"
},
...
...
Scenarios/ModelTests/TestPsychology/Stimuli/VariousStimuli/scenarios/09-ThreatLong-SelfCatThreatModel.scenario
0 → 100644
View file @
a58595fa
{
"name" : "09-ThreatLong-SelfCatThreatModel",
"description" : "",
"release" : "1.8",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
"filename" : "density.txt",
"processors" : [ 1 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOverlapOutputFile",
"filename" : "out.txt",
"processors" : [ 3 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.NoDataKeyOutputFile",
"filename" : "out1.txt",
"processors" : [ 4 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.EventtimePedestrianIdOutputFile",
"filename" : "postvis.traj",
"processors" : [ 6, 7, 8, 9 ]
} ],
"processors" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianDensityCountingProcessor",
"id" : 1,
"attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianDensityCountingProcessor",
"attributes" : {
"pedestrianPositionProcessorId" : 2,
"radius" : 1.5
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianPositionProcessor",
"id" : 2,
"attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianPositionProcessor",
"attributes" : {
"interpolate" : true
}
}, {
"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
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.MaxOverlapProcessor",
"id" : 5,
"attributesType" : "org.vadere.state.attributes.processor.AttributesMaxOverlapProcessor",
"attributes" : {
"pedestrianOverlapProcessorId" : 3
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepProcessor",
"id" : 6
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepTargetIDProcessor",
"id" : 7
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepMostImportantStimulusProcessor",
"id" : 8
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepSelfCategoryProcessor",
"id" : 9
} ],
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.psychology.selfcategorization.SelfCatThreatModel",
"attributesModel" : {
"org.vadere.state.attributes.models.AttributesSelfCatThreat" : {
"attributesLocomotion" : {
"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" : [ ]
},
"probabilityInGroupMembership" : 0.0
},
"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" : 150.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.0,
"writeSimulationData" : true,
"visualizationEnabled" : true,
"printFPS" : false,
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" : 1
},
"attributesPsychology" : {
"usePsychologyLayer" : true,
"psychologyLayer" : {
"perception" : "SimplePerceptionModel",
"cognition" : "ThreatCognitionModel"
}
},
"topography" : {
"attributes" : {
"bounds" : {
"x" : 0.0,
"y" : 0.0,
"width" : 40.0,
"height" : 16.0
},
"boundingBoxWidth" : 0.5,
"bounded" : true,
"referenceCoordinateSystem" : null
},
"obstacles" : [ ],
"measurementAreas" : [ ],
"stairs" : [ ],
"targets" : [ {
"id" : 1,
"absorbing" : true,
"shape" : {
"x" : 36.0,
"y" : 10.5,
"width" : 2.5,
"height" : 4.5,
"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" : 36.0,
"y" : 1.0,
"width" : 2.5,
"height" : 4.5,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
}, {
"id" : 0,
"absorbing" : true,
"shape" : {
"radius" : 1.0,
"center" : {
"x" : 20.0,
"y" : 8.0
},
"type" : "CIRCLE"
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
}, {
"id" : 3,
"absorbing" : true,
"shape" : {
"x" : 0.6,
"y" : 1.0,
"width" : 0.5,
"height" : 14.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" : 1,
"shape" : {
"x" : 1.0,
"y" : 10.5,
"width" : 2.5,
"height" : 4.5,
"type" : "RECTANGLE"
},
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 1.0 ],
"spawnNumber" : 10,
"maxSpawnNumberTotal" : -1,
"startTime" : 0.0,
"endTime" : 0.0,
"spawnAtRandomPositions" : false,
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
}, {
"id" : 2,
"shape" : {
"x" : 1.0,
"y" : 1.0,
"width" : 2.5,
"height" : 4.5,
"type" : "RECTANGLE"
},
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 1.0 ],
"spawnNumber" : 10,
"maxSpawnNumberTotal" : -1,
"startTime" : 0.0,
"endTime" : 0.0,
"spawnAtRandomPositions" : false,
"useFreeSpaceOnly" : true,
"targetIds" : [ 2 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
} ],
"dynamicElements" : [ {
"attributes" : {
"id" : 4,
"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
},
"source" : null,
"targetIds" : [ ],
"nextTargetListIndex" : 0,
"isCurrentTargetAnAgent" : false,
"position" : {
"x" : 23.2,
"y" : 4.7
},
"velocity" : {
"x" : 0.0,
"y" : 0.0
},
"freeFlowSpeed" : 1.2525182703548774,
"followers" : [ ],
"idAsTarget" : -1,
"isChild" : false,
"isLikelyInjured" : false,
"psychologyStatus" : {
"mostImportantStimulus" : null,
"threatMemory" : {
"allThreats" : [ ],
"latestThreatHandled" : true
},
"selfCategory" : "TARGET_ORIENTED",
"groupMembership" : "OUT_GROUP"
},
"groupIds" : [ ],
"groupSizes" : [ ],
"trajectory" : {
"footSteps" : [ ]
},
"modelPedestrianMap" : null,
"type" : "PEDESTRIAN"
} ],
"attributesPedestrian" : {
"radius" : 0.195,
"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" : [ {
"timeframe" : {
"startTime" : 15.0,
"endTime" : 17.0,
"repeat" : false,
"waitTimeBetweenRepetition" : 0.0
},
"stimuli" : [ {
"type" : "Threat",
"originAsTargetId" : 0,
"loudness" : 1.0,
"radius" : 10.0
} ]
} ]
}
}
\ No newline at end of file
Scenarios/ModelTests/TestPsychology/Stimuli/VariousStimuli/vadere.project
View file @
a58595fa
TestVariousStimuli
TestVariousStimuli
\ No newline at end of file
VadereSimulator/src/org/vadere/simulator/control/psychology/cognition/ThreatCognitionModel.java
View file @
a58595fa
...
...
@@ -9,6 +9,7 @@ import org.vadere.state.scenario.Pedestrian;
import
org.vadere.state.scenario.Topography
;
import
org.vadere.util.geometry.shapes.VPoint
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -44,17 +45,33 @@ public class ThreatCognitionModel implements ICognitionModel {
}
else
{
throw
new
IllegalArgumentException
(
"Can only process \"Threat\" and \"ElapsedTime\" stimuli!"
);
}
}
}
private
void
handleThreat
(
Pedestrian
pedestrian
,
Stimulus
stimulus
)
{
// TODO: Make code more readable.
if
(
pedestrian
.
getThreatMemory
().
isEmpty
())
{
pedestrian
.
getThreatMemory
().
setLatestThreatHandled
(
false
);
}
else
{
// Check if pedestrian re-entered the same threat area.
Threat
oldThreat
=
pedestrian
.
getThreatMemory
().
getLatestThreat
();
Threat
newThreat
=
(
Threat
)
stimulus
;
boolean
isNewThreat
=
oldThreat
.
getOriginAsTargetId
()
!=
newThreat
.
getOriginAsTargetId
();
if
(
isNewThreat
)
{
pedestrian
.
getThreatMemory
().
setLatestThreatHandled
(
false
);
}
}
// Current stimulus is a threat => store it and make clear that pedestrian is inside threat area.
pedestrian
.
s
et
Perceived
Threat
(
stimulus
);
pedestrian
.
g
et
ThreatMemory
().
add
((
Threat
)
stimulus
);
pedestrian
.
setSelfCategory
(
SelfCategory
.
INSIDE_THREAT_AREA
);
}
private
void
handleElapsedTime
(
Pedestrian
pedestrian
)
{
if
(
pedestrian
.
get
Perceived
Threat
()
!=
null
)
{
if
(
pedestrian
.
get
ThreatMemory
().
getLatest
Threat
()
!=
null
)
{
testIfInsideOrOutsideThreatArea
(
pedestrian
);
}
else
{
// These agents did not perceive a threat but are aware of other threatened agents.
...
...
@@ -69,7 +86,7 @@ public class ThreatCognitionModel implements ICognitionModel {
}
private
void
testIfInsideOrOutsideThreatArea
(
Pedestrian
pedestrian
)
{
Threat
threat
=
(
Threat
)
pedestrian
.
get
Perceived
Threat
();
Threat
threat
=
pedestrian
.
get
ThreatMemory
().
getLatest
Threat
();
VPoint
threatOrigin
=
topography
.
getTarget
(
threat
.
getOriginAsTargetId
()).
getShape
().
getCentroid
();
double
distanceToThreat
=
threatOrigin
.
distance
(
pedestrian
.
getPosition
());
...
...
@@ -93,10 +110,11 @@ public class ThreatCognitionModel implements ICognitionModel {
if
(
threatenedPedestrians
.
isEmpty
()
==
false
)
{
Pedestrian
threatenedPedestrian
=
threatenedPedestrians
.
get
(
0
);
Threat
latestThreat
=
threatenedPedestrian
.
getThreatMemory
().
getLatestThreat
();
assert
threatenedPedestrian
.
getPerceived
Threat
()
!=
null
;
assert
latest
Threat
!=
null
;
handleThreat
(
pedestrian
,
threatenedPedestrian
.
getPerceived
Threat
()
);
handleThreat
(
pedestrian
,
latest
Threat
);
}
else
{
pedestrian
.
setSelfCategory
(
SelfCategory
.
TARGET_ORIENTED
);
}
...
...
VadereSimulator/src/org/vadere/simulator/models/osm/OSMBehaviorController.java
View file @
a58595fa
...
...
@@ -121,13 +121,8 @@ public class OSMBehaviorController {
}
public
void
maximizeDistanceToThreatAndIncreaseSpeed
(
PedestrianOSM
pedestrian
,
Topography
topography
)
{
Stimulus
perceivedThreat
=
pedestrian
.
getPerceivedThreat
();
// FIXME: This test (if we have already seen a bang) is wrong!
// Assume, the pedestrian leaves the bang radius and re-enters it.
// Therefore, introduce a flag or another more robust test.
if
(
perceivedThreat
instanceof
Threat
&&
pedestrian
.
getCombinedPotentialStrategy
()
instanceof
TargetAttractionStrategy
)
{
Threat
threat
=
(
Threat
)
perceivedThreat
;
if
(
pedestrian
.
getThreatMemory
().
isLatestThreatHandled
()
==
false
)
{
Threat
threat
=
pedestrian
.
getThreatMemory
().
getLatestThreat
();
Target
threatOrigin
=
topography
.
getTarget
(
threat
.
getOriginAsTargetId
());
LinkedList
<
Integer
>
nextTarget
=
new
LinkedList
<>();
...
...
@@ -140,10 +135,7 @@ public class OSMBehaviorController {
double
escapeSpeed
=
pedestrian
.
getFreeFlowSpeed
()
*
2.0
;
pedestrian
.
setFreeFlowSpeed
(
escapeSpeed
);
}
else
{
logger
.
debug
(
String
.
format
(
"Expected: %s, Received: %s"
,
Threat
.
class
.
getSimpleName
(),
perceivedThreat
.
getClass
().
getSimpleName
()));
pedestrian
.
getThreatMemory
().
setLatestThreatHandled
(
true
);
}
}
...
...
@@ -159,7 +151,7 @@ public class OSMBehaviorController {
if
(
pedestrian
.
getCombinedPotentialStrategy
()
instanceof
TargetRepulsionStrategy
)
{
ScenarioElement
searchPosition
=
(
pedestrian
.
getSource
()
==
null
)
?
pedestrian
:
pedestrian
.
getSource
();
Target
closestTarget
=
findClosestTarget
(
topography
,
searchPosition
,
(
Threat
)
pedestrian
.
get
Perceived
Threat
());
Target
closestTarget
=
findClosestTarget
(
topography
,
searchPosition
,
(
Threat
)
pedestrian
.
get
ThreatMemory
().
getLatest
Threat
());
assert
closestTarget
!=
null
;
...
...
VadereState/src/org/vadere/state/psychology/PsychologyStatus.java
View file @
a58595fa
...
...
@@ -2,38 +2,39 @@ package org.vadere.state.psychology;
import
org.vadere.state.psychology.cognition.GroupMembership
;
import
org.vadere.state.psychology.cognition.SelfCategory
;
import
org.vadere.state.psychology.perception.ThreatMemory
;
import
org.vadere.state.psychology.perception.types.Stimulus
;
public
class
PsychologyStatus
{
// Member Variables
private
Stimulus
mostImportantStimulus
;
private
Stimulus
perceivedThreat
;
// TODO: Maybe, implement some kind of memory instead of just a perceived threat.
private
ThreatMemory
threatMemory
;
private
SelfCategory
selfCategory
;
private
GroupMembership
groupMembership
;
// Constructors
public
PsychologyStatus
()
{
this
(
null
,
n
ull
,
SelfCategory
.
TARGET_ORIENTED
,
GroupMembership
.
OUT_GROUP
);
this
(
null
,
n
ew
ThreatMemory
()
,
SelfCategory
.
TARGET_ORIENTED
,
GroupMembership
.
OUT_GROUP
);
}
public
PsychologyStatus
(
Stimulus
mostImportantStimulus
,
Stimulus
perceivedThreat
,
SelfCategory
selfCategory
,
GroupMembership
groupMembership
)
{
public
PsychologyStatus
(
Stimulus
mostImportantStimulus
,
ThreatMemory
threatMemory
,
SelfCategory
selfCategory
,
GroupMembership
groupMembership
)
{
this
.
mostImportantStimulus
=
mostImportantStimulus
;
this
.
perceivedThreat
=
perceivedThreat
;
this
.
threatMemory
=
threatMemory
;
this
.
selfCategory
=
selfCategory
;
this
.
groupMembership
=
groupMembership
;
}
public
PsychologyStatus
(
PsychologyStatus
other
)
{
this
.
mostImportantStimulus
=
other
.
getMostImportantStimulus
()
!=
null
?
other
.
getMostImportantStimulus
().
clone
()
:
null
;
this
.
perceivedThreat
=
other
.
getPerceivedThreat
()
!=
null
?
other
.
get
Perceived
Threat
().
clone
()
:
null
;
this
.
threatMemory
=
other
.
getThreatMemory
()
!=
null
?
other
.
getThreat
Memory
().
clone
()
:
null
;
this
.
selfCategory
=
other
.
getSelfCategory
();
this
.
groupMembership
=
other
.
getGroupMembership
();
}
// Getter
public
Stimulus
getMostImportantStimulus
()
{
return
mostImportantStimulus
;
}
public
Stimulus
getPerceivedThreat
()
{
return
perceivedThreat
;
}
public
ThreatMemory
getThreatMemory
()
{
return
threatMemory
;
}
public
SelfCategory
getSelfCategory
()
{
return
selfCategory
;
}
public
GroupMembership
getGroupMembership
()
{
return
groupMembership
;
}
...
...
@@ -42,9 +43,7 @@ public class PsychologyStatus {
this
.
mostImportantStimulus
=
mostImportantStimulus
;
}
public
void
setPerceivedThreat
(
Stimulus
perceivedThreat
)
{
this
.
perceivedThreat
=
perceivedThreat
;
}
public
void
setThreatMemory
(
ThreatMemory
threatMemory
)
{
this
.
threatMemory
=
threatMemory
;
}
public
void
setSelfCategory
(
SelfCategory
selfCategory
)
{
this
.
selfCategory
=
selfCategory
;
...
...
VadereState/src/org/vadere/state/psychology/perception/ThreatMemory.java
0 → 100644
View file @
a58595fa
package
org.vadere.state.psychology.perception
;
import
org.vadere.state.psychology.perception.types.Threat
;
import
org.vadere.state.scenario.Pedestrian
;
import
java.util.ArrayList
;
import
java.util.List
;
/**