Commit 8917e4ab authored by Maxim Dudin's avatar Maxim Dudin
Browse files

added a tolerance for short leaves without breaking one constant contact,...

added a tolerance for short leaves without breaking one constant contact, tolerance is adjustable over json
parent 9d49b443
......@@ -42,10 +42,11 @@ public class TimestepPedestriansNearbyIdKey implements DataKey<TimestepPedestria
return new String[]{Integer.toString(timeStep), Integer.toString(pedId1), Integer.toString(pedId2)};
}
public boolean isContinuationOf(PedestriansNearbyData other) {
public boolean isContinuationOf(PedestriansNearbyData other, int toleranceTimesteps) {
return other.getPedId1() == getPedId1() &&
other.getPedId2() == getPedId2() &&
(other.getStartTimestep() + other.getDurationTimesteps() == getTimeStep());
(other.getStartTimestep() + other.getDurationTimesteps() <= getTimeStep()) &&
(other.getStartTimestep() + other.getDurationTimesteps() + toleranceTimesteps >= getTimeStep());
}
public boolean isAccountedForBy(PedestriansNearbyData other) {
return equals(other) ||
......
......@@ -25,6 +25,7 @@ import java.util.stream.Collectors;
public class PedestriansNearbyProcessor extends DataProcessor<TimestepPedestriansNearbyIdKey, PedestriansNearbyData> {
private double maxDistance; // todo adjustable with json
private int sampleEveryNthStep;
private int allowedAbsenceTimestepsIfContactReturns;
public PedestriansNearbyProcessor() {
......@@ -63,7 +64,7 @@ public class PedestriansNearbyProcessor extends DataProcessor<TimestepPedestrian
PedestriansNearbyData currentVal = getValue(alreadyExisting);
if (key.isAccountedForBy(currentVal)) {
return;
} else if (key.isContinuationOf(currentVal)) {
} else if (key.isContinuationOf(currentVal, allowedAbsenceTimestepsIfContactReturns)) {
super.putValue(alreadyExisting, currentVal.getDataWithIncrementedDuration(sampleEveryNthStep));
return;
}
......@@ -77,6 +78,7 @@ public class PedestriansNearbyProcessor extends DataProcessor<TimestepPedestrian
AttributesPedestrianNearbyProcessor att = (AttributesPedestrianNearbyProcessor) this.getAttributes();
maxDistance = att.getMaxDistanceForANearbyPedestrian();
sampleEveryNthStep = att.getSampleEveryNthStep();
allowedAbsenceTimestepsIfContactReturns = att.getAllowedAbsenceTimestepsIfContactReturns();
}
private List<DynamicElement> getDynElementsAtPosition(final Topography topography, VPoint sourcePosition, double radius) {
......
......@@ -8,6 +8,7 @@ package org.vadere.state.attributes.processor;
public class AttributesPedestrianNearbyProcessor extends AttributesProcessor {
private double maxDistanceForANearbyPedestrian = 1.5;
private int sampleEveryNthStep = 1;
private int allowedAbsenceTimestepsIfContactReturns = 0;
public double getMaxDistanceForANearbyPedestrian() {
return maxDistanceForANearbyPedestrian;
......@@ -16,4 +17,8 @@ public class AttributesPedestrianNearbyProcessor extends AttributesProcessor {
public int getSampleEveryNthStep() {
return sampleEveryNthStep;
}
public int getAllowedAbsenceTimestepsIfContactReturns() {
return allowedAbsenceTimestepsIfContactReturns;
}
}
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