Commit 92a60ae9 authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier

Renamed variables "closestPedestrian" to "neighbor"

parent 0262836d
Pipeline #275067 passed with stages
in 213 minutes and 12 seconds
...@@ -30,12 +30,12 @@ public class CounterflowCognitionModel implements ICognitionModel { ...@@ -30,12 +30,12 @@ public class CounterflowCognitionModel implements ICognitionModel {
pedestrian.setSelfCategory(SelfCategory.TARGET_ORIENTED); pedestrian.setSelfCategory(SelfCategory.TARGET_ORIENTED);
if (pedestrian.hasNextTarget()) { if (pedestrian.hasNextTarget()) {
Pedestrian closestPedestrian = TopographyHelper.getNeighborCloserToTargetCentroid(pedestrian, topography); Pedestrian neighborCloserToTarget = TopographyHelper.getNeighborCloserToTargetCentroid(pedestrian, topography);
if (closestPedestrian != null) { if (neighborCloserToTarget != null) {
if (TopographyHelper.walkingDirectionDiffers(pedestrian, closestPedestrian, topography)) { if (TopographyHelper.walkingDirectionDiffers(pedestrian, neighborCloserToTarget, topography)) {
pedestrian.setSelfCategory(SelfCategory.EVADE); pedestrian.setSelfCategory(SelfCategory.EVADE);
} else if (closestPedestrian.getSelfCategory() == SelfCategory.EVADE) { } else if (neighborCloserToTarget.getSelfCategory() == SelfCategory.EVADE) {
pedestrian.setSelfCategory(SelfCategory.EVADE); // Imitate behavior pedestrian.setSelfCategory(SelfCategory.EVADE); // Imitate behavior
} }
} }
......
...@@ -88,7 +88,7 @@ public class ThreatCognitionModel implements ICognitionModel { ...@@ -88,7 +88,7 @@ public class ThreatCognitionModel implements ICognitionModel {
if (pedestrian.getGroupMembership() == GroupMembership.OUT_GROUP) { if (pedestrian.getGroupMembership() == GroupMembership.OUT_GROUP) {
pedestrian.setSelfCategory(SelfCategory.TARGET_ORIENTED); pedestrian.setSelfCategory(SelfCategory.TARGET_ORIENTED);
} else if (pedestrian.getGroupMembership() == GroupMembership.IN_GROUP) { } else if (pedestrian.getGroupMembership() == GroupMembership.IN_GROUP) {
imitateThreatenedPedestrianIfPresent(pedestrian); imitateThreatenedNeighborIfPresent(pedestrian);
} else { } else {
throw new IllegalArgumentException("Can only process \"IN_GROUP\" and \"OUT_GROUP\" group membership!"); throw new IllegalArgumentException("Can only process \"IN_GROUP\" and \"OUT_GROUP\" group membership!");
} }
...@@ -124,15 +124,15 @@ public class ThreatCognitionModel implements ICognitionModel { ...@@ -124,15 +124,15 @@ public class ThreatCognitionModel implements ICognitionModel {
* *
* This behavior is triggered by method {@link #handleThreat(Pedestrian, Stimulus)}. * This behavior is triggered by method {@link #handleThreat(Pedestrian, Stimulus)}.
*/ */
private void imitateThreatenedPedestrianIfPresent(Pedestrian pedestrian) { private void imitateThreatenedNeighborIfPresent(Pedestrian pedestrian) {
List<Pedestrian> threatenedPedestrians = TopographyHelper.getNeighborsWithSelfCategory(pedestrian, SelfCategory.OUTSIDE_THREAT_AREA, topography); List<Pedestrian> threatenedNeighbors = TopographyHelper.getNeighborsWithSelfCategory(pedestrian, SelfCategory.OUTSIDE_THREAT_AREA, topography);
List<Pedestrian> threatenedIngroupPeds = threatenedPedestrians.stream() List<Pedestrian> threatenedIngroupNeighbors = threatenedNeighbors.stream()
.filter(ped -> ped.getGroupMembership() == GroupMembership.IN_GROUP) .filter(ped -> ped.getGroupMembership() == GroupMembership.IN_GROUP)
.collect(Collectors.toList()); .collect(Collectors.toList());
if (threatenedIngroupPeds.isEmpty() == false) { if (threatenedIngroupNeighbors.isEmpty() == false) {
Pedestrian threatenedPedestrian = threatenedIngroupPeds.get(0); Pedestrian threatenedNeighbor = threatenedIngroupNeighbors.get(0);
Threat latestThreat = threatenedPedestrian.getThreatMemory().getLatestThreat(); Threat latestThreat = threatenedNeighbor.getThreatMemory().getLatestThreat();
assert latestThreat != null; assert latestThreat != null;
......
...@@ -332,19 +332,19 @@ public class OSMBehaviorController { ...@@ -332,19 +332,19 @@ public class OSMBehaviorController {
return null; return null;
} }
List<Pedestrian> closestPedestrians = TopographyHelper.getNeighborsCloserToTarget(pedestrian, topography); List<Pedestrian> neighborsCloserToTarget = TopographyHelper.getNeighborsCloserToTarget(pedestrian, topography);
if (closestPedestrians.size() > 0) { if (neighborsCloserToTarget.size() > 0) {
for (Pedestrian closestPedestrian : closestPedestrians) { for (Pedestrian neighbor : neighborsCloserToTarget) {
if (closestPedestrian.hasNextTarget()) { if (neighbor.hasNextTarget()) {
boolean closestPedIsCooperative = closestPedestrian.getSelfCategory() == SelfCategory.COOPERATIVE; boolean neighborIsCooperative = neighbor.getSelfCategory() == SelfCategory.COOPERATIVE;
boolean walkingDirectionDiffers = TopographyHelper.walkingDirectionDiffers(pedestrian, closestPedestrian, topography); boolean walkingDirectionDiffers = TopographyHelper.walkingDirectionDiffers(pedestrian, neighbor, topography);
if (closestPedIsCooperative && walkingDirectionDiffers) { if (neighborIsCooperative && walkingDirectionDiffers) {
return (PedestrianOSM)closestPedestrian; return (PedestrianOSM)neighbor;
} }
} else { } else {
return (PedestrianOSM)closestPedestrian; return (PedestrianOSM)neighbor;
} }
} }
} }
......
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