Commit 9c61f815 authored by Tobias Meuser's avatar Tobias Meuser
Browse files

Merge branch 'tm/sumo-integration' into tm/vehicular-services

parents 120c157a 9bd14638
...@@ -24,7 +24,6 @@ import java.util.HashMap; ...@@ -24,7 +24,6 @@ import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import de.tud.kom.p2psim.api.network.SimNetInterface; import de.tud.kom.p2psim.api.network.SimNetInterface;
import de.tud.kom.p2psim.api.topology.movement.MovementModel; import de.tud.kom.p2psim.api.topology.movement.MovementModel;
...@@ -33,23 +32,14 @@ import de.tud.kom.p2psim.impl.network.routed.RoutedNetLayer; ...@@ -33,23 +32,14 @@ import de.tud.kom.p2psim.impl.network.routed.RoutedNetLayer;
import de.tud.kom.p2psim.impl.topology.PositionVector; import de.tud.kom.p2psim.impl.topology.PositionVector;
import de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.traci.TraciSimulationController; import de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.traci.TraciSimulationController;
import de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.xml.XMLSimulationController; import de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.xml.XMLSimulationController;
import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.Time; import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.common.graph.INodeID; import de.tudarmstadt.maki.simonstrator.api.common.graph.INodeID;
import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException; import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.future_location.FutureLocationSensor;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location; import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent;
import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSDataCallback;
import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSInfoProperties;
import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSInformationProvider.SiSProviderHandle;
import de.tudarmstadt.maki.simonstrator.api.component.sis.exception.InformationNotAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.sis.type.SiSTypes;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.SimulationSetupExtractor; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.SimulationSetupExtractor;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.information.Position;
import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor; import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
public class RSUMovementModel implements MovementModel, FutureLocationSensor { public class RSUMovementModel implements MovementModel {
private final List<SimLocationActuator> components; private final List<SimLocationActuator> components;
...@@ -69,7 +59,7 @@ public class RSUMovementModel implements MovementModel, FutureLocationSensor { ...@@ -69,7 +59,7 @@ public class RSUMovementModel implements MovementModel, FutureLocationSensor {
private SimulationSetupExtractor _controller; private SimulationSetupExtractor _controller;
private List<Position> _intersections; private List<Location> _intersections;
private int _currentIndex = 0; private int _currentIndex = 0;
private final Map<INodeID, Integer> hostIntersectionMatching = new HashMap<>(); private final Map<INodeID, Integer> hostIntersectionMatching = new HashMap<>();
...@@ -107,40 +97,6 @@ public class RSUMovementModel implements MovementModel, FutureLocationSensor { ...@@ -107,40 +97,6 @@ public class RSUMovementModel implements MovementModel, FutureLocationSensor {
@Override @Override
public final void addComponent(SimLocationActuator comp) { public final void addComponent(SimLocationActuator comp) {
components.add(comp); components.add(comp);
try {
final SiSComponent sis = comp.getHost().getComponent(SiSComponent.class);
sis.provide().nodeState(SiSTypes.FUTURE_PHY_LOCATION,
new SiSDataCallback<Location>() {
Set<INodeID> localID = INodeID
.getSingleIDSet(comp.getHost().getId());
@Override
public Location getValue(INodeID nodeID,
SiSProviderHandle providerHandle)
throws InformationNotAvailableException {
if (nodeID.equals(comp.getHost().getId())) {
return getFutureLocation(comp.getHost());
} else {
throw new InformationNotAvailableException();
}
}
@Override
public Set<INodeID> getObservedNodes() {
return localID;
}
@Override
public SiSInfoProperties getInfoProperties() {
return new SiSInfoProperties();
}
});
} catch (ComponentNotAvailableException e) {
// Nothing to do
}
} }
@Override @Override
...@@ -156,8 +112,8 @@ public class RSUMovementModel implements MovementModel, FutureLocationSensor { ...@@ -156,8 +112,8 @@ public class RSUMovementModel implements MovementModel, FutureLocationSensor {
} }
if (_currentIndex < _intersections.size()) { if (_currentIndex < _intersections.size()) {
// Initial placement // Initial placement
Position intersection = _intersections.get(_currentIndex); Location intersection = _intersections.get(_currentIndex);
actuator.updateCurrentLocation(new PositionVector(intersection.getX(), intersection.getY())); actuator.updateCurrentLocation(new PositionVector(intersection.getLongitude(), intersection.getLatitude()));
hostIntersectionMatching.put(actuator.getHost().getId(), _currentIndex); hostIntersectionMatching.put(actuator.getHost().getId(), _currentIndex);
...@@ -198,17 +154,4 @@ public class RSUMovementModel implements MovementModel, FutureLocationSensor { ...@@ -198,17 +154,4 @@ public class RSUMovementModel implements MovementModel, FutureLocationSensor {
// System.out.println("Require " + _intersections.size() + " RSUs"); // System.out.println("Require " + _intersections.size() + " RSUs");
} }
@Override
public Location getFutureLocation(Host pHost) {
if (hostIntersectionMatching.containsKey(pHost.getId())) {
int intersection = hostIntersectionMatching.get(pHost.getId());
Position intersectionPosition = _intersections.get(intersection);
if (intersectionPosition != null) {
return new PositionVector(intersectionPosition.getX(), intersectionPosition.getY());
}
}
return null;
}
} }
\ No newline at end of file
...@@ -26,7 +26,6 @@ import java.util.LinkedList; ...@@ -26,7 +26,6 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Queue; import java.util.Queue;
import java.util.Set;
import de.tud.kom.p2psim.api.network.SimNetInterface; import de.tud.kom.p2psim.api.network.SimNetInterface;
import de.tud.kom.p2psim.api.topology.movement.MovementModel; import de.tud.kom.p2psim.api.topology.movement.MovementModel;
...@@ -42,22 +41,14 @@ import de.tudarmstadt.maki.simonstrator.api.Host; ...@@ -42,22 +41,14 @@ import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.Time; import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.common.graph.INodeID; import de.tudarmstadt.maki.simonstrator.api.common.graph.INodeID;
import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException; import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.future_location.FutureLocationSensor;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location; import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent;
import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSDataCallback;
import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSInfoProperties;
import de.tudarmstadt.maki.simonstrator.api.component.sis.SiSInformationProvider.SiSProviderHandle;
import de.tudarmstadt.maki.simonstrator.api.component.sis.exception.InformationNotAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.sis.type.SiSTypes;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.VehicleInformationComponent; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.VehicleInformationComponent;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.SimulationSetupExtractor; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.SimulationSetupExtractor;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.VehicleController; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.VehicleController;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.information.Position;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetwork; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetwork;
import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor; import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
public class VehicleMovementModel implements MovementModel, EventHandler, FutureLocationSensor { public class VehicleMovementModel implements MovementModel, EventHandler {
private static final Location DEFAULT_LOCATION = new PositionVector(Double.NaN, Double.NaN); private static final Location DEFAULT_LOCATION = new PositionVector(Double.NaN, Double.NaN);
...@@ -95,7 +86,7 @@ public class VehicleMovementModel implements MovementModel, EventHandler, Future ...@@ -95,7 +86,7 @@ public class VehicleMovementModel implements MovementModel, EventHandler, Future
private VehicleController _controller; private VehicleController _controller;
private SimulationSetupExtractor _extractor; private SimulationSetupExtractor _extractor;
private List<Position> intersections; private List<Location> intersections;
/** /**
* Constructor for the movement model using the sumo TraCI API * Constructor for the movement model using the sumo TraCI API
...@@ -302,7 +293,7 @@ public class VehicleMovementModel implements MovementModel, EventHandler, Future ...@@ -302,7 +293,7 @@ public class VehicleMovementModel implements MovementModel, EventHandler, Future
for (int i = 0; i < allVehicles.size(); i++) { for (int i = 0; i < allVehicles.size(); i++) {
String vehicle = allVehicles.get(i); String vehicle = allVehicles.get(i);
Position position = _controller.getVehiclePosition(vehicle); Location position = _controller.getVehiclePosition(vehicle);
if (position == null) { if (position == null) {
allVehicles.remove(i--); allVehicles.remove(i--);
...@@ -311,10 +302,10 @@ public class VehicleMovementModel implements MovementModel, EventHandler, Future ...@@ -311,10 +302,10 @@ public class VehicleMovementModel implements MovementModel, EventHandler, Future
SimLocationActuator component = requestSimActuator(vehicle); SimLocationActuator component = requestSimActuator(vehicle);
if (scenarioHeight != -1) { if (scenarioHeight != -1) {
component.updateCurrentLocation(new PositionVector(position.getX(), Math.min(scenarioHeight, height) - position.getY())); component.updateCurrentLocation(new PositionVector(position.getLongitude(), Math.min(scenarioHeight, height) - position.getLatitude()));
} else { } else {
// This would be vertically mirrored // This would be vertically mirrored
component.updateCurrentLocation(new PositionVector(position.getX(), position.getY())); component.updateCurrentLocation(new PositionVector(position.getLongitude(), position.getLatitude()));
} }
component.setMovementSpeed(position.getSpeed()); component.setMovementSpeed(position.getSpeed());
...@@ -420,22 +411,4 @@ public class VehicleMovementModel implements MovementModel, EventHandler, Future ...@@ -420,22 +411,4 @@ public class VehicleMovementModel implements MovementModel, EventHandler, Future
public static RoadNetwork getRoadNetwork() { public static RoadNetwork getRoadNetwork() {
return MOVEMENT._extractor.getRoadNetwork(); return MOVEMENT._extractor.getRoadNetwork();
} }
/**
* Returns the future location of a certain host.
* @param pHost The host for which the location is being requested.
* @return The future location of the host.
*/
@Override
public Location getFutureLocation(Host pHost) {
if (hostVehicleIDMatching.containsKey(pHost.getId())) {
String vehicleID = hostVehicleIDMatching.get(pHost.getId());
Position vehiclePosition = _controller.getVehiclePosition(_controller.getMaximumAvailablePrediction(), vehicleID);
if (vehiclePosition != null) {
return new PositionVector(vehiclePosition.getX(), vehiclePosition.getY());
}
}
return null;
}
} }
...@@ -11,36 +11,36 @@ import org.xml.sax.SAXException; ...@@ -11,36 +11,36 @@ import org.xml.sax.SAXException;
import de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.xml.CancelParsingSAXException; import de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.xml.CancelParsingSAXException;
import de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.xml.SimulationSetupInformationHandler; import de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.xml.SimulationSetupInformationHandler;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.information.Position; import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
public class SimulationSetupInformationProvider { public class SimulationSetupInformationProvider {
private static final SimulationSetupInformationProvider ONLY_INSTANCE = new SimulationSetupInformationProvider(); private static final SimulationSetupInformationProvider ONLY_INSTANCE = new SimulationSetupInformationProvider();
private SimulationSetupInformationHandler _handler = new SimulationSetupInformationHandler(); private SimulationSetupInformationHandler _handler = new SimulationSetupInformationHandler();
private SimulationSetupInformationProvider() { private SimulationSetupInformationProvider() {
} }
public static SimulationSetupInformationProvider getOnlyInstance() { public static SimulationSetupInformationProvider getOnlyInstance() {
return ONLY_INSTANCE; return ONLY_INSTANCE;
} }
public Position getUpperLeft() { public Location getUpperLeft() {
return _handler.getUpperLeft(); return _handler.getUpperLeft();
} }
public Position getLowerRight() { public Location getLowerRight() {
return _handler.getLowerRight(); return _handler.getLowerRight();
} }
public static void init(String pNetFileLocation) { public static void init(String pNetFileLocation) {
try { try {
SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
parser.parse(new FileInputStream(pNetFileLocation), ONLY_INSTANCE._handler); parser.parse(new FileInputStream(pNetFileLocation), ONLY_INSTANCE._handler);
} catch (CancelParsingSAXException e) { } catch (CancelParsingSAXException e) {
return; return;
} catch (ParserConfigurationException | SAXException | IOException e) { } catch (ParserConfigurationException | SAXException | IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
public class VehicleInformationContainer {
private Location _position;
private double _heading;
private double _speed;
public VehicleInformationContainer(Location pPosition, double pHeading,
double pSpeed) {
_position = pPosition;
_heading = pHeading;
_speed = pSpeed;
}
public Location getPosition() {
return _position;
}
public double getHeading() {
return _heading;
}
public double getSpeed() {
return _speed;
}
}
\ No newline at end of file
...@@ -7,64 +7,65 @@ import java.util.ArrayList; ...@@ -7,64 +7,65 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Scanner; import java.util.Scanner;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.information.Position; import de.tud.kom.p2psim.impl.topology.PositionVector;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
public class RoadSideUnitInformationHandler { public class RoadSideUnitInformationHandler {
private List<Position> _positions = new ArrayList<>(); private List<Location> _positions = new ArrayList<>();
private boolean _observedAreaSet = false; private boolean _observedAreaSet = false;
private double _startX = -1; private double _startX = -1;
private double _startY = -1; private double _startY = -1;
private double _endX = -1; private double _endX = -1;
private double _endY = -1; private double _endY = -1;
public List<Position> getIntersections() { public List<Location> getIntersections() {
if (!_observedAreaSet) { if (!_observedAreaSet) {
return _positions; return _positions;
} else { } else {
List<Position> result = new ArrayList<>(); List<Location> result = new ArrayList<>();
for (Position position : _positions) { for (Location position : _positions) {
if (_startX <= position.getX() && position.getX() <= _endX && _startY <= position.getY() && position.getY() <= _endY) { if (_startX <= position.getLongitude() && position.getLongitude() <= _endX && _startY <= position.getLatitude() && position.getLatitude() <= _endY) {
result.add(new Position(position.getX() - _startX, position.getY() - _startY, 0, 0)); result.add(new PositionVector(position.getLongitude() - _startX, position.getLatitude() - _startY, 0));
} }
} }
return result; return result;
} }
} }
public void parseIntersectionsFile(String pRoadSideUnitDataPath) { public void parseIntersectionsFile(String pRoadSideUnitDataPath) {
File file = new File(pRoadSideUnitDataPath); File file = new File(pRoadSideUnitDataPath);
try { try {
FileInputStream inputStream = new FileInputStream(file); FileInputStream inputStream = new FileInputStream(file);
Scanner scanner = new Scanner(inputStream); Scanner scanner = new Scanner(inputStream);
while (scanner.hasNextLine()) { while (scanner.hasNextLine()) {
String line = scanner.nextLine(); String line = scanner.nextLine();
if (line.contains(";")) { if (line.contains(";")) {
String[] split = line.split(";"); String[] split = line.split(";");
if (split.length == 2) { if (split.length == 2) {
double x = Double.parseDouble(split[0]); double x = Double.parseDouble(split[0]);
double y = Double.parseDouble(split[1]); double y = Double.parseDouble(split[1]);
_positions.add(new Position(x, y, 0, 0)); _positions.add(new PositionVector(x, y, 0));
} }
} }
} }
scanner.close(); scanner.close();
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
throw new UnsupportedOperationException("Unable to read file", e); throw new UnsupportedOperationException("Unable to read file", e);
} }
} }
public void setObservedArea(double pStartX, double pStartY, double pEndX, double pEndY) { public void setObservedArea(double pStartX, double pStartY, double pEndX, double pEndY) {
_startX = pStartX; _startX = pStartX;
_startY = pStartY; _startY = pStartY;
_endX = pEndX; _endX = pEndX;
_endY = pEndY; _endY = pEndY;
_observedAreaSet = true; _observedAreaSet = true;
} }
} }
...@@ -16,14 +16,14 @@ import java.util.Random; ...@@ -16,14 +16,14 @@ import java.util.Random;
import de.tud.kom.p2psim.api.simengine.SimulatorObserver; import de.tud.kom.p2psim.api.simengine.SimulatorObserver;
import de.tud.kom.p2psim.impl.simengine.Simulator; import de.tud.kom.p2psim.impl.simengine.Simulator;
import de.tudarmstadt.maki.simonstrator.api.Event; import de.tud.kom.p2psim.impl.topology.PositionVector;
import de.tudarmstadt.maki.simonstrator.api.EventHandler; import de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.VehicleInformationContainer;
import de.tudarmstadt.maki.simonstrator.api.Randoms; import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.EdgeController; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.EdgeController;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.SimulationSetupExtractor; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.SimulationSetupExtractor;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.VehicleController; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.VehicleController;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.information.LocationUtils; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.information.LocationUtils;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.information.Position;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetwork; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetwork;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkLane; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkLane;
...@@ -47,11 +47,19 @@ import de.tudresden.ws.container.SumoPosition2D; ...@@ -47,11 +47,19 @@ import de.tudresden.ws.container.SumoPosition2D;
import de.tudresden.ws.container.SumoStringList; import de.tudresden.ws.container.SumoStringList;
import it.polito.appeal.traci.SumoTraciConnection; import it.polito.appeal.traci.SumoTraciConnection;
/**
*
* @author Tobias Meuser (tobias.meuser@kom.tu-darmstadt.de)
* @version 1.0 at 06.11.2017
*
*/
public class TraciSimulationController implements VehicleController, SimulationSetupExtractor, EdgeController, SimulatorObserver { public class TraciSimulationController implements VehicleController, SimulationSetupExtractor, EdgeController, SimulatorObserver {
private static final File TEMP_FILE = new File(new File(System.getProperty("java.io.tmpdir")), "road_network.tmp"); private static final File TEMP_FILE = new File(new File(System.getProperty("java.io.tmpdir")), "road_network.tmp");
private Random _random = Randoms.getRandom(getClass()); private Random _random = Randoms.getRandom(getClass());
private List<RoadNetworkEdge> modifiedEdges = new ArrayList<>();
private static final Map<String, TraciSimulationController> CONTROLLER = new HashMap<>(); private static final Map<String, TraciSimulationController> CONTROLLER = new HashMap<>();
private static final double CLUSTERING_DISTANCE = 50; private static final double CLUSTERING_DISTANCE = 50;
...@@ -69,7 +77,8 @@ public class TraciSimulationController implements VehicleController, SimulationS ...@@ -69,7 +77,8 @@ public class TraciSimulationController implements VehicleController, SimulationS
private double _endX; private double _endX;
private double _endY; private double _endY;
private Map<Double, Map<String, Position>> _positonsByTimestamp = new HashMap<>(); private Map<Double, Map<String, VehicleInformationContainer>> _positonsByTimestamp = new HashMap<>();
private int _futureInformation = 0; private int _futureInformation = 0;
private boolean _initalized = false; private boolean _initalized = false;
...@@ -106,11 +115,11 @@ public class TraciSimulationController implements VehicleController, SimulationS ...@@ -106,11 +115,11 @@ public class TraciSimulationController implements VehicleController, SimulationS
// This will only work with the updated version of the TraaS API for sumo // This will only work with the updated version of the TraaS API for sumo
// It is available for download at https://dev.kom.e-technik.tu-darmstadt.de/gitlab/tobiasm/TraaS.git // It is available for download at https://dev.kom.e-technik.tu-darmstadt.de/gitlab/tobiasm/TraaS.git
_connection = new SumoTraciConnection(_sumoExe, _configFile, random.nextInt()); _connection = new SumoTraciConnection(_sumoExe, _configFile, random.nextInt());
/* /*
* prevent vehicles form teleporting (http://sumo.dlr.de/wiki/Simulation/Why_Vehicles_are_teleporting) * prevent vehicles form teleporting (http://sumo.dlr.de/wiki/Simulation/Why_Vehicles_are_teleporting)
*/ */
_connection.addOption("time-to-teleport", Integer.toString(-1)); _connection.addOption("time-to-teleport", Integer.toString(-1));
try { try {
_connection.runServer(); _connection.runServer();
...@@ -128,7 +137,7 @@ public class TraciSimulationController implements VehicleController, SimulationS ...@@ -128,7 +137,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
_initalized = true; _initalized = true;
} }
} }
@Override @Override
public void simulationFinished() { public void simulationFinished() {
/* /*
...@@ -141,20 +150,20 @@ public class TraciSimulationController implements VehicleController, SimulationS ...@@ -141,20 +150,20 @@ public class TraciSimulationController implements VehicleController, SimulationS
} }
@Override @Override
public Position getVehiclePosition(String pVehicleID) { public Location getVehiclePosition(String pVehicleID) {
return getVehiclePosition(_step, pVehicleID); return getVehiclePosition(_step, pVehicleID);
} }
@Override @Override
public Position getVehiclePosition(double pStep, String pVehicleID) { public Location getVehiclePosition(double pStep, String pVehicleID) {
Map<String, Position> map = _positonsByTimestamp.get(pStep); Map<String, VehicleInformationContainer> map = _positonsByTimestamp.get(pStep);
return map.get(pVehicleID); return map.get(pVehicleID).getPosition();
} }
@Override @Override
public List<Position> getAllIntersections(boolean pCluster) { public List<Location> getAllIntersections(boolean pCluster) {
List<Position> result = new ArrayList<>(); List<Location> result = new ArrayList<>();
SumoCommand intersectionCommand = Junction.getIDList(); SumoCommand intersectionCommand = Junction.getIDList();
...@@ -169,21 +178,21 @@ public class TraciSimulationController implements VehicleController, SimulationS ...@@ -169,21 +178,21 @@ public class TraciSimulationController implements VehicleController, SimulationS
if (_observedAreaSet) { if (_observedAreaSet) {
if (_startX <= sumoPosition.x && sumoPosition.x <= _endX && _startY <= sumoPosition.y && sumoPosition.y <= _endY) { if (_startX <= sumoPosition.x && sumoPosition.x <= _endX && _startY <= sumoPosition.y && sumoPosition.y <= _endY) {
result.add(new Position(sumoPosition.x - _startX, sumoPosition.y - _startY, 0, 0)); result.add(new PositionVector(sumoPosition.x - _startX, sumoPosition.y - _startY, 0));
} }
} else { } else {
result.add(new Position(sumoPosition.x, sumoPosition.y, 0, 0)); result.add(new PositionVector(sumoPosition.x, sumoPosition.y, 0));
} }
} }
if (pCluster) { if (pCluster) {
List<Position> tempResult = new ArrayList<>(); List<Location> tempResult = new ArrayList<>();
outer:for (int i = 0; i < result.size(); i++) { outer:for (int i = 0; i < result.size(); i++) {
Position position = result.get(i); Location position = result.get(i);
for (int j = 0; j < tempResult.size(); j++) { for (int j = 0; j < tempResult.size(); j++) {
Position addedPosition = tempResult.get(j); Location addedPosition = tempResult.get(j);
if (position != addedPosition && LocationUtils.calculateDistance(position, addedPosition) < CLUSTERING_DISTANCE / 1000.0) { if (position != addedPosition && LocationUtils.calculateDistance(position, addedPosition) < CLUSTERING_DISTANCE / 1000.0) {
continue outer; continue outer;
} }
...@@ -217,14 +226,19 @@ public class TraciSimulationController implements VehicleController, SimulationS ...@@ -217,14 +226,19 @@ public class TraciSimulationController implements VehicleController, SimulationS
double newStep = _step + _futureInformation; double newStep = _step + _futureInformation;
if (!_positonsByTimestamp.containsKey(newStep)) { if (!_positonsByTimestamp.containsKey(newStep)) {
Map<String, Position> vehiclePositions = new HashMap<>(); Map<String, VehicleInformationContainer> vehiclePositions = new HashMap<>();
_positonsByTimestamp.put(newStep, vehiclePositions); _positonsByTimestamp.put(newStep, vehiclePositions);
List<String> allVehicles = requestAllVehicles(); List<String> allVehicles = requestAllVehicles();
for (String vehicle : allVehicles) { for (String vehicle : allVehicles) {
Position vehiclePosition = requestVehiclePosition(vehicle); Location position = requestVehiclePosition(vehicle);
if (vehiclePosition != null) { if (position != null) {
vehiclePositions.put(vehicle, vehiclePosition); double heading = requestVehicleHeading(vehicle);
double speed = requestVehicleSpeed(vehicle);
VehicleInformationContainer informationContainer = new VehicleInformationContainer(position, heading, speed);
vehiclePositions.put(vehicle, informationContainer);
} }
} }
} }
...@@ -245,7 +259,7 @@ public class TraciSimulationController implements VehicleController, SimulationS ...@@ -245,7 +259,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
return false; return false;
} }
private Position requestVehiclePosition(String pVehicleID) { private Location requestVehiclePosition(String pVehicleID) {
if (_vehiclesOutOfRange.containsKey(pVehicleID)) { if (_vehiclesOutOfRange.containsKey(pVehicleID)) {
if (_vehiclesOutOfRange.get(pVehicleID) < _step) { if (_vehiclesOutOfRange.get(pVehicleID) < _step) {
return null; return null;
...@@ -255,20 +269,14 @@ public class TraciSimulationController implements VehicleController, SimulationS ...@@ -255,20 +269,14 @@ public class TraciSimulationController implements VehicleController, SimulationS
} }
SumoCommand positionCommand = Vehicle.getPosition(pVehicleID); SumoCommand positionCommand = Vehicle.getPosition(pVehicleID);
SumoCommand angleCommand = Vehicle.getAngle(pVehicleID);
SumoCommand speedCommand = Vehicle.getSpeed(pVehicleID);
Object positionObject = requestObject(positionCommand); Object positionObject = requestObject(positionCommand);
Object angleObject = requestObject(angleCommand);
Object speedObject = requestObject(speedCommand);
SumoPosition2D sumoPosition = (SumoPosition2D) positionObject; SumoPosition2D sumoPosition = (SumoPosition2D) positionObject;
double angle = (Double) angleObject;
double speed = (Double) speedObject;
if (_observedAreaSet) { if (_observedAreaSet) {
if (_startX <= sumoPosition.x && sumoPosition.x <= _endX && _startY <= sumoPosition.y && sumoPosition.y <= _endY) { if (_startX <= sumoPosition.x && sumoPosition.x <= _endX && _startY <= sumoPosition.y && sumoPosition.y <= _endY) {
return new Position(sumoPosition.x - _startX, sumoPosition.y - _startY, 0, angle, speed); return new PositionVector(sumoPosition.x - _startX, sumoPosition.y - _startY, 0);
} else { } else {
double diffX = _startX - sumoPosition.x; double diffX = _startX - sumoPosition.x;
if (diffX < 0 || sumoPosition.x - _endX < diffX) { if (diffX < 0 || sumoPosition.x - _endX < diffX) {
...@@ -293,8 +301,48 @@ public class TraciSimulationController implements VehicleController, SimulationS ...@@ -293,8 +301,48 @@ public class TraciSimulationController implements VehicleController, SimulationS
return null; return null;
} }
} else { } else {
return new Position(sumoPosition.x, sumoPosition.y, 0, angle); return new PositionVector(sumoPosition.x, sumoPosition.y, 0);
}
}
private double requestVehicleHeading(String pVehicleID) {
if (_vehiclesOutOfRange.containsKey(pVehicleID)) {
if (_vehiclesOutOfRange.get(pVehicleID) < _step) {
return -1;
} else {
_vehiclesOutOfRange.remove(pVehicleID);
}
}
SumoCommand angleCommand = Vehicle.getAngle(pVehicleID);
Object angleObject = requestObject(angleCommand);
if (angleObject != null) {
return (Double) angleObject;
} }
return -1;
}
private double requestVehicleSpeed(String pVehicleID) {
if (_vehiclesOutOfRange.containsKey(pVehicleID)) {
if (_vehiclesOutOfRange.get(pVehicleID) < _step) {
return -1;
} else {
_vehiclesOutOfRange.remove(pVehicleID);
}
}
SumoCommand speedCommand = Vehicle.getSpeed(pVehicleID);
Object speedObject = requestObject(speedCommand);
if (speedObject != null) {
return (Double) speedObject;
}
return -1;
} }
private List<String> requestAllVehicles() { private List<String> requestAllVehicles() {
...@@ -318,7 +366,7 @@ public class TraciSimulationController implements VehicleController, SimulationS ...@@ -318,7 +366,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
@Override @Override
public List<String> getAllVehicles(double pStep) { public List<String> getAllVehicles(double pStep) {
Map<String, Position> map = _positonsByTimestamp.get(pStep); Map<String, VehicleInformationContainer> map = _positonsByTimestamp.get(pStep);
return new ArrayList<>(map.keySet()); return new ArrayList<>(map.keySet());
} }
......
...@@ -4,32 +4,33 @@ import org.xml.sax.Attributes; ...@@ -4,32 +4,33 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.DefaultHandler;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.information.Position; import de.tud.kom.p2psim.impl.topology.PositionVector;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
public class SimulationSetupInformationHandler extends DefaultHandler { public class SimulationSetupInformationHandler extends DefaultHandler {
private Position _upperLeft; private Location _upperLeft;
private Position _lowerRight; private Location _lowerRight;
@Override @Override
public void startElement(String pUri, String pLocalName, String pQName, Attributes pAttributes) public void startElement(String pUri, String pLocalName, String pQName, Attributes pAttributes)
throws SAXException { throws SAXException {
if (pQName.equals("location")) { if (pQName.equals("location")) {
String meterBoundary = pAttributes.getValue("convBoundary"); String meterBoundary = pAttributes.getValue("convBoundary");
if (meterBoundary != null) { if (meterBoundary != null) {
String[] edges = meterBoundary.split(","); String[] edges = meterBoundary.split(",");
_upperLeft = new Position(Double.valueOf(edges[0]), Double.valueOf(edges[1]), 0, 0); _upperLeft = new PositionVector(Double.valueOf(edges[0]), Double.valueOf(edges[1]), 0);
_lowerRight = new Position(Double.valueOf(edges[2]), Double.valueOf(edges[3]), 0, 0); _lowerRight = new PositionVector(Double.valueOf(edges[2]), Double.valueOf(edges[3]), 0);
} }
throw new CancelParsingSAXException(); throw new CancelParsingSAXException();
} }
} }
public Position getLowerRight() { public Location getLowerRight() {
return _lowerRight; return _lowerRight;
} }
public Position getUpperLeft() { public Location getUpperLeft() {
return _upperLeft; return _upperLeft;
} }
} }
...@@ -6,123 +6,124 @@ import org.xml.sax.Attributes; ...@@ -6,123 +6,124 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.DefaultHandler;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.information.Position; import de.tud.kom.p2psim.impl.topology.PositionVector;
import de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.VehicleInformationContainer;
public class VehicleDataInformationHandler extends DefaultHandler { public class VehicleDataInformationHandler extends DefaultHandler {
private boolean _next = true; private boolean _next = true;
private boolean _run = true; private boolean _run = true;
private HashMap<String, Position> _vehiclePositions = new HashMap<>(); private HashMap<String, VehicleInformationContainer> _vehiclePositions = new HashMap<>();
private double _currentStep = -1; private double _currentStep = -1;
private boolean _observedAreaSet = false; private boolean _observedAreaSet = false;
private double _startX = -1; private double _startX = -1;
private double _startY = -1; private double _startY = -1;
private double _endX = -1; private double _endX = -1;
private double _endY = -1; private double _endY = -1;
private HashMap<String, Position> _nextVehiclePositions = new HashMap<>(); private HashMap<String, VehicleInformationContainer> _nextVehiclePositions = new HashMap<>();
private double _nextStep = -1; private double _nextStep = -1;
private static final String doublePattern = "-?[0-9]*\\.?[0-9]+"; private static final String doublePattern = "-?[0-9]*\\.?[0-9]+";
private boolean _terminated = false; private boolean _terminated = false;
@Override @Override
public void startElement(String pUri, String pLocalName, String pQName, Attributes pAttributes) public void startElement(String pUri, String pLocalName, String pQName, Attributes pAttributes)
throws SAXException { throws SAXException {
if (pQName.equals("timestep")) { if (pQName.equals("timestep")) {
while (!_next) { while (!_next) {
try { try {
Thread.sleep(10); Thread.sleep(10);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
_next = false; _next = false;
String value = pAttributes.getValue("time"); String value = pAttributes.getValue("time");
if (value.matches(doublePattern)) { if (value.matches(doublePattern)) {
_nextStep = Double.valueOf(value); _nextStep = Double.valueOf(value);
} }
} else if (pQName.equals("vehicle")) { } else if (pQName.equals("vehicle")) {
String id = pAttributes.getValue("id"); String id = pAttributes.getValue("id");
String lonString = pAttributes.getValue("x"); String lonString = pAttributes.getValue("x");
String latString = pAttributes.getValue("y"); String latString = pAttributes.getValue("y");
String speedString = pAttributes.getValue("speed"); String speedString = pAttributes.getValue("speed");
String headingString = pAttributes.getValue("angle"); String headingString = pAttributes.getValue("angle");
if (lonString.matches(doublePattern) && latString.matches(doublePattern) && headingString.matches(doublePattern) && speedString.matches(doublePattern) ) { if (lonString.matches(doublePattern) && latString.matches(doublePattern) && headingString.matches(doublePattern) && speedString.matches(doublePattern) ) {
double lon = Double.valueOf(lonString); double lon = Double.valueOf(lonString);
double lat = Double.valueOf(latString); double lat = Double.valueOf(latString);
double heading = Double.valueOf(headingString); double heading = Double.valueOf(headingString);
double speed = Double.valueOf(speedString); double speed = Double.valueOf(speedString);
if (_observedAreaSet) { if (_observedAreaSet) {
if (_startX <= lon && lon <= _endX && _startY <= lat && lat <= _endY) { if (_startX <= lon && lon <= _endX && _startY <= lat && lat <= _endY) {
_nextVehiclePositions.put(id, new Position(lon - _startX, lat - _startY, 0, heading, speed)); _nextVehiclePositions.put(id, new VehicleInformationContainer(new PositionVector(lon - _startX, lat - _startY, 0), heading, speed));
} }
} else { } else {
_nextVehiclePositions.put(id, new Position(lon, lat, 0, heading, speed)); _nextVehiclePositions.put(id, new VehicleInformationContainer(new PositionVector(lon, lat, 0), heading, speed));
} }
} }
} }
} }
@Override @Override
public void endElement(String pUri, String pLocalName, String pQName) throws SAXException { public void endElement(String pUri, String pLocalName, String pQName) throws SAXException {
if (pQName.equals("timestep")) { if (pQName.equals("timestep")) {
_run = false; _run = false;
} else if (pQName.equals("fcd-export")) { } else if (pQName.equals("fcd-export")) {
while (!_next) { while (!_next) {
try { try {
Thread.sleep(10); Thread.sleep(10);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
_next = false; _next = false;
_run = false; _run = false;
_terminated = true; _terminated = true;
} }
} }
public void setObservedArea(double pStartX, double pStartY, double pEndX, double pEndY) { public void setObservedArea(double pStartX, double pStartY, double pEndX, double pEndY) {
_startX = pStartX; _startX = pStartX;
_startY = pStartY; _startY = pStartY;
_endX = pEndX; _endX = pEndX;
_endY = pEndY; _endY = pEndY;
_observedAreaSet = true; _observedAreaSet = true;
} }
public boolean isTerminated() { public boolean isTerminated() {
return _terminated; return _terminated;
} }
public HashMap<String, Position> getVehiclePositions() { public HashMap<String, VehicleInformationContainer> getVehiclePositions() {
return _vehiclePositions; return _vehiclePositions;
} }
public void readNext() { public void readNext() {
while (_run) { while (_run) {
try { try {
Thread.sleep(10); Thread.sleep(10);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
_vehiclePositions = _nextVehiclePositions; _vehiclePositions = _nextVehiclePositions;
_currentStep = _nextStep; _currentStep = _nextStep;
_nextStep = -1; _nextStep = -1;
_nextVehiclePositions = new HashMap<>(); _nextVehiclePositions = new HashMap<>();
_run = true; _run = true;
_next = true; _next = true;
} }
public boolean isRunning() { public boolean isRunning() {
return _run; return _run;
} }
public double getStep() { public double getStep() {
return _currentStep; return _currentStep;
} }
} }
...@@ -10,10 +10,11 @@ import java.util.Map; ...@@ -10,10 +10,11 @@ import java.util.Map;
import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.SAXParserFactory;
import de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.VehicleInformationContainer;
import de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.csv.RoadSideUnitInformationHandler; import de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.csv.RoadSideUnitInformationHandler;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.SimulationSetupExtractor; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.SimulationSetupExtractor;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.VehicleController; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.VehicleController;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.information.Position;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetwork; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetwork;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute;
...@@ -26,7 +27,7 @@ public class XMLSimulationController implements VehicleController, SimulationSet ...@@ -26,7 +27,7 @@ public class XMLSimulationController implements VehicleController, SimulationSet
private List<String> _vehicles; private List<String> _vehicles;
private Map<Double, Map<String, Position>> _positonsByTimestamp = new HashMap<>(); private Map<Double, Map<String, VehicleInformationContainer>> _positonsByTimestamp = new HashMap<>();
private int _futureInformation = 10; private int _futureInformation = 10;
private boolean _initalized = false; private boolean _initalized = false;
...@@ -67,11 +68,11 @@ public class XMLSimulationController implements VehicleController, SimulationSet ...@@ -67,11 +68,11 @@ public class XMLSimulationController implements VehicleController, SimulationSet
} }
@Override @Override
public Position getVehiclePosition(String pVehicleID) { public Location getVehiclePosition(String pVehicleID) {
return getVehiclePosition(_step, pVehicleID); return getVehiclePosition(_step, pVehicleID);
} }
public Position requestVehiclePosition(String pVehicleID) { public VehicleInformationContainer requestVehicleInformation(String pVehicleID) {
return _vehicleDataInformationHandler.getVehiclePositions().get(pVehicleID); return _vehicleDataInformationHandler.getVehiclePositions().get(pVehicleID);
} }
...@@ -86,12 +87,12 @@ public class XMLSimulationController implements VehicleController, SimulationSet ...@@ -86,12 +87,12 @@ public class XMLSimulationController implements VehicleController, SimulationSet
double newStep = _step + _futureInformation; double newStep = _step + _futureInformation;
if (!_positonsByTimestamp.containsKey(newStep)) { if (!_positonsByTimestamp.containsKey(newStep)) {
Map<String, Position> vehiclePositions = new HashMap<>(); Map<String, VehicleInformationContainer> vehiclePositions = new HashMap<>();
_positonsByTimestamp.put(newStep, vehiclePositions); _positonsByTimestamp.put(newStep, vehiclePositions);
List<String> allVehicles = new ArrayList<>(_vehicleDataInformationHandler.getVehiclePositions().keySet()); List<String> allVehicles = new ArrayList<>(_vehicleDataInformationHandler.getVehiclePositions().keySet());
for (String vehicle : allVehicles) { for (String vehicle : allVehicles) {
Position vehiclePosition = requestVehiclePosition(vehicle); VehicleInformationContainer vehiclePosition = requestVehicleInformation(vehicle);
if (vehiclePosition != null) { if (vehiclePosition != null) {
vehiclePositions.put(vehicle, vehiclePosition); vehiclePositions.put(vehicle, vehiclePosition);
} }
...@@ -135,15 +136,15 @@ public class XMLSimulationController implements VehicleController, SimulationSet ...@@ -135,15 +136,15 @@ public class XMLSimulationController implements VehicleController, SimulationSet
} }
@Override @Override
public Position getVehiclePosition(double pStep, String pVehicleID) { public Location getVehiclePosition(double pStep, String pVehicleID) {
Map<String, Position> map = _positonsByTimestamp.get(pStep); Map<String, VehicleInformationContainer> map = _positonsByTimestamp.get(pStep);
return map.get(pVehicleID); return map.get(pVehicleID).getPosition();
} }
@Override @Override
public List<String> getAllVehicles(double pStep) { public List<String> getAllVehicles(double pStep) {
Map<String, Position> map = _positonsByTimestamp.get(pStep); Map<String, VehicleInformationContainer> map = _positonsByTimestamp.get(pStep);
return new ArrayList<>(map.keySet()); return new ArrayList<>(map.keySet());
} }
...@@ -156,7 +157,7 @@ public class XMLSimulationController implements VehicleController, SimulationSet ...@@ -156,7 +157,7 @@ public class XMLSimulationController implements VehicleController, SimulationSet
} }
@Override @Override
public List<Position> getAllIntersections(boolean pCluster) { public List<Location> getAllIntersections(boolean pCluster) {
return _roadSideUnitInformationHandler.getIntersections(); return _roadSideUnitInformationHandler.getIntersections();
} }
......
...@@ -25,11 +25,10 @@ import java.util.List; ...@@ -25,11 +25,10 @@ import java.util.List;
import de.tud.kom.p2psim.api.topology.TopologyComponent; import de.tud.kom.p2psim.api.topology.TopologyComponent;
import de.tud.kom.p2psim.api.topology.placement.PlacementModel; import de.tud.kom.p2psim.api.topology.placement.PlacementModel;
import de.tud.kom.p2psim.impl.topology.PositionVector; import de.tud.kom.p2psim.impl.topology.PositionVector;
import de.tud.kom.p2psim.impl.topology.movement.VehicleMovementModel;
import de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.traci.TraciSimulationController; import de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.traci.TraciSimulationController;
import de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.xml.XMLSimulationController; import de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.xml.XMLSimulationController;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.SimulationSetupExtractor; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.SimulationSetupExtractor;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.information.Position;
import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor; import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
/** /**
...@@ -48,7 +47,7 @@ public class RSUPlacement implements PlacementModel { ...@@ -48,7 +47,7 @@ public class RSUPlacement implements PlacementModel {
private SimulationSetupExtractor _controller; private SimulationSetupExtractor _controller;
private List<Position> _intersections; private List<Location> _intersections;
private int _currentIndex = 0; private int _currentIndex = 0;
@XMLConfigurableConstructor({ "sumoExe", "sumoConfigFile", "offsetX", "offsetY", "width", "height" }) @XMLConfigurableConstructor({ "sumoExe", "sumoConfigFile", "offsetX", "offsetY", "width", "height" })
...@@ -107,9 +106,9 @@ public class RSUPlacement implements PlacementModel { ...@@ -107,9 +106,9 @@ public class RSUPlacement implements PlacementModel {
@Override @Override
public PositionVector place(TopologyComponent comp) { public PositionVector place(TopologyComponent comp) {
if (_currentIndex < _intersections.size()) { if (_currentIndex < _intersections.size()) {
Position intersection = _intersections.get(_currentIndex); Location intersection = _intersections.get(_currentIndex);
_currentIndex++; _currentIndex++;
return new PositionVector(intersection.getX(), intersection.getY()); return new PositionVector(intersection.getLongitude(), intersection.getLatitude());
} else { } else {
return new PositionVector(Double.NaN, Double.NaN); return new PositionVector(Double.NaN, Double.NaN);
} }
......
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