Commit 21ad9c1d authored by hm-schuhba1's avatar hm-schuhba1

Merge branch 'master' into 151_diff_origin

parents 184bdd82 e9873189
Pipeline #76228 failed with stages
in 46 minutes and 3 seconds
...@@ -46,6 +46,7 @@ VadereModelTests/TestOSM/output/* ...@@ -46,6 +46,7 @@ VadereModelTests/TestOSM/output/*
VadereModelTests/TestOSM_Group/output/* VadereModelTests/TestOSM_Group/output/*
VadereModelTests/TestSFM/output/* VadereModelTests/TestSFM/output/*
VadereModelTests/TestGNM/output/* VadereModelTests/TestGNM/output/*
VadereModelTests/TestBHM/output/*
VadereModelTests/TestOVM/output/* VadereModelTests/TestOVM/output/*
VadereModelTests/TestOSM/legacy/* VadereModelTests/TestOSM/legacy/*
VadereModelTests/TestOSM_Group/legacy/* VadereModelTests/TestOSM_Group/legacy/*
...@@ -67,7 +68,7 @@ VadereGui/output/ ...@@ -67,7 +68,7 @@ VadereGui/output/
#mac osx files #mac osx files
.DS_Store .DS_Store
#linux deskopt dotfiles #linux desktop dotfiles
**/.directory **/.directory
/VadereModelTests/TestStairs/output /VadereModelTests/TestStairs/output
/VadereModelTests/TestStairs/legacy /VadereModelTests/TestStairs/legacy
...@@ -11,7 +11,9 @@ This software runs on OS X, Windows, and Linux. ...@@ -11,7 +11,9 @@ This software runs on OS X, Windows, and Linux.
VADERE has been developed by [Prof. Dr. Gerta Köster's](http://www.cs.hm.edu/die_fakultaet/ansprechpartner/professoren/koester/index.de.html) VADERE has been developed by [Prof. Dr. Gerta Köster's](http://www.cs.hm.edu/die_fakultaet/ansprechpartner/professoren/koester/index.de.html)
research group at the [Munich University of Applied Sciences](https://www.hm.edu/) at the research group at the [Munich University of Applied Sciences](https://www.hm.edu/) at the
[department for Computer Science and Mathematics](http://cs.hm.edu/). [department for Computer Science and Mathematics](http://cs.hm.edu/).
However, we welcome contributions from external sources. However, we welcome contributions from external sources.
The VADERE framework includes a mesh generator for unstructured high quality 2D meshes called **EikMesh** which is described [here](https://gitlab.lrz.de/vadere/vadere/blob/master/VadereMeshing/README.md).
## Pipeline Status ## Pipeline Status
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# Note: script contains some print statements so that progress can be tracked # Note: script contains some print statements so that progress can be tracked
# a little bit while script is running in continuous integration pipeline. # a little bit while script is running in continuous integration pipeline.
# Wach out: call this script from root directory of project. E.g. # Watch out: call this script from root directory of project. E.g.
# #
# python Tools/my_script.py # python Tools/my_script.py
...@@ -46,6 +46,7 @@ def run_scenario_files_with_vadere_console(scenario_files, vadere_console="Vader ...@@ -46,6 +46,7 @@ def run_scenario_files_with_vadere_console(scenario_files, vadere_console="Vader
failed_scenarios_with_exception = [] failed_scenarios_with_exception = []
for i, scenario_file in enumerate(scenario_files): for i, scenario_file in enumerate(scenario_files):
try: try:
print("Running scenario file ({}/{}): {}".format(i + 1, total_scenario_files, scenario_file)) print("Running scenario file ({}/{}): {}".format(i + 1, total_scenario_files, scenario_file))
...@@ -96,6 +97,7 @@ def print_summary(passed_and_failed_scenarios): ...@@ -96,6 +97,7 @@ def print_summary(passed_and_failed_scenarios):
print("Failed: {}".format(total_failed_scenarios)) print("Failed: {}".format(total_failed_scenarios))
if __name__ == "__main__": if __name__ == "__main__":
long_running_scenarios = [ long_running_scenarios = [
"basic_4_1_wall_gnm1", "basic_4_1_wall_gnm1",
"queueing", "queueing",
...@@ -103,8 +105,10 @@ if __name__ == "__main__": ...@@ -103,8 +105,10 @@ if __name__ == "__main__":
"rimea_11", "rimea_11",
"TestSFM", "TestSFM",
"thin_wall_and_closer_source_nelder_mead_ok", "thin_wall_and_closer_source_nelder_mead_ok",
"thin_wall_and_closer_source_pso_could_fail" "thin_wall_and_closer_source_pso_could_fail",
"rimea_04_flow_osm1_550_up",
] ]
excluded_scenarios = ["TESTOVM", "output", "legacy"] excluded_scenarios = ["TESTOVM", "output", "legacy"]
excluded_scenarios.extend(long_running_scenarios) excluded_scenarios.extend(long_running_scenarios)
......
...@@ -297,6 +297,7 @@ TopographyCreator.btnCutTopography.tooltip=Cut Scenario ...@@ -297,6 +297,7 @@ TopographyCreator.btnCutTopography.tooltip=Cut Scenario
TopographyCreator.btnInsertPedestrian.tooltip=Pedestrian TopographyCreator.btnInsertPedestrian.tooltip=Pedestrian
TopographyCreator.btnTopographyBound.tooltip=Topography Bound TopographyCreator.btnTopographyBound.tooltip=Topography Bound
TopographyCreator.btnTranslation.tooltip=Translate topography TopographyCreator.btnTranslation.tooltip=Translate topography
TopographyCreator.btnElementTranslation.tooltip=Translate topography elements
TopographyCreator.btnInsertObstacle.tooltip=Obstacle TopographyCreator.btnInsertObstacle.tooltip=Obstacle
TopographyCreator.btnInsertTarget.tooltip=Target TopographyCreator.btnInsertTarget.tooltip=Target
TopographyCreator.btnInsertSource.tooltip=Source TopographyCreator.btnInsertSource.tooltip=Source
......
...@@ -293,6 +293,7 @@ TopographyCreator.btnInsertObstacle.tooltip=Hindernis ...@@ -293,6 +293,7 @@ TopographyCreator.btnInsertObstacle.tooltip=Hindernis
TopographyCreator.btnInsertTarget.tooltip=Ziel TopographyCreator.btnInsertTarget.tooltip=Ziel
TopographyCreator.btnTopographyBound.tooltip=Topographie Grenze TopographyCreator.btnTopographyBound.tooltip=Topographie Grenze
TopographyCreator.btnTranslation.tooltip=Topographie verschieben TopographyCreator.btnTranslation.tooltip=Topographie verschieben
TopographyCreator.btnElementTranslation.tooltip=Elemente der Topography verschieben
TopographyCreator.btnInsertSource.tooltip=Quelle TopographyCreator.btnInsertSource.tooltip=Quelle
TopographyCreator.btnInsertStairs.tooltip=Treppen TopographyCreator.btnInsertStairs.tooltip=Treppen
TopographyCreator.btnErase.tooltip=Radierer TopographyCreator.btnErase.tooltip=Radierer
......
...@@ -174,12 +174,12 @@ public class ScenarioElementView extends JPanel implements ISelectScenarioElemen ...@@ -174,12 +174,12 @@ public class ScenarioElementView extends JPanel implements ISelectScenarioElemen
} else { } else {
if (scenarioElement instanceof AgentWrapper) { if (scenarioElement instanceof AgentWrapper) {
this.txtrTextfiletextarea.setText( this.txtrTextfiletextarea.setText(
StateJsonConverter.serializeObject(((AgentWrapper) scenarioElement).getAgentInitialStore())); StateJsonConverter.serializeObjectPretty(((AgentWrapper) scenarioElement).getAgentInitialStore()));
} else if (scenarioElement instanceof Pedestrian) { } else if (scenarioElement instanceof Pedestrian) {
this.txtrTextfiletextarea.setText(StateJsonConverter.serializeObject(scenarioElement)); this.txtrTextfiletextarea.setText(StateJsonConverter.serializeObjectPretty(scenarioElement));
} else { } else {
this.txtrTextfiletextarea.setText(StateJsonConverter this.txtrTextfiletextarea.setText(StateJsonConverter
.serializeObject(scenarioElement.getAttributes())); .serializeObjectPretty(scenarioElement.getAttributes()));
} }
} }
} }
......
...@@ -4,12 +4,15 @@ import java.awt.*; ...@@ -4,12 +4,15 @@ import java.awt.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import java.util.stream.Stream;
import org.jetbrains.annotations.NotNull;
import org.vadere.gui.components.view.DefaultRenderer; import org.vadere.gui.components.view.DefaultRenderer;
import org.vadere.gui.components.view.SimulationRenderer; import org.vadere.gui.components.view.SimulationRenderer;
import org.vadere.gui.onlinevisualization.model.OnlineVisualizationModel; import org.vadere.gui.onlinevisualization.model.OnlineVisualizationModel;
import org.vadere.gui.renderer.agent.AgentRender; import org.vadere.gui.renderer.agent.AgentRender;
import org.vadere.state.scenario.Agent; import org.vadere.state.scenario.Agent;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.util.geometry.shapes.VPoint; import org.vadere.util.geometry.shapes.VPoint;
public class OnlinevisualizationRenderer extends SimulationRenderer { public class OnlinevisualizationRenderer extends SimulationRenderer {
...@@ -102,4 +105,18 @@ public class OnlinevisualizationRenderer extends SimulationRenderer { ...@@ -102,4 +105,18 @@ public class OnlinevisualizationRenderer extends SimulationRenderer {
} }
} }
} }
/*
* This method should replace pedestrianPositions.get(ped.getId()).addFirst(ped.getPosition());
* However the simulation runs in an separated thread. Therefore, foot steps might be cleared
* before they can be drawn! Solution: deep clone of the topography, which is costly and difficult.
*/
private Stream<VPoint> getFootStepsPosition(@NotNull final Agent agent) {
if(agent instanceof Pedestrian) {
return ((Pedestrian) agent).getFootSteps().stream().map(footStep -> footStep.getStart());
}
else {
return Stream.of(agent.getPosition());
}
}
} }
...@@ -111,7 +111,6 @@ public class PostvisualizationModel extends SimulationModel<PostvisualizationCon ...@@ -111,7 +111,6 @@ public class PostvisualizationModel extends SimulationModel<PostvisualizationCon
// to have fast access to the key values. // to have fast access to the key values.
Map<Integer, Step> map = agentsByStep Map<Integer, Step> map = agentsByStep
.keySet().stream() .keySet().stream()
.sorted(stepComparator)
.collect(Collectors.toMap(s -> s.getStepNumber(), s -> s)); .collect(Collectors.toMap(s -> s.getStepNumber(), s -> s));
......
package org.vadere.gui.topographycreator.control;
import org.jetbrains.annotations.NotNull;
import org.vadere.gui.topographycreator.model.IDrawPanelModel;
import org.vadere.gui.topographycreator.model.TopographyCreatorModel;
import org.vadere.gui.topographycreator.view.ActionTranslateTopographyDialog;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VRectangle;
import java.awt.event.ActionEvent;
import java.awt.geom.Rectangle2D;
import javax.swing.*;
import javax.swing.undo.UndoableEditSupport;
/**
* @author Benedikt Zoennchen
*/
public class ActionTranslateElements extends TopographyAction {
private TopographyAction action;
private final UndoableEditSupport undoableEditSupport;
public ActionTranslateElements(final String name,
final ImageIcon icon,
@NotNull final IDrawPanelModel<?> panelModel,
@NotNull final TopographyAction action,
@NotNull final UndoableEditSupport undoSupport) {
super(name, icon, panelModel);
this.action = action;
this.undoableEditSupport = undoSupport;
}
@Override
public void actionPerformed(ActionEvent e) {
action.actionPerformed(e);
TopographyCreatorModel model = (TopographyCreatorModel) getScenarioPanelModel();
ActionTranslateTopographyDialog dialog = new ActionTranslateTopographyDialog(0, 0);
if (dialog.getValue()){
double x = dialog.getX();
double y = dialog.getY();
TopographyCreatorModel topographyCreatorModel = (TopographyCreatorModel) getScenarioPanelModel();
topographyCreatorModel.translateElements(x, y);
undoableEditSupport.postEdit(new EditTranslateElements(topographyCreatorModel, x, y));
}
getScenarioPanelModel().notifyObservers();
}
}
package org.vadere.gui.topographycreator.control;
import org.jetbrains.annotations.NotNull;
import org.vadere.gui.topographycreator.model.TopographyCreatorModel;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VRectangle;
import javax.swing.undo.AbstractUndoableEdit;
import javax.swing.undo.CannotRedoException;
import javax.swing.undo.CannotUndoException;
/**
* @author Benedikt Zoennchen
*/
public class EditTranslateElements extends AbstractUndoableEdit {
private static final long serialVersionUID = 5176192525116057658L;
private final TopographyCreatorModel panelModel;
private final double dx;
private final double dy;
public EditTranslateElements(@NotNull final TopographyCreatorModel panelModel,
final double dx,
final double dy) {
this.panelModel = panelModel;
this.dx = dx;
this.dy = dy;
}
@Override
public void undo() throws CannotUndoException {
panelModel.translateElements(-dx, -dy);
}
@Override
public void redo() throws CannotRedoException {
panelModel.translateTopography(dx, dy);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public boolean canRedo() {
return true;
}
@Override
public String getPresentationName() {
return "translate elements";
}
}
...@@ -335,12 +335,16 @@ public class TopographyCreatorModel extends DefaultModel implements IDrawPanelMo ...@@ -335,12 +335,16 @@ public class TopographyCreatorModel extends DefaultModel implements IDrawPanelMo
public void translateTopography(final double x, final double y) { public void translateTopography(final double x, final double y) {
double oldX = getTopographyBound().x; double oldX = getTopographyBound().x;
double oldY = getTopographyBound().y; double oldY = getTopographyBound().y;
translateElements(x - oldX, y - oldY);
topographyBuilder.translateElements(x - oldX, y - oldY);
setTopographyBound(new VRectangle(x, y, getTopographyBound().getWidth(), getTopographyBound().getHeight())); setTopographyBound(new VRectangle(x, y, getTopographyBound().getWidth(), getTopographyBound().getHeight()));
setChanged(); setChanged();
} }
public void translateElements(final double dx, final double dy) {
topographyBuilder.translateElements(dx, dy);
setChanged();
}
@Override @Override
public VShape translate(final Point vector) { public VShape translate(final Point vector) {
VPoint worldVector = new VPoint(vector.x / getScaleFactor(), -vector.y / getScaleFactor()); VPoint worldVector = new VPoint(vector.x / getScaleFactor(), -vector.y / getScaleFactor());
......
...@@ -4,6 +4,7 @@ import org.vadere.gui.projectview.view.ProjectView; ...@@ -4,6 +4,7 @@ import org.vadere.gui.projectview.view.ProjectView;
import java.awt.*; import java.awt.*;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.util.Locale;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
...@@ -22,7 +23,7 @@ public class ActionTranslateTopographyDialog { ...@@ -22,7 +23,7 @@ public class ActionTranslateTopographyDialog {
public ActionTranslateTopographyDialog(final double x, double y){ public ActionTranslateTopographyDialog(final double x, double y){
this.textField = new JTextField(30); this.textField = new JTextField(30);
this.textField.setText(String.format("%f, %f", x, y)); this.textField.setText(String.format(Locale.ENGLISH, "%f, %f", x, y));
this.textField.getDocument().addDocumentListener(new DialogListener()); this.textField.getDocument().addDocumentListener(new DialogListener());
this.valid = false; this.valid = false;
this.x = x; this.x = x;
......
...@@ -31,6 +31,7 @@ import org.vadere.gui.topographycreator.control.ActionSelectSelectShape; ...@@ -31,6 +31,7 @@ import org.vadere.gui.topographycreator.control.ActionSelectSelectShape;
import org.vadere.gui.topographycreator.control.ActionSwitchCategory; import org.vadere.gui.topographycreator.control.ActionSwitchCategory;
import org.vadere.gui.topographycreator.control.ActionSwitchSelectionMode; import org.vadere.gui.topographycreator.control.ActionSwitchSelectionMode;
import org.vadere.gui.topographycreator.control.ActionTopographyMakroMenu; import org.vadere.gui.topographycreator.control.ActionTopographyMakroMenu;
import org.vadere.gui.topographycreator.control.ActionTranslateElements;
import org.vadere.gui.topographycreator.control.ActionTranslateTopography; import org.vadere.gui.topographycreator.control.ActionTranslateTopography;
import org.vadere.gui.topographycreator.control.ActionUndo; import org.vadere.gui.topographycreator.control.ActionUndo;
import org.vadere.gui.topographycreator.control.ActionZoomIn; import org.vadere.gui.topographycreator.control.ActionZoomIn;
...@@ -308,10 +309,14 @@ public class TopographyWindow extends JPanel { ...@@ -308,10 +309,14 @@ public class TopographyWindow extends JPanel {
new ImageIcon(Resources.class.getResource("/icons/topography_icon.png")), new ImageIcon(Resources.class.getResource("/icons/topography_icon.png")),
panelModel, selectShape, undoSupport); panelModel, selectShape, undoSupport);
TopographyAction translateTopography =new ActionTranslateTopography("SetTopograpyBound", TopographyAction translateTopography =new ActionTranslateTopography("TranslateTopography",
new ImageIcon(Resources.class.getResource("/icons/translation_icon.png")), new ImageIcon(Resources.class.getResource("/icons/translation_icon.png")),
panelModel, selectShape, undoSupport); panelModel, selectShape, undoSupport);
TopographyAction translateElements =new ActionTranslateElements("TranslateElements",
new ImageIcon(Resources.class.getResource("/icons/translation_elements_icon.png")),
panelModel, selectShape, undoSupport);
/* Makros */ /* Makros */
ActionTopographyMakroMenu actionTopographyMakroMenu = ActionTopographyMakroMenu actionTopographyMakroMenu =
new ActionTopographyMakroMenu("TopographyMakros", new ActionTopographyMakroMenu("TopographyMakros",
...@@ -353,6 +358,7 @@ public class TopographyWindow extends JPanel { ...@@ -353,6 +358,7 @@ public class TopographyWindow extends JPanel {
addActionToToolbar(toolbar, maximizeAction, "TopographyCreator.btnMaximizeTopography.tooltip"); addActionToToolbar(toolbar, maximizeAction, "TopographyCreator.btnMaximizeTopography.tooltip");
addActionToToolbar(toolbar, resizeTopographyBound, "TopographyCreator.btnTopographyBound.tooltip"); addActionToToolbar(toolbar, resizeTopographyBound, "TopographyCreator.btnTopographyBound.tooltip");
addActionToToolbar(toolbar, translateTopography, "TopographyCreator.btnTranslation.tooltip"); addActionToToolbar(toolbar, translateTopography, "TopographyCreator.btnTranslation.tooltip");
addActionToToolbar(toolbar, translateElements, "TopographyCreator.btnElementTranslation.tooltip");
toolbar.addSeparator(new Dimension(5, 50)); toolbar.addSeparator(new Dimension(5, 50));
addActionToToolbar(toolbar, selectCutAction, "TopographyCreator.btnCutTopography.tooltip"); addActionToToolbar(toolbar, selectCutAction, "TopographyCreator.btnCutTopography.tooltip");
addActionToToolbar(toolbar, resetScenarioAction, "TopographyCreator.btnNewTopography.tooltip"); addActionToToolbar(toolbar, resetScenarioAction, "TopographyCreator.btnNewTopography.tooltip");
......
# EikMesh
TODO
\ No newline at end of file
...@@ -53,6 +53,16 @@ ...@@ -53,6 +53,16 @@
"attributes" : { "attributes" : {
"pedestrianOverlapProcessorId" : 3 "pedestrianOverlapProcessorId" : 3
} }
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.tests.TestPedestrianWaitingTimeProcessor",
"id" : 6,
"attributesType" : "org.vadere.state.attributes.processor.AttributesTestPedestrianWaitingTimeProcessor",
"attributes" : {
"expectedResult" : "SUCCESS",
"pedestrianWaitingTimeProcessorId" : 2,
"maximalWaitingTime" : 0.0,
"minimalWaitingTime" : 0.0
}
} ], } ],
"isTimestamped" : true "isTimestamped" : true
}, },
......
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
"finishTime" : 400.0, "finishTime" : 400.0,
"simTimeStepLength" : 0.4, "simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.0, "realTimeSimTimeRatio" : 0.0,
"writeSimulationData" : true, "writeSimulationData" : false,
"visualizationEnabled" : true, "visualizationEnabled" : true,
"printFPS" : false, "printFPS" : false,
"digitsPerCoordinate" : 2, "digitsPerCoordinate" : 2,
......
...@@ -102,6 +102,11 @@ public class BehaviouralHeuristicsModel implements MainModel { ...@@ -102,6 +102,11 @@ public class BehaviouralHeuristicsModel implements MainModel {
@Override @Override
public void update(final double simTimeInSec) { public void update(final double simTimeInSec) {
// all those foot steps are done in previous sim time steps
for(PedestrianBHM ped : pedestrianEventsQueue) {
ped.clearFootSteps();
}
// event driven update // event driven update
if (!pedestrianEventsQueue.isEmpty()) { if (!pedestrianEventsQueue.isEmpty()) {
while (pedestrianEventsQueue.peek().getTimeOfNextStep() < simTimeInSec) { while (pedestrianEventsQueue.peek().getTimeOfNextStep() < simTimeInSec) {
......
...@@ -13,6 +13,7 @@ import org.vadere.state.scenario.Obstacle; ...@@ -13,6 +13,7 @@ import org.vadere.state.scenario.Obstacle;
import org.vadere.state.scenario.Pedestrian; import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Target; import org.vadere.state.scenario.Target;
import org.vadere.state.scenario.Topography; import org.vadere.state.scenario.Topography;
import org.vadere.state.simulation.FootStep;
import org.vadere.util.geometry.shapes.Vector2D; import org.vadere.util.geometry.shapes.Vector2D;
import org.vadere.util.geometry.shapes.VLine; import org.vadere.util.geometry.shapes.VLine;
import org.vadere.util.geometry.shapes.VPoint; import org.vadere.util.geometry.shapes.VPoint;
...@@ -152,9 +153,11 @@ public class PedestrianBHM extends Pedestrian { ...@@ -152,9 +153,11 @@ public class PedestrianBHM extends Pedestrian {
updateTargetDirection(); updateTargetDirection();
this.nextPosition = navigation.getNavigationPosition(); this.nextPosition = navigation.getNavigationPosition();
VPoint position = getPosition();
makeStep(); makeStep();
getFootSteps().add(new FootStep(position, getPosition(), timeOfNextStep, timeOfNextStep + durationNextStep));
this.timeOfNextStep = timeOfNextStep + durationNextStep; this.timeOfNextStep = timeOfNextStep + durationNextStep;
} }
......
...@@ -3,6 +3,7 @@ package org.vadere.simulator.models.bmm; ...@@ -3,6 +3,7 @@ package org.vadere.simulator.models.bmm;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.stream.Collectors;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.vadere.annotation.factories.models.ModelClass; import org.vadere.annotation.factories.models.ModelClass;
...@@ -15,6 +16,7 @@ import org.vadere.state.attributes.scenario.AttributesAgent; ...@@ -15,6 +16,7 @@ import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.scenario.DynamicElement; import org.vadere.state.scenario.DynamicElement;
import org.vadere.state.scenario.Pedestrian; import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Topography; import org.vadere.state.scenario.Topography;
import org.vadere.state.simulation.FootStep;
import org.vadere.util.geometry.shapes.VPoint; import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VShape; import org.vadere.util.geometry.shapes.VShape;
...@@ -92,6 +94,8 @@ public class BiomechanicsModel implements MainModel { ...@@ -92,6 +94,8 @@ public class BiomechanicsModel implements MainModel {
public void update(final double simTimeInSec) { public void update(final double simTimeInSec) {
double deltaTime = simTimeInSec - lastSimTimeInSec; double deltaTime = simTimeInSec - lastSimTimeInSec;
List<VPoint> positions = pedestriansBMM.stream().map(ped -> ped.getPosition()).collect(Collectors.toList());
for (PedestrianBMM agent : pedestriansBMM) { for (PedestrianBMM agent : pedestriansBMM) {
agent.update(simTimeInSec, deltaTime); agent.update(simTimeInSec, deltaTime);
} }
...@@ -104,6 +108,12 @@ public class BiomechanicsModel implements MainModel { ...@@ -104,6 +108,12 @@ public class BiomechanicsModel implements MainModel {
agent.reverseCollisions(); agent.reverseCollisions();
} }
for(int i = 0; i < pedestriansBMM.size(); i++) {
PedestrianBMM agent = pedestriansBMM.get(i);
agent.clearFootSteps();
agent.getFootSteps().add(new FootStep(positions.get(i), agent.getPosition(), lastSimTimeInSec, simTimeInSec));
}
this.lastSimTimeInSec = simTimeInSec; this.lastSimTimeInSec = simTimeInSec;
} }
......
package org.vadere.simulator.models.ode; package org.vadere.simulator.models.ode;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.stream.Collectors;
import org.apache.commons.math3.exception.MathIllegalNumberException; import org.apache.commons.math3.exception.MathIllegalNumberException;
import org.apache.commons.math3.ode.FirstOrderIntegrator; import org.apache.commons.math3.ode.FirstOrderIntegrator;
...@@ -13,6 +15,7 @@ import org.vadere.state.scenario.Car; ...@@ -13,6 +15,7 @@ import org.vadere.state.scenario.Car;
import org.vadere.state.scenario.DynamicElement; import org.vadere.state.scenario.DynamicElement;
import org.vadere.state.scenario.Pedestrian; import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Topography; import org.vadere.state.scenario.Topography;
import org.vadere.state.simulation.FootStep;
import org.vadere.state.types.ScenarioElementType; import org.vadere.state.types.ScenarioElementType;
import org.vadere.util.geometry.shapes.Vector2D; import org.vadere.util.geometry.shapes.Vector2D;
import org.vadere.util.geometry.shapes.VPoint; import org.vadere.util.geometry.shapes.VPoint;
...@@ -72,6 +75,9 @@ public abstract class ODEModel<T extends DynamicElement, TAttributes extends Att ...@@ -72,6 +75,9 @@ public abstract class ODEModel<T extends DynamicElement, TAttributes extends Att
// get pedestrian and car data // get pedestrian and car data
Collection<T> dynamicElements = topography.getElements(type); Collection<T> dynamicElements = topography.getElements(type);
List<T> orderedDynamicElements = topography.getElements(type).stream().collect(Collectors.toList());
List<VPoint> positions = orderedDynamicElements.stream().map(ped -> ped.getPosition()).collect(Collectors.toList());
double[] y; double[] y;
// if no peds are present, return // if no peds are present, return
...@@ -117,6 +123,15 @@ public abstract class ODEModel<T extends DynamicElement, TAttributes extends Att ...@@ -117,6 +123,15 @@ public abstract class ODEModel<T extends DynamicElement, TAttributes extends Att
} }
updateElementPositions(type, simTimeInSec, topography, equations, y); updateElementPositions(type, simTimeInSec, topography, equations, y);
for(int i = 0; i < orderedDynamicElements.size(); i++) {
DynamicElement element = orderedDynamicElements.get(i);
if (element.getType() == ScenarioElementType.PEDESTRIAN) {
Pedestrian pedestrian = (Pedestrian)element;
pedestrian.clearFootSteps();
pedestrian.getFootSteps().add(new FootStep(positions.get(i), pedestrian.getPosition(), lastSimTimeInSec, simTimeInSec));
}
}
} }
// reset the time // reset the time
...@@ -128,8 +143,7 @@ public abstract class ODEModel<T extends DynamicElement, TAttributes extends Att ...@@ -128,8 +143,7 @@ public abstract class ODEModel<T extends DynamicElement, TAttributes extends Att
* double vector. * double vector.
* The {@link AbstractModelEquations} are used to get the correct positions from the vector. * The {@link AbstractModelEquations} are used to get the correct positions from the vector.
*/ */
public static <T extends DynamicElement> void updateElementPositions(Class<T> type, double simTimeInSec, public static <T extends DynamicElement> void updateElementPositions(Class<T> type, double t, Topography topography, AbstractModelEquations equations, double[] y) {
Topography topography, AbstractModelEquations equations, double[] y) {
Collection<T> dynamicElements = topography.getElements(type); Collection<T> dynamicElements = topography.getElements(type);
......
...@@ -25,9 +25,8 @@ public class UpdateSchemeEventDriven implements UpdateSchemeOSM { ...@@ -25,9 +25,8 @@ public class UpdateSchemeEventDriven implements UpdateSchemeOSM {
@Override @Override
public void update(final double timeStepInSec, final double currentTimeInSec) { public void update(final double timeStepInSec, final double currentTimeInSec) {
for(PedestrianOSM pedestrianOSM : topography.getElements(PedestrianOSM.class)) {
pedestrianOSM.clearStrides(); clearStrides(topography);
}
if(!pedestrianEventsQueue.isEmpty()) { if(!pedestrianEventsQueue.isEmpty()) {
// event driven update ignores time credits! // event driven update ignores time credits!
......
...@@ -11,6 +11,7 @@ import org.vadere.state.scenario.DynamicElementAddListener; ...@@ -11,6 +11,7 @@ import org.vadere.state.scenario.DynamicElementAddListener;
import org.vadere.state.scenario.DynamicElementRemoveListener; import org.vadere.state.scenario.DynamicElementRemoveListener;
import org.vadere.state.scenario.Pedestrian; import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Topography; import org.vadere.state.scenario.Topography;
import org.vadere.state.simulation.FootStep;
import org.vadere.state.types.UpdateType; import org.vadere.state.types.UpdateType;
import org.vadere.util.geometry.shapes.Vector2D;