...
 
Commits (2)
......@@ -8,7 +8,7 @@ from vadere_analysis_tool.analysis import OriginDeviation
def run_scenario_files_with_vadere_console(scenario_files, vadere_console="VadereSimulator/target/vadere-console.jar",
scenario_timeout_in_sec=60):
scenario_timeout_in_sec=60*5):
output_dir = "Tools/ContinuousIntegration/run_orign_translation_test.d/output"
if os.path.exists(output_dir):
......@@ -61,16 +61,16 @@ def run_scenario_files_with_vadere_console(scenario_files, vadere_console="Vader
return {"passed": passed_scenarios, "failed": failed_scenarios_with_exception}
def get_output_pairs(path="Tools/ContinuousIntegration/run_orign_translation_test.d/output"):
_output_pairs = []
output_without_offset = [d for d in os.listdir(path) if d.endswith("without_offset")]
for dir_without in output_without_offset:
dir_with_offset = dir_without.replace("without_offset", "with_offset")
name = dir_with_offset[:-len("without_offset")]
pair = [os.path.join(path, dir_without), os.path.join(path, dir_with_offset)]
_output_pairs.append(OriginDeviation(pair, name))
return _output_pairs
#def get_output_pairs(path="Tools/ContinuousIntegration/run_orign_translation_test.d/output"):
# _output_pairs = []
# output_without_offset = [d for d in os.listdir(path) if d.endswith("without_offset")]
# for dir_without in output_without_offset:
# dir_with_offset = dir_without.replace("without_offset", "with_offset")
# name = dir_with_offset[:-len("without_offset")]
# pair = [os.path.join(path, dir_without), os.path.join(path, dir_with_offset)]
# _output_pairs.append(OriginDeviation(pair, name))
#
# return _output_pairs
def run_simulations(test_project_path):
......@@ -86,9 +86,9 @@ def run_simulations(test_project_path):
if __name__ == '__main__':
test_project_path = "Tools/ContinuousIntegration/run_orign_translation_test.d"
# run_simulations(test_project_path)
# run_simulations(test_project_path)
output_pairs = get_output_pairs()
output_pairs = OriginDeviation.create_origin_deviation_pairs_from_project(project_path=test_project_path)
print("comparing {} output pairs".format(len(output_pairs)))
# results = [pair.get_origin_deviation_result() for pair in output_pairs]
return_val = 0
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -8,4 +8,4 @@ pyparsing==2.3.0
python-dateutil==2.7.5
pytz==2018.7
six==1.11.0
VadereAnalysisTool==0.0.4
VadereAnalysisTool==0.1.0
......@@ -12,7 +12,7 @@ import org.vadere.gui.components.model.IDefaultModel;
import org.vadere.gui.projectview.view.JsonValidIndicator;
import org.vadere.gui.projectview.view.ProjectView;
import org.vadere.gui.projectview.view.ScenarioPanel;
import org.vadere.gui.topographycreator.model.AgentWrapper;
import org.vadere.simulator.utils.builder.topography.AgentWrapper;
import org.vadere.gui.topographycreator.model.TopographyCreatorModel;
import org.vadere.state.attributes.Attributes;
import org.vadere.state.scenario.Pedestrian;
......
......@@ -7,7 +7,7 @@ import java.awt.geom.Rectangle2D;
import javax.swing.undo.UndoableEdit;
import javax.swing.undo.UndoableEditSupport;
import org.vadere.gui.topographycreator.model.AgentWrapper;
import org.vadere.simulator.utils.builder.topography.AgentWrapper;
import org.vadere.gui.topographycreator.model.IDrawPanelModel;
import org.vadere.state.scenario.ScenarioElement;
import org.vadere.util.geometry.shapes.VCircle;
......
......@@ -5,6 +5,7 @@ import javax.swing.undo.CannotRedoException;
import javax.swing.undo.CannotUndoException;
import org.vadere.gui.topographycreator.model.IDrawPanelModel;
import org.vadere.simulator.utils.builder.topography.AttributeModifier;
import org.vadere.state.scenario.ScenarioElement;
import org.vadere.util.geometry.shapes.VShape;
......
......@@ -9,6 +9,7 @@ import javax.swing.undo.UndoableEditSupport;
import org.vadere.gui.components.control.DefaultSelectionMode;
import org.vadere.gui.components.control.IMode;
import org.vadere.gui.topographycreator.model.IDrawPanelModel;
import org.vadere.simulator.utils.builder.topography.AttributeModifier;
import org.vadere.state.scenario.ScenarioElement;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VShape;
......
......@@ -15,6 +15,8 @@ import org.vadere.gui.components.control.IMode;
import org.vadere.gui.components.model.DefaultConfig;
import org.vadere.gui.components.model.DefaultModel;
import org.vadere.simulator.projects.Scenario;
import org.vadere.simulator.utils.builder.topography.AgentWrapper;
import org.vadere.simulator.utils.builder.topography.TopographyBuilder;
import org.vadere.state.attributes.scenario.AttributesTopography;
import org.vadere.state.scenario.Obstacle;
import org.vadere.state.scenario.ScenarioElement;
......@@ -235,14 +237,7 @@ public class TopographyCreatorModel extends DefaultModel implements IDrawPanelMo
@Override
public void setTopographyBound(final VRectangle scenarioBound) {
try {
Field field = AttributesTopography.class.getDeclaredField("bounds");
field.setAccessible(true);
field.set(topographyBuilder.getAttributes(), scenarioBound);
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
topographyBuilder.getAttributes().setBounds(scenarioBound);
boundId++;
calculateScaleFactor();
setChanged();
......
package org.vadere.gui.topographycreator.model;
import org.vadere.simulator.utils.builder.topography.AgentWrapper;
import org.vadere.state.attributes.Attributes;
import org.vadere.state.attributes.scenario.AttributesObstacle;
import org.vadere.state.attributes.scenario.AttributesSource;
......
......@@ -14,10 +14,12 @@ import org.apache.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.vadere.simulator.projects.dataprocessing.DataProcessingJsonManager;
import org.vadere.simulator.projects.io.JsonConverter;
import org.vadere.simulator.utils.builder.topography.TopographyBuilder;
import org.vadere.state.attributes.Attributes;
import org.vadere.state.attributes.AttributesSimulation;
import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.scenario.Topography;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.io.IOUtils;
import org.vadere.util.reflection.VadereClassNotFoundException;
......@@ -32,6 +34,7 @@ import difflib.DiffUtils;
*/
public class Scenario {
private static Logger logger = LogManager.getLogger(Scenario.class);
private ScenarioStore scenarioStore;
private ScenarioStore simulationScenarioStore;
......@@ -66,12 +69,19 @@ public class Scenario {
public void setSimulationRunning(boolean simulationRunning) {
if (simulationRunning){
simulationScenarioStore = copyScenarioStore();
setSimulationOrigin(0.0, 0.0);
} else {
simulationScenarioStore = null;
}
this.simulationRunning = simulationRunning;
}
public void setSimulationOrigin(double x, double y){
TopographyBuilder builder = new TopographyBuilder(getScenarioStore().getTopography());
builder.setOrigin(x, y);
simulationScenarioStore.setTopography(builder.build());
}
public ScenarioStore copyScenarioStore() {
try {
return JsonConverter.cloneScenarioStore(this.scenarioStore);
......
......@@ -95,7 +95,7 @@ public class ScenarioRun implements Runnable {
scenarioStore.getTopography().reset();
logger.info("StartIt " + scenario.getName());
MainModelBuilder modelBuilder = new MainModelBuilder(scenarioStore);
modelBuilder.createModelAndRandom();
modelBuilder.createModelAndRandom(); // save selected seed in output-scenario file
final MainModel mainModel = modelBuilder.getModel();
final Random random = modelBuilder.getRandom();
......
......@@ -31,11 +31,21 @@ public class PedestrianPositionProcessor extends DataProcessor<TimestepPedestria
@Override
protected void doUpdate(final SimulationState state) {
Integer timeStep = state.getStep();
VPoint offset = new VPoint(0,0);
if (state.getName().contains("_with_offset")){
offset = new VPoint(564280.000000, 5933391.000000);
}
for (Pedestrian p : state.getTopography().getElements(Pedestrian.class)) {
this.putValue(new TimestepPedestrianIdKey(timeStep, p.getId()), p.getPosition());
this.putValue(new TimestepPedestrianIdKey(timeStep, p.getId()), getPosition(offset, p));
}
}
private VPoint getPosition(VPoint offset, Pedestrian p){
return p.getPosition().add(offset);
}
@Override
public void init(final ProcessorManager manager) {
super.init(manager);
......
......@@ -71,7 +71,8 @@ public class JsonConverter {
return null;
}
public static String serializeScenarioRunManager(Scenario scenarioRunManager, boolean commitHashIncluded)
public static String
serializeScenarioRunManager(Scenario scenarioRunManager, boolean commitHashIncluded)
throws IOException {
return StateJsonConverter.writeValueAsString(serializeScenarioRunManagerToNode(scenarioRunManager, commitHashIncluded));
}
......
package org.vadere.gui.topographycreator.model;
package org.vadere.simulator.utils.builder.topography;
import java.util.LinkedList;
import java.util.Random;
......@@ -25,6 +25,7 @@ public final class AgentWrapper extends ScenarioElement {
/** The wrapped store object. */
private Agent agent;
public
AgentWrapper(final VPoint position) {
// use a Pedestrian as default
// TODO this default does not make much sense
......
package org.vadere.gui.topographycreator.control;
package org.vadere.simulator.utils.builder.topography;
import org.vadere.gui.topographycreator.model.AgentWrapper;
import org.vadere.simulator.utils.builder.topography.AgentWrapper;
import org.vadere.state.attributes.AttributesEmbedShape;
import org.vadere.state.scenario.ScenarioElement;
import org.vadere.util.geometry.shapes.VPoint;
......
package org.vadere.gui.topographycreator.model;
package org.vadere.simulator.utils.builder.topography;
import java.awt.geom.Rectangle2D;
import java.lang.reflect.Field;
......@@ -8,7 +8,6 @@ import java.util.List;
import java.util.function.Predicate;
import org.jetbrains.annotations.NotNull;
import org.vadere.gui.topographycreator.control.AttributeModifier;
import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.attributes.scenario.AttributesCar;
import org.vadere.state.attributes.scenario.AttributesTopography;
......@@ -21,6 +20,7 @@ import org.vadere.state.scenario.Target;
import org.vadere.state.scenario.Teleporter;
import org.vadere.state.scenario.Topography;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VRectangle;
import org.vadere.util.geometry.shapes.VShape;
/**
......@@ -141,6 +141,15 @@ public class TopographyBuilder implements Iterable<ScenarioElement> {
return topography;
}
public void setOrigin(double x, double y){
double oldX = this.attributes.getBounds().x;
double oldY = this.attributes.getBounds().y;
double width = this.attributes.getBounds().width;
double height = this.attributes.getBounds().height;
translateElements(x - oldX, y - oldY);
this.attributes.setBounds(new VRectangle(x, y, width, height));
}
public void translateElements(final double x, final double y) {
for(ScenarioElement element : topographyElements) {
VShape shape = element.getShape().translate(new VPoint(x, y));
......