Commit 5233957e authored by Daniel Lehmberg's avatar Daniel Lehmberg
Browse files

add new attribute "currentFootStep" to Pedestrian.class

parent 9cce77a8
Pipeline #146858 failed with stages
in 2 minutes and 25 seconds
......@@ -4,7 +4,6 @@ import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.behavior.SalientBehavior;
import org.vadere.state.simulation.FootStep;
import org.vadere.state.simulation.LastFootSteps;
import org.vadere.state.simulation.VTrajectory;
import org.vadere.state.types.ScenarioElementType;
import org.vadere.util.geometry.shapes.VPoint;
......@@ -27,7 +26,7 @@ public class Pedestrian extends Agent {
private SalientBehavior salientBehavior;
private LinkedList<Integer> groupIds; // TODO should actually be an attribute or a member of a subclass
* Footsteps is a list of foot steps a pedestrian made during the duration of one time step.
* trajectory is a list of foot steps a pedestrian made during the duration of one time step.
* For all non event driven models this is exactly one foot step. For the event driven update
* one pedestrian can move multiple times during one time step. To save memory the list of foot steps
* will be cleared after each completion of a time step. The output processor <tt>PedestrianStrideProcessor</tt>
......@@ -35,6 +34,11 @@ 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!
......@@ -61,6 +65,7 @@ public class Pedestrian extends Agent {
groupSizes = new LinkedList<>();
modelPedestrianMap = new HashMap<>();
trajectory = new VTrajectory(attributesAgent.getFootStepsToStore());
currentFootStep = null;
private Pedestrian(Pedestrian other) {
......@@ -111,7 +116,11 @@ public class Pedestrian extends Agent {
public VPoint getInterpolatedFootStepPosition(double time){
return FootStep.interpolateFootStep(trajectory.getFootSteps().getLast(), time);
if(currentFootStep == null){
return getPosition();
return FootStep.interpolateFootStep(currentFootStep, time);
// Setter
......@@ -145,10 +154,15 @@ public class Pedestrian extends Agent {
public void addFootStepToTrajectory(FootStep footStep){
currentFootStep = footStep;
this.trajectory = this.trajectory.add(footStep);
public void clearFootSteps() {
// Last is always the most recent (made sure in VTrajectory.add)
// 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)
currentFootStep = trajectory.getFootSteps().getLast();
......@@ -158,6 +158,11 @@ public final class FootStep {
return start + "->" + end;
public FootStep clone(){
return new FootStep(this.start.clone(), this.end.clone(), this.startTime, this.endTime);
public String[] getValueString(){
String[] valueLine = {""+startTime, ""+endTime, ""+start.x, ""+start.y, ""+end.x, ""+end.y};
return valueLine;
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