Notice to GitKraken users: A vulnerability has been found in the SSH key generation of GitKraken versions 7.6.0 to 8.0.0 (https://www.gitkraken.com/blog/weak-ssh-key-fix). If you use GitKraken and have generated a SSH key using one of these versions, please remove it both from your local workstation and from your LRZ GitLab profile.

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

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

Implemented first (rudimentary) working version of...

Implemented first (rudimentary) working version of "SalientBehavior.COOPERATIVE" in "OSMBehaviorController" and "UpdateSchemeEventDriven" (but visualization seems to be broken).
parent 823c1d83
......@@ -73,9 +73,7 @@ public class OSMBehaviorController {
pedestrian.setVelocity(pedVelocity);
}
/**
* strides and foot steps have no influence on the simulation itself, i.e. they are saved to analyse trajectories
*/
// 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));
}
......@@ -121,10 +119,16 @@ public class OSMBehaviorController {
*/
public void swapWithClosestCooperativePedestrian(PedestrianOSM pedestrian, Topography topography) {
if (pedestrian.hasNextTarget() == false) { // Ignore pedestrians with no targets.
// this can cause problems if the pedestrian desired speed is 0 (see speed adjuster)
pedestrian.updateNextPosition();
makeStep(pedestrian, topography, pedestrian.getDurationNextStep());
pedestrian.setTimeOfNextStep(pedestrian.getTimeOfNextStep() + pedestrian.getDurationNextStep());
return;
}
List<Pedestrian> closestPedestrians = getClosestPedestriansWhichAreCloserToTarget(pedestrian, topography);
boolean pedestriansSwapped = false;
if (closestPedestrians.size() > 0) {
for (Pedestrian closestPedestrian : closestPedestrians) {
......@@ -133,18 +137,26 @@ public class OSMBehaviorController {
boolean targetOrientationDiffers = true;
if (closestPedIsCooperative && targetOrientationDiffers) {
swapPedestrians(pedestrian, closestPedestrian);
swapPedestrians(pedestrian, (PedestrianOSM)closestPedestrian, topography);
pedestriansSwapped = true;
break;
}
}
}
if (pedestriansSwapped == false) { // Try to perform a regular step
// this can cause problems if the pedestrian desired speed is 0 (see speed adjuster)
pedestrian.updateNextPosition();
makeStep(pedestrian, topography, pedestrian.getDurationNextStep());
pedestrian.setTimeOfNextStep(pedestrian.getTimeOfNextStep() + pedestrian.getDurationNextStep());
}
}
@NotNull
private List<Pedestrian> getClosestPedestriansWhichAreCloserToTarget(PedestrianOSM pedestrian, Topography topography) {
VPoint positionOfPedestrian = pedestrian.getPosition();
// TODO Maybe, extract search radius as configurable attribute.
List<Pedestrian> closestPedestrians = topography.getSpatialMap(Pedestrian.class)
.getObjects(positionOfPedestrian, pedestrian.getRadius() * 5);
......@@ -207,16 +219,17 @@ public class OSMBehaviorController {
return angleInRadian;
}
private void swapPedestrians(Pedestrian pedestrian1, Pedestrian pedestrian2) {
private void swapPedestrians(PedestrianOSM pedestrian1, PedestrianOSM pedestrian2, Topography topography) {
// TODO Use "makeStep()" to swap both pedestrians to avoid
// "java.lang.AssertionError: Number of pedestrians in LinkedCellGrid does not match number of pedestrians in topography".
/*
VPoint newPosition = pedestrian2.getPosition().clone();
VPoint oldPosition = pedestrian1.getPosition().clone();
pedestrian1.setPosition(newPosition);
pedestrian2.setPosition(oldPosition);
*/
pedestrian1.setNextPosition(newPosition);
pedestrian2.setNextPosition(oldPosition);
makeStep(pedestrian1, topography, pedestrian1.getDurationNextStep());
makeStep(pedestrian2, topography, pedestrian2.getDurationNextStep());
}
}
......@@ -60,14 +60,12 @@ public class UpdateSchemeEventDriven implements UpdateSchemeOSM {
}
// TODO Make a code review with Bene here and check if everything works as expected.
// this can cause problems if the pedestrian desired speed is 0 (see speed adjuster)
pedestrian.updateNextPosition();
double stepDuration = pedestrian.getDurationNextStep();
osmBehaviorController.makeStep(pedestrian, topography, stepDuration);
pedestrian.setTimeOfNextStep(pedestrian.getTimeOfNextStep() + stepDuration);
if (pedestrian.getSalientBehavior() == SalientBehavior.COOPERATIVE) {
if (pedestrian.getSalientBehavior() == SalientBehavior.TARGET_ORIENTED) {
// this can cause problems if the pedestrian desired speed is 0 (see speed adjuster)
pedestrian.updateNextPosition();
osmBehaviorController.makeStep(pedestrian, topography, pedestrian.getDurationNextStep());
pedestrian.setTimeOfNextStep(pedestrian.getTimeOfNextStep() + pedestrian.getDurationNextStep());
} else if (pedestrian.getSalientBehavior() == SalientBehavior.COOPERATIVE) {
osmBehaviorController.swapWithClosestCooperativePedestrian(pedestrian, topography);
}
} else if (mostImportantEvent instanceof WaitEvent || mostImportantEvent instanceof WaitInAreaEvent) {
......
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