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

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

Renamed class "LastFootSteps" to "FootstepHistory" and move its usage from...

Renamed class "LastFootSteps" to "FootstepHistory" and move its usage from "VTrajectory" to "Pedestrian"

Implemented also class "JsonTransformationV1_3ToV1_4" to rename field
"footStepsToStore" to "footstepHistorySize" in existing scenario files.
parent 4b51581a
......@@ -2,13 +2,11 @@ package org.vadere.simulator.control.cognition;
import org.vadere.state.events.types.BangEvent;
import org.vadere.state.behavior.SalientBehavior;
import org.vadere.state.events.types.Event;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Topography;
import org.vadere.state.simulation.LastFootSteps;
import org.vadere.state.simulation.FootstepHistory;
import java.util.Collection;
import java.util.List;
/**
* The SalientBehaviorCognition class should provide logic to change the salient behavior of a pedestrian
......@@ -36,10 +34,10 @@ public class SalientBehaviorCognition {
int requiredFootSteps = 2;
double requiredSpeedInMetersPerSecondToBeCooperative = 0.05;
LastFootSteps lastFootSteps = pedestrian.getFootSteps().getLastFootSteps();
FootstepHistory footstepHistory = pedestrian.getFootstepHistory();
if (lastFootSteps.size() >= requiredFootSteps) { // Adapt behavior only if we have seen some footsteps in the past
if (lastFootSteps.getAverageSpeedInMeterPerSecond() <= requiredSpeedInMetersPerSecondToBeCooperative) {
if (footstepHistory.size() >= requiredFootSteps) { // Adapt behavior only if we have seen some footsteps in the past
if (footstepHistory.getAverageSpeedInMeterPerSecond() <= requiredSpeedInMetersPerSecondToBeCooperative) {
pedestrian.setSalientBehavior(SalientBehavior.COOPERATIVE);
} else {
// TODO Maybe, check if area directed to target is free for a step (only then change to "TARGET_ORIENTED").
......
......@@ -28,6 +28,7 @@ public enum Version {
V1_1(1,1),
V1_2(1,2),
V1_3(1,3),
V1_4(1,4),
;
......
......@@ -189,7 +189,9 @@ public class PedestrianBHM extends Pedestrian {
throw new UnsupportedEventException(mostImportantEvent, this.getClass());
}
getFootSteps().add(new FootStep(position, getPosition(), timeOfNextStep, timeOfNextStep + durationNextStep));
FootStep currentFootstep = new FootStep(position, getPosition(), timeOfNextStep, timeOfNextStep + durationNextStep);
getFootSteps().add(currentFootstep);
getFootstepHistory().add(currentFootstep);
}
/**
......
......@@ -111,7 +111,10 @@ public class BiomechanicsModel implements MainModel {
for(int i = 0; i < pedestriansBMM.size(); i++) {
PedestrianBMM agent = pedestriansBMM.get(i);
agent.clearFootSteps();
agent.getFootSteps().add(new FootStep(positions.get(i), agent.getPosition(), lastSimTimeInSec, simTimeInSec));
FootStep currentFootstep = new FootStep(positions.get(i), agent.getPosition(), lastSimTimeInSec, simTimeInSec);
agent.getFootSteps().add(currentFootstep);
agent.getFootstepHistory().add(currentFootstep);
}
this.lastSimTimeInSec = simTimeInSec;
......
......@@ -128,7 +128,10 @@ public abstract class ODEModel<T extends DynamicElement, TAttributes extends Att
if (element.getType() == ScenarioElementType.PEDESTRIAN) {
Pedestrian pedestrian = (Pedestrian)element;
pedestrian.clearFootSteps();
pedestrian.getFootSteps().add(new FootStep(positions.get(i), pedestrian.getPosition(), lastSimTimeInSec, simTimeInSec));
FootStep currentFootstep = new FootStep(positions.get(i), pedestrian.getPosition(), lastSimTimeInSec, simTimeInSec);
pedestrian.getFootSteps().add(currentFootstep);
pedestrian.getFootstepHistory().add(currentFootstep);
}
}
}
......
......@@ -79,7 +79,10 @@ public class OSMBehaviorController {
// strides and foot steps have no influence on the simulation itself, i.e. they are saved to analyse trajectories
pedestrian.getStrides().add(Pair.of(currentPosition.distance(nextPosition), stepStartTime));
pedestrian.getFootSteps().add(new FootStep(currentPosition, nextPosition, stepStartTime, stepEndTime));
FootStep currentFootstep = new FootStep(currentPosition, nextPosition, stepStartTime, stepEndTime);
pedestrian.getFootSteps().add(currentFootstep);
pedestrian.getFootstepHistory().add(currentFootstep);
}
public void wait(PedestrianOSM pedestrian) {
......
......@@ -134,7 +134,10 @@ public interface UpdateSchemeOSM extends DynamicElementRemoveListener<Pedestrian
* strides and foot steps have no influence on the simulation itself, i.e. they are saved to analyse trajectories
*/
pedestrian.getStrides().add(Pair.of(currentPosition.distance(nextPosition), timeOfNextStep));
pedestrian.getFootSteps().add(new FootStep(currentPosition, nextPosition, timeOfNextStep, entTimeOfStep));
FootStep currentFootstep = new FootStep(currentPosition, nextPosition, timeOfNextStep, entTimeOfStep);
pedestrian.getFootSteps().add(currentFootstep);
pedestrian.getFootstepHistory().add(currentFootstep);
}
}
......@@ -40,11 +40,14 @@ public class PedestrianReynolds extends Pedestrian {
VPoint oldPosition = getPosition();
VPoint newPosition = oldPosition.add(mov);
setPosition(newPosition);
// TODO: the first footstep starts at the wrong time!
clearFootSteps();
// TODO: the first footstep starts at the wrong time!
getFootSteps().add(new FootStep(oldPosition, newPosition, lastSimTimeInSec, simTime));
FootStep currentFootstep = new FootStep(oldPosition, newPosition, lastSimTimeInSec, simTime);
getFootSteps().add(currentFootstep);
getFootstepHistory().add(currentFootstep);
lastSimTimeInSec = simTime;
}
......
package org.vadere.simulator.projects.migration.jsontranformation.json;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.vadere.annotation.factories.migrationassistant.MigrationTransformation;
import org.vadere.simulator.entrypoints.Version;
import org.vadere.simulator.projects.migration.MigrationException;
import org.vadere.simulator.projects.migration.jsontranformation.SimpleJsonTransformation;
@MigrationTransformation(targetVersionLabel = "1.4")
public class JsonTransformationV1_3ToV1_4 extends SimpleJsonTransformation {
public JsonTransformationV1_3ToV1_4(){
super(Version.V1_4);
}
@Override
protected void initDefaultHooks() {
addPostHookFirst(this::renameFootStepsToStore);
addPostHookLast(this::sort);
}
public JsonNode renameFootStepsToStore(JsonNode node) throws MigrationException {
String oldName = "footStepsToStore";
String newName = "footstepHistorySize";
renameInTopography(node, oldName, newName);
renameInMainModel(node, oldName, newName);
return node;
}
private void renameInTopography(JsonNode node, String oldName, String newName) throws MigrationException {
JsonNode attributesPedestrianNode = pathMustExist(node, "scenario/topography/attributesPedestrian");
renameField((ObjectNode)attributesPedestrianNode, oldName, newName);
}
private void renameInMainModel(JsonNode node, String oldName, String newName) throws MigrationException {
JsonNode attributesModelNode = path(node, "scenario/attributesModel/org.vadere.state.attributes.scenario.AttributesCar");
if (!attributesModelNode.isMissingNode()) {
renameField((ObjectNode)attributesModelNode, oldName, newName);
}
}
}
......@@ -408,7 +408,7 @@
"minimumSpeed" : 0.3,
"maximumSpeed" : 3.0,
"acceleration" : 2.0,
"footStepsToStore" : 4,
"footstepHistorySize" : 4,
"searchRadius" : 1.0,
"angleCalculationType" : "USE_CENTER",
"targetOrientationAngleThreshold" : 45.0
......
{
"name" : "s001",
"description" : "",
"release" : "1.3",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
"filename" : "postvis.trajectories",
"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.PedestrianPositionProcessor",
"id" : 1
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianTargetIdProcessor",
"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.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" : "CSV_CACHE",
"cacheDir" : "s002",
"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" : 50.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.1,
"writeSimulationData" : true,
"visualizationEnabled" : true,
"printFPS" : false,
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 183115877309837713,
"simulationSeed" : 0,
"useSalientBehavior" : false
},
"topography" : {
"attributes" : {
"bounds" : {
"x" : 0.0,
"y" : 0.0,
"width" : 10.0,
"height" : 10.0
},
"boundingBoxWidth" : 0.5,
"bounded" : true
},
"obstacles" : [ {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 4.038095238095238,
"y" : 3.0
}, {
"x" : 4.038095238095238,
"y" : 3.6
}, {
"x" : 0.5,
"y" : 3.6
}, {
"x" : 0.5,
"y" : 3.0
} ]
},
"id" : 4
}, {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 9.5,
"y" : 3.0
}, {
"x" : 9.5,
"y" : 3.6
}, {
"x" : 5.961904761904762,
"y" : 3.6
}, {
"x" : 5.961904761904762,
"y" : 3.0
} ]
},
"id" : 5
}, {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 8.4196748078264,
"y" : 6.990370356126214
}, {
"x" : 5.178391040736634,
"y" : 6.990370356126214
}, {
"x" : 5.178391040736634,
"y" : 7.010726909982895
}, {
"x" : 4.614300219392282,
"y" : 7.010726909982895
}, {
"x" : 4.614300219392282,
"y" : 6.990370356126215
}, {
"x" : 1.4356932102296667,
"y" : 6.990370356126215
}, {
"x" : 1.4356932102296667,
"y" : 6.332264397891138
}, {
"x" : 4.614300219392282,
"y" : 6.332264397891138
}, {
"x" : 4.614300219392282,
"y" : 0.5033259106661707
}, {
"x" : 5.178391040736634,
"y" : 0.5033259106661707
}, {
"x" : 5.178391040736634,
"y" : 6.4262795347818615
}, {
"x" : 8.4196748078264,
"y" : 6.426279534781862
} ]
},
"id" : 6
} ],
"measurementAreas" : [ ],
"stairs" : [ ],
"targets" : [ {
"id" : 2,
"absorbing" : true,
"shape" : {
"x" : 7.542857142857143,
"y" : 0.7,
"width" : 1.757142857142858,
"height" : 1.0142857142857136,
"type" : "RECTANGLE"
},
"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.742857142857142,
"y" : 0.7,
"width" : 1.757142857142858,
"height" : 1.0142857142857136,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : 1,
"shape" : {
"x" : 4.2,
"y" : 8.457142857142857,
"width" : 2.0095238095238095,
"height" : 0.9428571428571431,
"type" : "RECTANGLE"
},
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 20.0 ],
"spawnNumber" : 4,
"maxSpawnNumberTotal" : 4,
"startTime" : 0.0,
"endTime" : 50.0,
"spawnAtRandomPositions" : true,
"useFreeSpaceOnly" : true,
"targetIds" : [ 2 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.2,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.34,
"speedDistributionStandardDeviation" : 0.26,
"minimumSpeed" : 0.5,
"maximumSpeed" : 2.2,
"acceleration" : 2.0,
"footStepsToStore" : 4,
"searchRadius" : 1.0,
"angleCalculationType" : "USE_CENTER",
"targetOrientationAngleThreshold" : 45.0
},
"teleporter" : null,
"attributesCar" : null
},
"eventInfos" : [ ]
}
}
{
"name" : "s002",
"description" : "",
"release" : "1.3",
"processWriters" : {
"files" : [ ],
"processors" : [ ],
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.ovm.OptimalVelocityModel",
"attributesModel" : {
"org.vadere.state.attributes.models.AttributesOVM" : {
"attributesODEIntegrator" : {
"solverType" : "DORMAND_PRINCE_45",
"stepSizeMin" : 1.0E-4,
"stepSizeMax" : 1.0,
"toleranceAbsolute" : 1.0E-5,
"toleranceRelative" : 1.0E-4
},
"sensitivity" : 1.0,
"sightDistance" : 10.0,
"sightDistanceFactor" : 1.0,
"firstDistanceRandom" : {
"x" : 5.0,
"y" : 15.0
},
"ignoreOtherCars" : true
},
"org.vadere.state.attributes.scenario.AttributesCar" : {
"id" : -1,
"radius" : 0.195,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.34,
"speedDistributionStandardDeviation" : 0.0,
"minimumSpeed" : 0.3,
"maximumSpeed" : 3.0,
"acceleration" : 2.0,
"footStepsToStore" : 4,
"searchRadius" : 1.0,
"angleCalculationType" : "USE_CENTER",
"targetOrientationAngleThreshold" : 45.0,
"length" : 4.5,
"width" : 1.7,
"direction" : {
"x" : 1.0,
"y" : 0.0
}
}
},
"attributesSimulation" : {
"finishTime" : 100.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.1,
"writeSimulationData" : true,
"visualizationEnabled" : true,
"printFPS" : false,
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" : 1,
"useSalientBehavior" : false
},
"topography" : {
"attributes" : {
"bounds" : {
"x" : 0.0,
"y" : 0.0,
"width" : 30.0,
"height" : 6.0
},
"boundingBoxWidth" : 0.5,
"bounded" : true,
"referenceCoordinateSystem" : null
},
"obstacles" : [ ],
"measurementAreas" : [ ],
"stairs" : [ ],
"targets" : [ {
"id" : 1,
"absorbing" : true,
"shape" : {
"x" : 28.0,
"y" : 1.0,
"width" : 1.0,
"height" : 4.0,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : -1,
"shape" : {
"x" : 1.0,
"y" : 1.0,
"width" : 1.0,
"height" : 4.0,
"type" : "RECTANGLE"
},
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 2.0 ],
"spawnNumber" : 1,
"maxSpawnNumberTotal" : -1,
"startTime" : 0.0,
"endTime" : 60.0,
"spawnAtRandomPositions" : false,
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "CAR"
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.34,
"speedDistributionStandardDeviation" : 0.26,
"minimumSpeed" : 0.5,
"maximumSpeed" : 2.2,
"acceleration" : 2.0,
"footStepsToStore" : 4,
"searchRadius" : 1.0,
"angleCalculationType" : "USE_CENTER",
"targetOrientationAngleThreshold" : 45.0
},
"teleporter" : null,
"attributesCar" : null
},
"eventInfos" : [ ]
}
}