Commit 6799a555 authored by Daniel Lehmberg's avatar Daniel Lehmberg

revert new field in Pedestrian and use storage of VTrajectory instead

parent c6834357
Pipeline #147220 failed with stages
in 63 minutes and 50 seconds
......@@ -176,7 +176,6 @@
"trajectory" : {
"footSteps" : [ ]
},
"currentFootStep" : null,
"groupSizes" : [ ],
"modelPedestrianMap" : null,
"type" : "PEDESTRIAN"
......@@ -211,4 +210,4 @@
} ]
} ]
}
}
\ No newline at end of file
}
......@@ -176,7 +176,6 @@
"trajectory" : {
"footSteps" : [ ]
},
"currentFootStep" : null,
"groupSizes" : [ ],
"modelPedestrianMap" : null,
"type" : "PEDESTRIAN"
......@@ -211,4 +210,4 @@
} ]
} ]
}
}
\ No newline at end of file
}
......@@ -176,7 +176,6 @@
"trajectory" : {
"footSteps" : [ ]
},
"currentFootStep" : null,
"groupSizes" : [ ],
"modelPedestrianMap" : null,
"type" : "PEDESTRIAN"
......@@ -216,7 +215,6 @@
"trajectory" : {
"footSteps" : [ ]
},
"currentFootStep" : null,
"groupSizes" : [ ],
"modelPedestrianMap" : null,
"type" : "PEDESTRIAN"
......@@ -256,7 +254,6 @@
"trajectory" : {
"footSteps" : [ ]
},
"currentFootStep" : null,
"groupSizes" : [ ],
"modelPedestrianMap" : null,
"type" : "PEDESTRIAN"
......@@ -296,7 +293,6 @@
"trajectory" : {
"footSteps" : [ ]
},
"currentFootStep" : null,
"groupSizes" : [ ],
"modelPedestrianMap" : null,
"type" : "PEDESTRIAN"
......@@ -331,4 +327,4 @@
} ]
} ]
}
}
\ No newline at end of file
}
......@@ -185,7 +185,6 @@
"trajectory" : {
"footSteps" : [ ]
},
"currentFootStep" : null,
"groupSizes" : [ ],
"modelPedestrianMap" : null,
"type" : "PEDESTRIAN"
......@@ -220,4 +219,4 @@
} ]
} ]
}
}
\ No newline at end of file
}
......@@ -64,7 +64,7 @@
"attributesModel" : {
"org.vadere.state.attributes.models.AttributesFloorField" : {
"createMethod" : "HIGH_ACCURACY_FAST_MARCHING",
"potentialFieldResolution" : 0.2,
"potentialFieldResolution" : 0.1,
"obstacleGridPenalty" : 0.1,
"targetAttractionStrength" : 1.0,
"cacheType" : "NO_CACHE",
......@@ -116,7 +116,7 @@
}
},
"attributesSimulation" : {
"finishTime" : 400.0,
"finishTime" : 200.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.0,
"writeSimulationData" : true,
......@@ -133,7 +133,7 @@
"bounds" : {
"x" : 0.0,
"y" : 0.0,
"width" : 31.0,
"width" : 38.0,
"height" : 12.0
},
"boundingBoxWidth" : 0.5,
......
......@@ -248,7 +248,6 @@
"trajectory" : {
"footSteps" : [ ]
},
"currentFootStep" : null,
"groupSizes" : [ ],
"modelPedestrianMap" : { },
"type" : "PEDESTRIAN"
......@@ -271,4 +270,4 @@
},
"eventInfos" : [ ]
}
}
\ No newline at end of file
}
......@@ -372,7 +372,6 @@
"trajectory" : {
"footSteps" : [ ]
},
"currentFootStep" : null,
"groupSizes" : [ ],
"modelPedestrianMap" : { },
"type" : "PEDESTRIAN"
......@@ -412,7 +411,6 @@
"trajectory" : {
"footSteps" : [ ]
},
"currentFootStep" : null,
"groupSizes" : [ ],
"modelPedestrianMap" : { },
"type" : "PEDESTRIAN"
......@@ -435,4 +433,4 @@
},
"eventInfos" : [ ]
}
}
\ No newline at end of file
}
......@@ -316,7 +316,6 @@
"trajectory" : {
"footSteps" : [ ]
},
"currentFootStep" : null,
"groupSizes" : [ ],
"modelPedestrianMap" : { },
"type" : "PEDESTRIAN"
......@@ -356,7 +355,6 @@
"trajectory" : {
"footSteps" : [ ]
},
"currentFootStep" : null,
"groupSizes" : [ ],
"modelPedestrianMap" : { },
"type" : "PEDESTRIAN"
......@@ -379,4 +377,4 @@
},
"eventInfos" : [ ]
}
}
\ No newline at end of file
}
......@@ -604,7 +604,6 @@
"trajectory" : {
"footSteps" : [ ]
},
"currentFootStep" : null,
"groupSizes" : [ ],
"modelPedestrianMap" : null,
"type" : "PEDESTRIAN"
......@@ -644,7 +643,6 @@
"trajectory" : {
"footSteps" : [ ]
},
"currentFootStep" : null,
"groupSizes" : [ ],
"modelPedestrianMap" : null,
"type" : "PEDESTRIAN"
......@@ -667,4 +665,4 @@
},
"eventInfos" : [ ]
}
}
\ No newline at end of file
}
......@@ -258,7 +258,6 @@
"trajectory" : {
"footSteps" : [ ]
},
"currentFootStep" : null,
"groupSizes" : [ ],
"modelPedestrianMap" : { },
"type" : "PEDESTRIAN"
......@@ -298,7 +297,6 @@
"trajectory" : {
"footSteps" : [ ]
},
"currentFootStep" : null,
"groupSizes" : [ ],
"modelPedestrianMap" : { },
"type" : "PEDESTRIAN"
......
......@@ -56,7 +56,7 @@ public class PedestrianListBuilder {
Pedestrian p = new Pedestrian(new AttributesAgent(id), new Random());
for(FootStep fs : trajectory){
p.addFootStepToTrajectory(fs);
p.getTrajectory().add(fs);
}
out.add(p);
......
......@@ -34,11 +34,6 @@ public class Pedestrian extends Agent {
*/
private VTrajectory trajectory;
/**
* currentFootStep is the most recent foot step that is used for interpolation.
*/
private FootStep currentFootStep;
private LinkedList<Integer> groupSizes;
private Map<Class<? extends ModelPedestrian>, ModelPedestrian> modelPedestrianMap;
private ScenarioElementType type = ScenarioElementType.PEDESTRIAN; // TODO used at all? For JSON de-/serialization? Car does NOT have this field. remove if unused!
......@@ -65,7 +60,6 @@ public class Pedestrian extends Agent {
groupSizes = new LinkedList<>();
modelPedestrianMap = new HashMap<>();
trajectory = new VTrajectory(attributesAgent.getFootStepsToStore());
currentFootStep = null;
}
private Pedestrian(Pedestrian other) {
......@@ -115,19 +109,27 @@ public class Pedestrian extends Agent {
return trajectory;
}
public VPoint getInterpolatedFootStepPosition(double time){
if(currentFootStep == null){
return getPosition();
public VPoint getInterpolatedFootStepPosition(double time){
if(this.trajectory.getLastFootStepCapacity() <= 0){
throw new RuntimeException("Cannot interpolate foot steps if there is no foot steps storage capacity (see " +
"scenario attribute 'lastFootStepsToStore'");
}
FootStep currentFootStep = this.trajectory.getLastFootSteps().getYoungestFootStep();
if(currentFootStep == null){
return getPosition();
}else{
if(time > currentFootStep.getEndTime()){
// This happens for example if a pedestrian is waiting (see Events)
// TODO: check with Bene K. if this is okay, or a better way?
return currentFootStep.getEnd();
}else{
if(time > currentFootStep.getEndTime()){
// This happens for example if a pedestrian is waiting (see Events)
// TODO: check with Bene K. if this is okay, or a better way?
return currentFootStep.getEnd();
}else{
return FootStep.interpolateFootStep(currentFootStep, time);
}
return FootStep.interpolateFootStep(currentFootStep, time);
}
}
}
// Setter
public void setIdAsTarget(int id) { this.idAsTarget = id; }
......@@ -160,7 +162,6 @@ public class Pedestrian extends Agent {
}
public void addFootStepToTrajectory(FootStep footStep){
currentFootStep = footStep;
this.trajectory = this.trajectory.add(footStep);
}
......@@ -169,7 +170,6 @@ public class Pedestrian extends Agent {
// This statement is for security and should mostly have no effect (only if someone did not use method
// "addFootStepToTrajectory" to add another foot step to the trajectory)
if(!trajectory.isEmpty()){
currentFootStep = trajectory.getFootSteps().getLast();
trajectory.clear();
}
}
......
......@@ -4,12 +4,9 @@ import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.NotNull;
import org.vadere.util.geometry.shapes.VRectangle;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class VTrajectory implements Iterable<FootStep> {
......@@ -17,6 +14,7 @@ public class VTrajectory implements Iterable<FootStep> {
// Variables
private LinkedList<FootStep> footSteps;
private transient LastFootSteps lastFootSteps;
private int lastFootStepCapacity;
// Constructors
public VTrajectory(){
......@@ -24,6 +22,7 @@ public class VTrajectory implements Iterable<FootStep> {
}
public VTrajectory(int lastFootStepCapacity){
this.lastFootStepCapacity = lastFootStepCapacity;
footSteps = new LinkedList<>();
lastFootSteps = new LastFootSteps(lastFootStepCapacity);
}
......@@ -33,6 +32,10 @@ public class VTrajectory implements Iterable<FootStep> {
return new LinkedList<>(footSteps);
}
public int getLastFootStepCapacity() {
return lastFootStepCapacity;
}
public LastFootSteps getLastFootSteps() {
return lastFootSteps;
}
......
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