Starting from 2021-07-01, all LRZ GitLab users will be required to explicitly accept the GitLab Terms of Service. Please see the detailed information at https://doku.lrz.de/display/PUBLIC/GitLab and make sure that your projects conform to the requirements.

Commit 95beb249 authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier
Browse files

Refactored "CooperativeCognitionModel.update()" to make it more readable

parent 6786f2c0
......@@ -28,22 +28,26 @@ public class CooperativeCognitionModel implements ICognitionModel {
@Override
public void update(Collection<Pedestrian> pedestrians) {
for (Pedestrian pedestrian : pedestrians) {
// TODO: Maybe, add following variables as attributes to new class "AttributesCognition".
int requiredFootSteps = 2;
double requiredSpeedInMetersPerSecondToBeCooperative = 0.05;
FootstepHistory footstepHistory = pedestrian.getFootstepHistory();
// Adapt category only if we have seen some footsteps in the past
if (footstepHistory.size() >= requiredFootSteps) {
if (footstepHistory.getAverageSpeedInMeterPerSecond() <= requiredSpeedInMetersPerSecondToBeCooperative) {
if (pedestrianCannotMove(pedestrian)) {
pedestrian.setSelfCategory(SelfCategory.COOPERATIVE);
} else {
// TODO: Maybe, check if area directed to target is free for a step
// (only then change to "TARGET_ORIENTED").
// Maybe, check if area directed to target is free for a step (only then change to "TARGET_ORIENTED").
pedestrian.setSelfCategory(SelfCategory.TARGET_ORIENTED);
}
}
}
private boolean pedestrianCannotMove(Pedestrian pedestrian) {
boolean cannotMove = false;
FootstepHistory footstepHistory = pedestrian.getFootstepHistory();
int requiredFootSteps = 2;
if (footstepHistory.size() >= requiredFootSteps
&& footstepHistory.getAverageSpeedInMeterPerSecond() <= 0.05) {
cannotMove = true;
}
return cannotMove;
}
}
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