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

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

Add object of class "LastFootSteps" to class "VTrajectory".

parent d8df7e8d
...@@ -31,6 +31,9 @@ public class AttributesAgent extends AttributesDynamicElement { ...@@ -31,6 +31,9 @@ public class AttributesAgent extends AttributesDynamicElement {
// only used for the GNM and SFM // only used for the GNM and SFM
private double acceleration = 2.0; private double acceleration = 2.0;
// store n last foot steps for speed calculation
private int footStepsToStore = 10;
public AttributesAgent() { public AttributesAgent() {
this(-1); this(-1);
} }
...@@ -51,6 +54,7 @@ public class AttributesAgent extends AttributesDynamicElement { ...@@ -51,6 +54,7 @@ public class AttributesAgent extends AttributesDynamicElement {
this.minimumSpeed = other.minimumSpeed; this.minimumSpeed = other.minimumSpeed;
this.maximumSpeed = other.maximumSpeed; this.maximumSpeed = other.maximumSpeed;
this.acceleration = other.acceleration; this.acceleration = other.acceleration;
this.footStepsToStore = other.footStepsToStore;
} }
// Getters... // Getters...
...@@ -83,6 +87,10 @@ public class AttributesAgent extends AttributesDynamicElement { ...@@ -83,6 +87,10 @@ public class AttributesAgent extends AttributesDynamicElement {
return acceleration; return acceleration;
} }
public int getFootStepsToStore() { return footStepsToStore; }
// Setters...
public void setRadius(double radius) { public void setRadius(double radius) {
checkSealed(); checkSealed();
this.radius = radius; this.radius = radius;
...@@ -117,4 +125,9 @@ public class AttributesAgent extends AttributesDynamicElement { ...@@ -117,4 +125,9 @@ public class AttributesAgent extends AttributesDynamicElement {
checkSealed(); checkSealed();
this.acceleration = acceleration; this.acceleration = acceleration;
} }
public void setFootStepsToStore(int footStepsToStore) {
checkSealed();
this.footStepsToStore = footStepsToStore;
}
} }
...@@ -59,7 +59,7 @@ public class Pedestrian extends Agent { ...@@ -59,7 +59,7 @@ public class Pedestrian extends Agent {
groupIds = new LinkedList<>(); groupIds = new LinkedList<>();
groupSizes = new LinkedList<>(); groupSizes = new LinkedList<>();
modelPedestrianMap = new HashMap<>(); modelPedestrianMap = new HashMap<>();
trajectory = new VTrajectory(); trajectory = new VTrajectory(attributesAgent.getFootStepsToStore());
} }
private Pedestrian(Pedestrian other) { private Pedestrian(Pedestrian other) {
......
...@@ -4,6 +4,8 @@ import java.util.ArrayList; ...@@ -4,6 +4,8 @@ import java.util.ArrayList;
/** /**
* Store the last foot steps of an agent to calculate the agent's average speed during simulation. * Store the last foot steps of an agent to calculate the agent's average speed during simulation.
*
* TODO: Maybe, rename to "FootStepHistory".
*/ */
public class LastFootSteps { public class LastFootSteps {
......
...@@ -16,9 +16,15 @@ import java.util.stream.Stream; ...@@ -16,9 +16,15 @@ import java.util.stream.Stream;
public class VTrajectory implements Iterable<FootStep> { public class VTrajectory implements Iterable<FootStep> {
private LinkedList<FootStep> footSteps; private LinkedList<FootStep> footSteps;
private transient LastFootSteps lastFootSteps;
public VTrajectory(){ public VTrajectory(){
this(10);
}
public VTrajectory(int lastFootStepCapacity){
footSteps = new LinkedList<>(); footSteps = new LinkedList<>();
lastFootSteps = new LastFootSteps(lastFootStepCapacity);
} }
public Optional<Double> speed(@NotNull final VRectangle rectangle) { public Optional<Double> speed(@NotNull final VRectangle rectangle) {
...@@ -83,7 +89,9 @@ public class VTrajectory implements Iterable<FootStep> { ...@@ -83,7 +89,9 @@ public class VTrajectory implements Iterable<FootStep> {
public void add(@NotNull final FootStep footStep) { public void add(@NotNull final FootStep footStep) {
assert footSteps.isEmpty() || footSteps.peekLast().getEndTime() <= footStep.getStartTime(); assert footSteps.isEmpty() || footSteps.peekLast().getEndTime() <= footStep.getStartTime();
footSteps.add(footStep); footSteps.add(footStep);
lastFootSteps.add(footStep);
} }
public VTrajectory cut(@NotNull final VRectangle rectangle) { public VTrajectory cut(@NotNull final VRectangle rectangle) {
......
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