Commit 3c6d5114 authored by Petyo Bogdanov Ilov's avatar Petyo Bogdanov Ilov

ScenarioUpload with SimLang + AutopilotAdapter with RPC

parent 13c56764
......@@ -5,4 +5,4 @@
.directory
.idea
.idea/*
/target/
/target
......@@ -125,17 +125,28 @@
<artifactId>simulator</artifactId>
<version>${montisim.version}</version>
</dependency>
<!-- Autopilot -->
<dependency>
<groupId>montisim</groupId>
<artifactId>example-autopilot-ema</artifactId>
<version>0.0.5</version>
</dependency>
<!-- <dependency>
<groupId>montisim</groupId>
<dependency>
<groupId>montisim</groupId>
<artifactId>model-client</artifactId>
<version>1.0.1</version>
</dependency>
<!-- SimLong -->
<dependency>
<groupId>de.monticore.lang.montisim</groupId>
<artifactId>SimLang</artifactId>
<version>1.0.0</version>
</dependency> -->
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>de.monticore.lang.montisim</groupId>
<artifactId>Weather</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>
<!-- Set up profiles -->
<profiles>
......@@ -245,6 +256,18 @@
<goal>shade</goal>
</goals>
<configuration>
<!-- Exclude signatures -->
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>package rwth.server.extensions.ZoneExt</mainClass>
......
......@@ -15,13 +15,13 @@
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
<orderEntry type="library" name="Maven: sfs:sfs2x:2.13" level="project" />
<orderEntry type="library" name="Maven: sfs:sfs2x-core:2.13" level="project" />
<orderEntry type="library" name="Maven: montisim:commons:1.0.1" level="project" />
<orderEntry type="module" module-name="commons" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
<orderEntry type="library" name="Maven: montisim-controller:library:1.0.1" level="project" />
<orderEntry type="library" name="Maven: montisim-controller:control:1.0.1" level="project" />
<orderEntry type="library" name="Maven: montisim-controller:navigation:1.0.1" level="project" />
<orderEntry type="library" name="Maven: montisim-simulation:environment:1.0.1" level="project" />
<orderEntry type="library" name="Maven: montisim-simulation:util:1.0.1" level="project" />
<orderEntry type="module" module-name="library" />
<orderEntry type="module" module-name="control" />
<orderEntry type="module" module-name="navigation" />
<orderEntry type="module" module-name="environment" />
<orderEntry type="module" module-name="util" />
<orderEntry type="library" name="Maven: jfree:jfreechart:1.0.13" level="project" />
<orderEntry type="library" name="Maven: jfree:jcommon:1.0.16" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:osm4j-core:0.0.18" level="project" />
......@@ -32,7 +32,6 @@
<orderEntry type="library" name="Maven: de.topobyte:commons-cli-helper:0.0.3" level="project" />
<orderEntry type="library" name="Maven: commons-cli:commons-cli:1.3.1" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:melon-io:0.0.1" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:19.0" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:osm4j-xml:0.0.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.3.2" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:dynsax:0.0.1" level="project" />
......@@ -63,17 +62,17 @@
<orderEntry type="module-library">
<library name="Maven: com.sun:tools:1.4.2">
<CLASSES>
<root url="jar://C:/Program Files/Java/jdk1.8.0_102/jre/../lib/tools.jar!/" />
<root url="jar:///usr/lib/jvm/java-8-openjdk-amd64/jre/../lib/tools.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="Maven: montisim-simulation:vehicle:1.0.1" level="project" />
<orderEntry type="library" name="Maven: montisim-simulation:sensors:1.0.1" level="project" />
<orderEntry type="module" module-name="vehicle" />
<orderEntry type="module" module-name="sensors" />
<orderEntry type="library" name="Maven: com.jhlabs:filters:2.0.235-1" level="project" />
<orderEntry type="library" name="Maven: montisim-simulation:network:1.0.1" level="project" />
<orderEntry type="library" name="Maven: montisim-simulation:simulator:1.0.1" level="project" />
<orderEntry type="module" module-name="network" />
<orderEntry type="module" module-name="simulator" />
<orderEntry type="library" name="Maven: montisim:example-autopilot-ema:0.0.5" level="project" />
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.51" level="project" />
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib:1.1.51" level="project" />
......@@ -82,5 +81,44 @@
<orderEntry type="library" name="Maven: de.monticore.lang.monticar.ema2kt:runtime:0.0.5" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.1" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.1" level="project" />
<orderEntry type="library" name="Maven: de.monticore.lang.montisim:SimulationLanguage:1.0.1" level="project" />
<orderEntry type="library" name="Maven: de.se_rwth.commons:se-commons-logging:1.7.7" level="project" />
<orderEntry type="library" name="Maven: de.se_rwth.commons:se-commons-utilities:1.7.7" level="project" />
<orderEntry type="library" name="Maven: javax.inject:javax.inject:1" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:18.0" level="project" />
<orderEntry type="library" name="Maven: de.monticore:monticore-runtime:4.5.3-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.9" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.18.2-GA" level="project" />
<orderEntry type="library" name="Maven: com.google.code.findbugs:annotations:2.0.1" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.4" level="project" />
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.0" level="project" />
<orderEntry type="library" name="Maven: org.antlr:antlr4:4.5.1" level="project" />
<orderEntry type="library" name="Maven: org.freemarker:freemarker:2.3.23" level="project" />
<orderEntry type="library" name="Maven: de.monticore:monticore-grammar:4.5.3-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: de.monticore:monticore-emf-runtime:4.5.3-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.emf:org.eclipse.emf.compare:1.2.0" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.emf:org.eclipse.emf.compare.match:1.2.0" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.emf:org.eclipse.emf.compare.diff:1.2.0" level="project" />
<orderEntry type="library" name="Maven: org.mod4j.org.eclipse.emf:ecore:2.5.0" level="project" />
<orderEntry type="library" name="Maven: org.mod4j.org.eclipse.core:runtime:3.5.0" level="project" />
<orderEntry type="library" name="Maven: org.mod4j.org.eclipse:osgi:3.5.0" level="project" />
<orderEntry type="library" name="Maven: org.mod4j.org.eclipse.equinox:common:3.5.0" level="project" />
<orderEntry type="library" name="Maven: org.mod4j.org.eclipse.core:jobs:3.4.100" level="project" />
<orderEntry type="library" name="Maven: org.mod4j.org.eclipse.equinox:registry:3.4.100" level="project" />
<orderEntry type="library" name="Maven: org.mod4j.org.eclipse.equinox:preferences:3.2.300" level="project" />
<orderEntry type="library" name="Maven: org.mod4j.org.eclipse.core:contenttype:3.4.0" level="project" />
<orderEntry type="library" name="Maven: org.mod4j.org.eclipse.equinox:app:1.2.0" level="project" />
<orderEntry type="library" name="Maven: org.mod4j.org.eclipse.emf.ecore:xmi:2.5.0" level="project" />
<orderEntry type="library" name="Maven: org.mod4j.org.eclipse.emf:common:2.5.0" level="project" />
<orderEntry type="library" name="Maven: de.se_rwth.commons:se-commons-groovy:1.7.7" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.groovy:groovy:2.3.7" level="project" />
<orderEntry type="library" name="Maven: jline:jline:2.12" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.1.2" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.1.2" level="project" />
<orderEntry type="library" name="Maven: org.jscience:jscience:4.3.1" level="project" />
<orderEntry type="library" name="Maven: org.javolution:javolution:5.2.3" level="project" />
<orderEntry type="library" name="Maven: org.antlr:antlr4-runtime:4.5.1" level="project" />
<orderEntry type="library" name="Maven: de.monticore.lang.monticar:common-monticar:0.0.10-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: de.monticore.lang:NumberUnit:0.0.10-SNAPSHOT" level="project" />
</component>
</module>
\ No newline at end of file
......@@ -59,6 +59,7 @@ public class WorldBuilder {
registerOverlappingAreas(sectors, overlap);
assignWorldToSectors(worldMap, mapId);
sectorsList = getSectorsAsList(sectors);
} catch (Exception e) {
console.trace(ExtensionLogLevel.ERROR, e);
}
......@@ -226,13 +227,48 @@ public class WorldBuilder {
}
/**
* Creates a MapArea object from primitive coordinates.
*
* @param minX
* @param minY
* @param maxX
* @param maxY
* @param minZ
* @param maxZ
* @return the created MapArea object
*/
private MapArea createArea(double minX, double minY, double maxX, double maxY, double minZ, double maxZ) {
Integer areaId = sectBo.addArea(minX, maxX, minY, maxY, minZ, maxZ);
return new MapArea(areaId, minX, minY, maxX, maxY, minZ, maxZ);
}
/**
* Returns a list of MapSectors by looping a given grid (two-dimensional array).
*
* @param sectors
* @return
*/
private List<MapSector> getSectorsAsList(MapSector[][] sectors) {
List<MapSector> list = new ArrayList<MapSector>();
for(int x=0; x<sectors.length; ++x) {
for(int y=0; y<sectors[x].length; ++y) {
list.add(sectors[x][y]);
}
}
return list;
}
//serialization
/**
* Return world data as SFSObject.
*
* @param world
* @return
*/
public SFSObject getSFSWorld(VisualisationEnvironmentContainer world) {
SFSObject sfsWorld = new SFSObject();
......@@ -262,6 +298,12 @@ public class WorldBuilder {
return sfsBuildings;
}
/**
* Returns the representation of given streets as SFSArray.
*
* @param streets
* @return
*/
private ISFSArray getSFSStreets(Collection<EnvStreet> streets) {
SFSArray sfsStreets = new SFSArray();
......@@ -277,6 +319,12 @@ public class WorldBuilder {
return sfsStreets;
}
/**
* Returns the representation of given nodes as SFSArray.
*
* @param nodes
* @return
*/
private ISFSArray getSFSNodes(List<EnvNode> nodes) {
SFSArray sfsNodes = new SFSArray();
......@@ -296,6 +344,12 @@ public class WorldBuilder {
return sfsNodes;
}
/**
* Returns the SFSObject representation of given StreetSign.
*
* @param streetSign
* @return
*/
private SFSObject getSFSStreetSign(StreetSign streetSign) {
SFSObject result = new SFSObject();
......@@ -315,6 +369,12 @@ public class WorldBuilder {
return result;
}
/**
* Returns SFSObject representation of given Boundaries.
*
* @param bounds
* @return
*/
private SFSObject getSFSBounds(EnvBounds bounds) {
SFSObject sfsBounds = new SFSObject();
......
......@@ -83,6 +83,9 @@ public class ZoneExt extends SFSExtension {
//Business Logic services
private ScenarioBO scenarioBo;
//Services
ScenarioUpload scenUpload;
@Override
/**
* Initialize current extension class
......@@ -98,10 +101,18 @@ public class ZoneExt extends SFSExtension {
initWorld(getConfigProperties());
} catch (Exception e) {
trace(ExtensionLogLevel.ERROR, "Failed to initialize the world: " + e);
e.printStackTrace();
}
//initialize Business logic objects
//initialize Business logic objects and services
this.scenarioBo = new ScenarioBO();
this.scenUpload = new ScenarioUpload(
new PathFinder(
this.sectors,
new WeatherSettings(this.isRainy ? Weather.RAIN : Weather.SUNSHINE),
this.mapId
)
);
//handle custom login
// addEventHandler(SFSEventType.USER_LOGIN, LoginHandler.class);
......@@ -115,8 +126,15 @@ public class ZoneExt extends SFSExtension {
public void handleServerEvent(ISFSEvent event) throws Exception {
switch(event.getType()) {
case FILE_UPLOAD:
ScenarioUpload.getInstance()
.uploadScenario((List<UploadedFile>) event.getParameter(SFSEventParam.UPLOAD_FILE_LIST));
SimulationScenario scenario = this.scenUpload.parseScenario(
(List<UploadedFile>) event.getParameter(SFSEventParam.UPLOAD_FILE_LIST));
//save scenario in DB
if(scenario == null) return;
this.scenarioBo.add(scenario.getName(), this.mapId, scenario.getTracks());
//send updated scenario list to user
send(GET_SCENARIOS, getScenarios(), (User) event.getParameter(SFSEventParam.USER));
break;
default:;
}
......@@ -212,7 +230,7 @@ public class ZoneExt extends SFSExtension {
this.mapId = mapBo.add(mapName, mapSrc);
//split map on sectors
this.sectors = WorldBuilder.getInstance().buildWorld(sectorSize, this.overlap, worldMap, this.mapId);
trace("Map parsed and saved in DB for: " + (new Date().getTime() - startAt) + "ms");
trace("Map parsed and saved in DB for: " + (new Date().getTime() - startAt)/1000f + "s");
trace("Cache entry nodes and build path matrix...");
//cache entry nodes and paths
......@@ -416,6 +434,6 @@ public class ZoneExt extends SFSExtension {
}
this.scenarioBo.add(scenarioName, this.mapId, scenTracks);
//update user's scenario list
send(GET_SCENARIOS, getScenarios(), user);
if(user != null) send(GET_SCENARIOS, getScenarios(), user);
}
}
......@@ -9,6 +9,7 @@ import commons.simulation.PhysicalObject;
import commons.simulation.SimulationLoopExecutable;
import commons.simulation.SimulationLoopNotifiable;
import databus.DataBus;
import de.rwth.modelling.client.SimpleClient;
import functionBlock.ConnectionEntry;
import functionBlock.FunctionBlock;
import javafx.geometry.Point3D;
......@@ -19,8 +20,9 @@ import rwth.server.bo.EnvObjectBO;
import rwth.server.bo.util.Logger;
import rwth.server.pathfinder.NavigationPath;
import rwth.server.pojo.ScenarioTrack;
import rwth.server.simulation.adapters.AutopilotAdapter;
import rwth.server.simulation.adapters.AutopilotAdapterAsFunctionBlock;
import sensors.StaticPlannedTrajectoryXSensor;
import sensors.StaticPlannedTrajectoryYSensor;
import sensors.util.SensorUtil;
import simulation.environment.WorldModel;
import simulation.environment.object.House;
......@@ -37,6 +39,7 @@ import simulation.simulator.Simulator;
import simulation.vehicle.PhysicalVehicle;
import simulation.vehicle.PhysicalVehicleBuilder;
import simulation.vehicle.RandomStatusLogger;
import simulation.vehicle.Vehicle;
import structures.Graph;
public class SimulationController implements SimulationLoopNotifiable {
......@@ -289,7 +292,7 @@ public class SimulationController implements SimulationLoopNotifiable {
PhysicalVehicleBuilder vehicleBuilder = PhysicalVehicleBuilder.getInstance();
vehicleBuilder.resetPhysicalVehicle();
AutopilotAdapterAsFunctionBlock mainBlockAdapter = new AutopilotAdapterAsFunctionBlock(new AutopilotAdapter());
AutopilotAdapterAsFunctionBlock mainBlockAdapter = new AutopilotAdapterAsFunctionBlock(new SimpleClient("localhost", 10247));
PhysicalVehicle physicalVehicle = vehicleBuilder.buildPhysicalVehicle(
Optional.of(new DataBus()),
Optional.of(mainBlockAdapter),
......@@ -316,7 +319,7 @@ public class SimulationController implements SimulationLoopNotifiable {
//prepare rough trajectory
List<Vertex> trajectory = getTrajectory(startNode, endNode);
PhysicalVehicle pVehicle = setupDefaultVehicle();
PhysicalVehicle pVehicle = setupVehicle();//setupDefaultVehicle();
this.simulation.registerAndPutObject(pVehicle,
startNode.getX().doubleValue(),
......@@ -324,14 +327,14 @@ public class SimulationController implements SimulationLoopNotifiable {
getRotation(trajectory)
);
pVehicle.getSimulationVehicle().navigateTo(endNode);
//Basic model
// pVehicle.getSimulationVehicle().navigateTo(endNode);
//Vehicle simVehicle = pVehicle.getSimulationVehicle();
//Map<String, List<Double>> trajectoryCoordinates = getTrajectoryCoordinates(trajectory);
//simVehicle.addSensor(new StaticPlannedTrajectoryXSensor(trajectoryCoordinates.get("x")));
//simVehicle.addSensor(new StaticPlannedTrajectoryYSensor(trajectoryCoordinates.get("y")));
//Autopilot model
Vehicle simVehicle = pVehicle.getSimulationVehicle();
Map<String, List<Double>> trajectoryCoordinates = getTrajectoryCoordinates(trajectory);
simVehicle.addSensor(new StaticPlannedTrajectoryXSensor(trajectoryCoordinates.get("x")));
simVehicle.addSensor(new StaticPlannedTrajectoryYSensor(trajectoryCoordinates.get("y")));
return pVehicle.getId();
}
......
package rwth.server.simulation.adapters;
/**
* JNI binding to a CPP class generated for the native model.
*
* @author Alexander Ryndin
*/
public final class AutopilotAdapter {
static {
// make sure the corresponding DLL is on the classpath
// when the java app with simulation is started
System.loadLibrary("AutopilotAdapter");
}
private boolean isInitialized = false;
public void execute() {
initialize();
exec();
}
public void initialize() {
if (!isInitialized) {
init();
isInitialized = true;
}
}
public native void set_timeIncrement(double timeIncrement);
public native void set_currentVelocity(double currentVelocity);
public native void set_x(double currentGpsLat);
public native void set_y(double currentGpsLon);
public native void set_compass(double compass);
public native void set_currentEngine(double currentEngine);
public native void set_currentSteering(double currentSteering);
public native void set_currentBrakes(double currentBrakes);
public native void set_trajectory_length(int length);
public native void set_trajectory_x(double[] x);
public native void set_trajectory_y(double[] y);
public native double get_engine();
public native double get_steering();
public native double get_brakes();
private native void exec();
private native void init();
}
\ No newline at end of file
......@@ -2,6 +2,10 @@ package rwth.server.simulation.adapters;
import commons.controller.commons.BusEntry;
import commons.controller.interfaces.FunctionBlockInterface;
import de.rwth.modelling.client.SimpleClient;
import de.rwth.modelling.client.model.Inputs;
import de.rwth.modelling.client.model.Outputs;
import org.apache.commons.math3.linear.RealVector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -13,22 +17,23 @@ import java.util.List;
import java.util.Map;
/**
* Wraps {@link AutopilotAdapter} and implements {@link FunctionBlockInterface}.
*
* @author Alexander Ryndin
*/
public class AutopilotAdapterAsFunctionBlock implements FunctionBlockInterface {
private static final Logger LOG = LoggerFactory.getLogger(AutopilotAdapter.class);
private static final Logger LOG = LoggerFactory.getLogger(AutopilotAdapterAsFunctionBlock.class);
private static final int MAX_TRAJECTORY_LENGTH = 100;
private final AutopilotAdapter adapter;
private final SimpleClient client;
private final double[] trajectoryX = new double[MAX_TRAJECTORY_LENGTH];
private final double[] trajectoryY = new double[MAX_TRAJECTORY_LENGTH];
private PhysicalVehicle vehicle;
public AutopilotAdapterAsFunctionBlock(AutopilotAdapter adapter) {
this.adapter = adapter;
private Inputs modelInputs = new Inputs();
private Outputs modelOutputs;
public AutopilotAdapterAsFunctionBlock(SimpleClient client) {
this.client = client;
}
public void setVehicle(PhysicalVehicle vehicle) {
......@@ -41,12 +46,11 @@ public class AutopilotAdapterAsFunctionBlock implements FunctionBlockInterface {
@Override
public void execute() {
adapter.execute();
modelOutputs = client.executeModel(modelInputs);
}
@Override
public void setInputs(Map<String, Object> inputs) {
adapter.initialize();
double timeIncrement = (Double) inputs.get(BusEntry.SIMULATION_DELTA_TIME.toString());
double currentVelocity = (Double) inputs.get(BusEntry.SENSOR_VELOCITY.toString());
RealVector gps = (RealVector) inputs.get(BusEntry.SENSOR_GPS_COORDINATES.toString());
......@@ -59,31 +63,30 @@ public class AutopilotAdapterAsFunctionBlock implements FunctionBlockInterface {
LOG.debug("velocity " + currentVelocity);
LOG.debug("position " + x + " " + y);
LOG.debug("actuation " + brakes + " " + engine + " " + steering);
adapter.set_timeIncrement(timeIncrement);
adapter.set_currentVelocity(currentVelocity);
adapter.set_x(x);
adapter.set_y(y);
adapter.set_compass(compass);
adapter.set_currentEngine(engine);
adapter.set_currentSteering(steering);
adapter.set_currentBrakes(brakes);
modelInputs.setTimeIncrement(timeIncrement);
modelInputs.setCurrentVelocity(currentVelocity);
modelInputs.setX(x);
modelInputs.setY(y);
modelInputs.setCompass(compass);
modelInputs.setCurrentEngine(engine);
modelInputs.setCurrentSteering(steering);
modelInputs.setCurrentBrakes(brakes);
Object ptx = inputs.get(BusEntry.PLANNED_TRAJECTORY_X.toString());
Object pty = inputs.get(BusEntry.PLANNED_TRAJECTORY_Y.toString());
if (ptx instanceof List<?> && pty instanceof List<?>) {
int trajectoryLength = processTrajectory((List<Double>) ptx, (List<Double>) pty);
adapter.set_trajectory_length(trajectoryLength);
modelInputs.setTrajectoryLength(trajectoryLength);
} else {
LOG.error("planned trajectory is not provided");
adapter.set_trajectory_length(0);
modelInputs.setTrajectoryLength(0);
}
}
@Override
public Map<String, Object> getOutputs() {
adapter.initialize();
double engine = adapter.get_engine();
double brakes = adapter.get_brakes();
double steering = adapter.get_steering();
double engine = modelOutputs.getEngine();
double brakes = modelOutputs.getBrakes();
double steering = modelOutputs.getSteeringAngle();
Map<String, Object> result = new HashMap<>();
result.put(
BusEntry.ACTUATOR_ENGINE.toString(),
......@@ -146,8 +149,8 @@ public class AutopilotAdapterAsFunctionBlock implements FunctionBlockInterface {
trajectoryY[i] = y;
}
logTrajectory(len);
adapter.set_trajectory_x(trajectoryX);
adapter.set_trajectory_y(trajectoryY);
modelInputs.setTrajectoryX(trajectoryX);
modelInputs.setTrajectoryY(trajectoryY);
return len;
}
......
package rwth.server.upload;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.FileUtils;
import org.apache.commons.math3.linear.ArrayRealVector;
import org.apache.commons.math3.linear.RealVector;
import com.smartfoxserver.v2.extensions.ExtensionLogLevel;
import com.smartfoxserver.v2.util.UploadedFile;
import commons.controller.commons.Vertex;
import de.monticore.lang.montisim.simlang.SimLangTool;
import de.monticore.lang.montisim.simlang.adapter.SLMontiSimAdapter;
import de.monticore.lang.montisim.simlang.util.ExplicitVehicle;
import de.monticore.lang.montisim.simlang.util.Path2D;
import functionBlock.ConnectionEntry;
import navigationBlock.components.LocateNearestVertexInGraph;
import rwth.server.bo.EnvObjectBO;
import rwth.server.bo.util.Logger;
import rwth.server.pathfinder.NavigationPath;
import rwth.server.pathfinder.PathFinder;
import rwth.server.pojo.ScenarioTrack;
import rwth.server.pojo.SimulationScenario;
import simulation.environment.WorldModel;
import simulation.environment.osm.ParserSettings;
import simulation.environment.osm.ParserSettings.ZCoordinates;
import simulation.environment.visualisationadapter.interfaces.VisualisationEnvironmentContainer;
import simulation.environment.weather.Weather;
import simulation.environment.weather.WeatherSettings;
import structures.Graph;
/**
* Service class, taking care of parsing and preparing SimulationScenario
* from given configuration and OSM map files.
*
* @author petyo
*/
public class ScenarioUpload {
private static ScenarioUpload instance;
private final String UPL_EXT = ".upload.dat";
private final String SIM_EXT = ".sim";
private final String OSM_EXT = ".osm";
private Logger console;
private ScenarioUpload() {
this.console = Logger.getInstance();
}
private PathFinder pathFinder;
private EnvObjectBO eoBo;
public static ScenarioUpload getInstance() {
return instance == null ? instance = new ScenarioUpload() : instance;
public ScenarioUpload(PathFinder pathFinder) {
this.pathFinder = pathFinder;
this.eoBo = new EnvObjectBO();
this.console = Logger.getInstance();
}