Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
PeerfactSim.KOM
Commits
a7ade2b5
Commit
a7ade2b5
authored
Nov 06, 2017
by
Tobias Meuser
Committed by
Jose Ignacio Monreal Bailey
Aug 20, 2019
Browse files
Removed Position class
parent
08a789ee
Changes
10
Show whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/movement/RSUMovementModel.java
View file @
a7ade2b5
...
...
@@ -24,7 +24,6 @@ import java.util.HashMap;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
de.tud.kom.p2psim.api.network.SimNetInterface
;
import
de.tud.kom.p2psim.api.topology.movement.MovementModel
;
...
...
@@ -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.movement.vehicular.sumo.simulation.controller.traci.TraciSimulationController
;
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.common.graph.INodeID
;
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.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.information.Position
;
import
de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor
;
public
class
RSUMovementModel
implements
MovementModel
,
FutureLocationSensor
{
public
class
RSUMovementModel
implements
MovementModel
{
private
final
List
<
SimLocationActuator
>
components
;
...
...
@@ -69,7 +59,7 @@ public class RSUMovementModel implements MovementModel, FutureLocationSensor {
private
SimulationSetupExtractor
_controller
;
private
List
<
Posi
tion
>
_intersections
;
private
List
<
Loca
tion
>
_intersections
;
private
int
_currentIndex
=
0
;
private
final
Map
<
INodeID
,
Integer
>
hostIntersectionMatching
=
new
HashMap
<>();
...
...
@@ -107,40 +97,6 @@ public class RSUMovementModel implements MovementModel, FutureLocationSensor {
@Override
public
final
void
addComponent
(
SimLocationActuator
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
...
...
@@ -156,8 +112,8 @@ public class RSUMovementModel implements MovementModel, FutureLocationSensor {
}
if
(
_currentIndex
<
_intersections
.
size
())
{
// Initial placement
Posi
tion
intersection
=
_intersections
.
get
(
_currentIndex
);
actuator
.
updateCurrentLocation
(
new
PositionVector
(
intersection
.
get
X
(),
intersection
.
get
Y
()));
Loca
tion
intersection
=
_intersections
.
get
(
_currentIndex
);
actuator
.
updateCurrentLocation
(
new
PositionVector
(
intersection
.
get
Longitude
(),
intersection
.
get
Latitude
()));
hostIntersectionMatching
.
put
(
actuator
.
getHost
().
getId
(),
_currentIndex
);
...
...
@@ -198,17 +154,4 @@ public class RSUMovementModel implements MovementModel, FutureLocationSensor {
// 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
src/de/tud/kom/p2psim/impl/topology/movement/VehicleMovementModel.java
View file @
a7ade2b5
...
...
@@ -26,7 +26,6 @@ import java.util.LinkedList;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Queue
;
import
java.util.Set
;
import
de.tud.kom.p2psim.api.network.SimNetInterface
;
import
de.tud.kom.p2psim.api.topology.movement.MovementModel
;
...
...
@@ -42,22 +41,14 @@ import de.tudarmstadt.maki.simonstrator.api.Host;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.INodeID
;
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.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.api.SimulationSetupExtractor
;
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.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
);
...
...
@@ -95,7 +86,7 @@ public class VehicleMovementModel implements MovementModel, EventHandler, Future
private
VehicleController
_controller
;
private
SimulationSetupExtractor
_extractor
;
private
List
<
Posi
tion
>
intersections
;
private
List
<
Loca
tion
>
intersections
;
/**
* Constructor for the movement model using the sumo TraCI API
...
...
@@ -200,40 +191,7 @@ public class VehicleMovementModel implements MovementModel, EventHandler, Future
initialized
=
true
;
}
// Initial placement
actuator
.
updateCurrentLocation
(
DEFAULT_LOCATION
);
try
{
final
SiSComponent
sis
=
actuator
.
getHost
().
getComponent
(
SiSComponent
.
class
);
sis
.
provide
().
nodeState
(
SiSTypes
.
FUTURE_PHY_LOCATION
,
new
SiSDataCallback
<
Location
>()
{
Set
<
INodeID
>
localID
=
INodeID
.
getSingleIDSet
(
actuator
.
getHost
().
getId
());
@Override
public
Location
getValue
(
INodeID
nodeID
,
SiSProviderHandle
providerHandle
)
throws
InformationNotAvailableException
{
if
(
nodeID
.
equals
(
actuator
.
getHost
().
getId
()))
{
return
getFutureLocation
(
actuator
.
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
}
actuator
.
updateCurrentLocation
(
new
PositionVector
(
Double
.
NaN
,
Double
.
NaN
));
}
/**
...
...
@@ -302,7 +260,7 @@ public class VehicleMovementModel implements MovementModel, EventHandler, Future
for
(
int
i
=
0
;
i
<
allVehicles
.
size
();
i
++)
{
String
vehicle
=
allVehicles
.
get
(
i
);
Posi
tion
position
=
_controller
.
getVehiclePosition
(
vehicle
);
Loca
tion
position
=
_controller
.
getVehiclePosition
(
vehicle
);
if
(
position
==
null
)
{
allVehicles
.
remove
(
i
--);
...
...
@@ -311,10 +269,10 @@ public class VehicleMovementModel implements MovementModel, EventHandler, Future
SimLocationActuator
component
=
requestSimActuator
(
vehicle
);
if
(
scenarioHeight
!=
-
1
)
{
component
.
updateCurrentLocation
(
new
PositionVector
(
position
.
get
X
(),
Math
.
min
(
scenarioHeight
,
height
)
-
position
.
get
Y
()));
component
.
updateCurrentLocation
(
new
PositionVector
(
position
.
get
Longitude
(),
Math
.
min
(
scenarioHeight
,
height
)
-
position
.
get
Latitude
()));
}
else
{
// This would be vertically mirrored
component
.
updateCurrentLocation
(
new
PositionVector
(
position
.
get
X
(),
position
.
get
Y
()));
component
.
updateCurrentLocation
(
new
PositionVector
(
position
.
get
Longitude
(),
position
.
get
Latitude
()));
}
component
.
setMovementSpeed
(
position
.
getSpeed
());
...
...
@@ -420,22 +378,4 @@ public class VehicleMovementModel implements MovementModel, EventHandler, Future
public
static
RoadNetwork
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
;
}
}
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/SimulationSetupInformationProvider.java
View file @
a7ade2b5
...
...
@@ -11,7 +11,7 @@ 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.SimulationSetupInformationHandler
;
import
de.tudarmstadt.maki.simonstrator.api.component.
vehicular.api.inform
ation.
Posi
tion
;
import
de.tudarmstadt.maki.simonstrator.api.component.
sensor.loc
ation.
Loca
tion
;
public
class
SimulationSetupInformationProvider
{
private
static
final
SimulationSetupInformationProvider
ONLY_INSTANCE
=
new
SimulationSetupInformationProvider
();
...
...
@@ -25,11 +25,11 @@ public class SimulationSetupInformationProvider {
return
ONLY_INSTANCE
;
}
public
Posi
tion
getUpperLeft
()
{
public
Loca
tion
getUpperLeft
()
{
return
_handler
.
getUpperLeft
();
}
public
Posi
tion
getLowerRight
()
{
public
Loca
tion
getLowerRight
()
{
return
_handler
.
getLowerRight
();
}
...
...
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/VehicleInformationContainer.java
0 → 100755
View file @
a7ade2b5
/*
* 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
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/csv/RoadSideUnitInformationHandler.java
View file @
a7ade2b5
...
...
@@ -7,11 +7,12 @@ import java.util.ArrayList;
import
java.util.List
;
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
{
private
List
<
Posi
tion
>
_positions
=
new
ArrayList
<>();
private
List
<
Loca
tion
>
_positions
=
new
ArrayList
<>();
private
boolean
_observedAreaSet
=
false
;
private
double
_startX
=
-
1
;
...
...
@@ -19,15 +20,15 @@ public class RoadSideUnitInformationHandler {
private
double
_endX
=
-
1
;
private
double
_endY
=
-
1
;
public
List
<
Posi
tion
>
getIntersections
()
{
public
List
<
Loca
tion
>
getIntersections
()
{
if
(!
_observedAreaSet
)
{
return
_positions
;
}
else
{
List
<
Posi
tion
>
result
=
new
ArrayList
<>();
List
<
Loca
tion
>
result
=
new
ArrayList
<>();
for
(
Posi
tion
position
:
_positions
)
{
if
(
_startX
<=
position
.
get
X
()
&&
position
.
get
X
()
<=
_endX
&&
_startY
<=
position
.
get
Y
()
&&
position
.
get
Y
()
<=
_endY
)
{
result
.
add
(
new
Position
(
position
.
get
X
()
-
_startX
,
position
.
get
Y
()
-
_startY
,
0
,
0
));
for
(
Loca
tion
position
:
_positions
)
{
if
(
_startX
<=
position
.
get
Longitude
()
&&
position
.
get
Longitude
()
<=
_endX
&&
_startY
<=
position
.
get
Latitude
()
&&
position
.
get
Latitude
()
<=
_endY
)
{
result
.
add
(
new
Position
Vector
(
position
.
get
Longitude
()
-
_startX
,
position
.
get
Latitude
()
-
_startY
,
0
));
}
}
...
...
@@ -49,7 +50,7 @@ public class RoadSideUnitInformationHandler {
if
(
split
.
length
==
2
)
{
double
x
=
Double
.
parseDouble
(
split
[
0
]);
double
y
=
Double
.
parseDouble
(
split
[
1
]);
_positions
.
add
(
new
Position
(
x
,
y
,
0
,
0
));
_positions
.
add
(
new
Position
Vector
(
x
,
y
,
0
));
}
}
}
...
...
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/traci/TraciSimulationController.java
View file @
a7ade2b5
...
...
@@ -16,14 +16,14 @@ import java.util.Random;
import
de.tud.kom.p2psim.api.simengine.SimulatorObserver
;
import
de.tud.kom.p2psim.impl.simengine.Simulator
;
import
de.tud
armstadt.maki.simonstrator.api.Event
;
import
de.tud
armstadt.maki.simonstrator.api.EventHandl
er
;
import
de.tud
.kom.p2psim.impl.topology.PositionVector
;
import
de.tud
.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.VehicleInformationContain
er
;
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.SimulationSetupExtractor
;
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.Position
;
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.RoadNetworkLane
;
...
...
@@ -52,6 +52,8 @@ public class TraciSimulationController implements VehicleController, SimulationS
private
Random
_random
=
Randoms
.
getRandom
(
getClass
());
private
List
<
RoadNetworkEdge
>
modifiedEdges
=
new
ArrayList
<>();
private
static
final
Map
<
String
,
TraciSimulationController
>
CONTROLLER
=
new
HashMap
<>();
private
static
final
double
CLUSTERING_DISTANCE
=
50
;
...
...
@@ -69,7 +71,8 @@ public class TraciSimulationController implements VehicleController, SimulationS
private
double
_endX
;
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
boolean
_initalized
=
false
;
...
...
@@ -141,20 +144,20 @@ public class TraciSimulationController implements VehicleController, SimulationS
}
@Override
public
Posi
tion
getVehiclePosition
(
String
pVehicleID
)
{
public
Loca
tion
getVehiclePosition
(
String
pVehicleID
)
{
return
getVehiclePosition
(
_step
,
pVehicleID
);
}
@Override
public
Posi
tion
getVehiclePosition
(
double
pStep
,
String
pVehicleID
)
{
Map
<
String
,
Position
>
map
=
_positonsByTimestamp
.
get
(
pStep
);
public
Loca
tion
getVehiclePosition
(
double
pStep
,
String
pVehicleID
)
{
Map
<
String
,
VehicleInformationContainer
>
map
=
_positonsByTimestamp
.
get
(
pStep
);
return
map
.
get
(
pVehicleID
);
return
map
.
get
(
pVehicleID
)
.
getPosition
()
;
}
@Override
public
List
<
Posi
tion
>
getAllIntersections
(
boolean
pCluster
)
{
List
<
Posi
tion
>
result
=
new
ArrayList
<>();
public
List
<
Loca
tion
>
getAllIntersections
(
boolean
pCluster
)
{
List
<
Loca
tion
>
result
=
new
ArrayList
<>();
SumoCommand
intersectionCommand
=
Junction
.
getIDList
();
...
...
@@ -169,21 +172,21 @@ public class TraciSimulationController implements VehicleController, SimulationS
if
(
_observedAreaSet
)
{
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
Position
Vector
(
sumoPosition
.
x
-
_startX
,
sumoPosition
.
y
-
_startY
,
0
));
}
}
else
{
result
.
add
(
new
Position
(
sumoPosition
.
x
,
sumoPosition
.
y
,
0
,
0
));
result
.
add
(
new
Position
Vector
(
sumoPosition
.
x
,
sumoPosition
.
y
,
0
));
}
}
if
(
pCluster
)
{
List
<
Posi
tion
>
tempResult
=
new
ArrayList
<>();
List
<
Loca
tion
>
tempResult
=
new
ArrayList
<>();
outer:
for
(
int
i
=
0
;
i
<
result
.
size
();
i
++)
{
Posi
tion
position
=
result
.
get
(
i
);
Loca
tion
position
=
result
.
get
(
i
);
for
(
int
j
=
0
;
j
<
tempResult
.
size
();
j
++)
{
Posi
tion
addedPosition
=
tempResult
.
get
(
j
);
Loca
tion
addedPosition
=
tempResult
.
get
(
j
);
if
(
position
!=
addedPosition
&&
LocationUtils
.
calculateDistance
(
position
,
addedPosition
)
<
CLUSTERING_DISTANCE
/
1000.0
)
{
continue
outer
;
}
...
...
@@ -204,13 +207,6 @@ public class TraciSimulationController implements VehicleController, SimulationS
return
false
;
}
try
{
// for (RoadNetworkEdge roadNetworkEdge : modifiedEdges) {
// SumoCommand setMaxSpeedCommand = Edge.setMaxSpeed(roadNetworkEdge.getEdgeID(), roadNetworkEdge.getOriginalMaxSpeed());
//
// execute(setMaxSpeedCommand);
// }
_connection
.
do_timestep
();
try
{
...
...
@@ -224,14 +220,19 @@ public class TraciSimulationController implements VehicleController, SimulationS
double
newStep
=
_step
+
_futureInformation
;
if
(!
_positonsByTimestamp
.
containsKey
(
newStep
))
{
Map
<
String
,
Position
>
vehiclePositions
=
new
HashMap
<>();
Map
<
String
,
VehicleInformationContainer
>
vehiclePositions
=
new
HashMap
<>();
_positonsByTimestamp
.
put
(
newStep
,
vehiclePositions
);
List
<
String
>
allVehicles
=
requestAllVehicles
();
for
(
String
vehicle
:
allVehicles
)
{
Position
vehiclePosition
=
requestVehiclePosition
(
vehicle
);
if
(
vehiclePosition
!=
null
)
{
vehiclePositions
.
put
(
vehicle
,
vehiclePosition
);
Location
position
=
requestVehiclePosition
(
vehicle
);
if
(
position
!=
null
)
{
double
heading
=
requestVehicleHeading
(
vehicle
);
double
speed
=
requestVehicleSpeed
(
vehicle
);
VehicleInformationContainer
informationContainer
=
new
VehicleInformationContainer
(
position
,
heading
,
speed
);
vehiclePositions
.
put
(
vehicle
,
informationContainer
);
}
}
}
...
...
@@ -243,12 +244,6 @@ public class TraciSimulationController implements VehicleController, SimulationS
e
.
printStackTrace
();
}
// for (RoadNetworkEdge roadNetworkEdge : modifiedEdges) {
// SumoCommand setMaxSpeedCommand = Edge.setMaxSpeed(roadNetworkEdge.getEdgeID(), roadNetworkEdge.getMaxSpeed());
//
// execute(setMaxSpeedCommand);
// }
return
true
;
}
catch
(
RuntimeException
e
)
{
throw
e
;
...
...
@@ -258,7 +253,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
return
false
;
}
private
Posi
tion
requestVehiclePosition
(
String
pVehicleID
)
{
private
Loca
tion
requestVehiclePosition
(
String
pVehicleID
)
{
if
(
_vehiclesOutOfRange
.
containsKey
(
pVehicleID
))
{
if
(
_vehiclesOutOfRange
.
get
(
pVehicleID
)
<
_step
)
{
return
null
;
...
...
@@ -268,20 +263,14 @@ public class TraciSimulationController implements VehicleController, SimulationS
}
SumoCommand
positionCommand
=
Vehicle
.
getPosition
(
pVehicleID
);
SumoCommand
angleCommand
=
Vehicle
.
getAngle
(
pVehicleID
);
SumoCommand
speedCommand
=
Vehicle
.
getSpeed
(
pVehicleID
);
Object
positionObject
=
requestObject
(
positionCommand
);
Object
angleObject
=
requestObject
(
angleCommand
);
Object
speedObject
=
requestObject
(
speedCommand
);
SumoPosition2D
sumoPosition
=
(
SumoPosition2D
)
positionObject
;
double
angle
=
(
Double
)
angleObject
;
double
speed
=
(
Double
)
speedObject
;
if
(
_observedAreaSet
)
{
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
Position
Vector
(
sumoPosition
.
x
-
_startX
,
sumoPosition
.
y
-
_startY
,
0
);
}
else
{
double
diffX
=
_startX
-
sumoPosition
.
x
;
if
(
diffX
<
0
||
sumoPosition
.
x
-
_endX
<
diffX
)
{
...
...
@@ -306,8 +295,48 @@ public class TraciSimulationController implements VehicleController, SimulationS
return
null
;
}
}
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
()
{
...
...
@@ -331,7 +360,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
@Override
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
());
}
...
...
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/xml/SimulationSetupInformationHandler.java
View file @
a7ade2b5
...
...
@@ -4,12 +4,13 @@ import org.xml.sax.Attributes;
import
org.xml.sax.SAXException
;
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
{
private
Posi
tion
_upperLeft
;
private
Posi
tion
_lowerRight
;
private
Loca
tion
_upperLeft
;
private
Loca
tion
_lowerRight
;
@Override
public
void
startElement
(
String
pUri
,
String
pLocalName
,
String
pQName
,
Attributes
pAttributes
)
...
...
@@ -18,18 +19,18 @@ public class SimulationSetupInformationHandler extends DefaultHandler {
String
meterBoundary
=
pAttributes
.
getValue
(
"convBoundary"
);
if
(
meterBoundary
!=
null
)
{
String
[]
edges
=
meterBoundary
.
split
(
","
);
_upperLeft
=
new
Position
(
Double
.
valueOf
(
edges
[
0
]),
Double
.
valueOf
(
edges
[
1
]),
0
,
0
);
_lowerRight
=
new
Position
(
Double
.
valueOf
(
edges
[
2
]),
Double
.
valueOf
(
edges
[
3
]),
0
,
0
);
_upperLeft
=
new
Position
Vector
(
Double
.
valueOf
(
edges
[
0
]),
Double
.
valueOf
(
edges
[
1
]),
0
);
_lowerRight
=
new
Position
Vector
(
Double
.
valueOf
(
edges
[
2
]),
Double
.
valueOf
(
edges
[
3
]),
0
);
}
throw
new
CancelParsingSAXException
();
}
}
public
Posi
tion
getLowerRight
()
{
public
Loca
tion
getLowerRight
()
{
return
_lowerRight
;
}
public
Posi
tion
getUpperLeft
()
{
public
Loca
tion
getUpperLeft
()
{
return
_upperLeft
;
}
}
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/xml/VehicleDataInformationHandler.java
View file @
a7ade2b5
...
...
@@ -6,12 +6,13 @@ import org.xml.sax.Attributes;
import
org.xml.sax.SAXException
;
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
{
private
boolean
_next
=
true
;
private
boolean
_run
=
true
;
private
HashMap
<
String
,
Position
>
_vehiclePositions
=
new
HashMap
<>();
private
HashMap
<
String
,
VehicleInformationContainer
>
_vehiclePositions
=
new
HashMap
<>();
private
double
_currentStep
=
-
1
;
private
boolean
_observedAreaSet
=
false
;
...
...
@@ -20,7 +21,7 @@ public class VehicleDataInformationHandler extends DefaultHandler {
private
double
_endX
=
-
1
;
private
double
_endY
=
-
1
;
private
HashMap
<
String
,
Position
>
_nextVehiclePositions
=
new
HashMap
<>();
private
HashMap
<
String
,
VehicleInformationContainer
>
_nextVehiclePositions
=
new
HashMap
<>();
private
double
_nextStep
=
-
1
;
private
static
final
String
doublePattern
=
"-?[0-9]*\\.?[0-9]+"
;
...
...
@@ -57,10 +58,10 @@ public class VehicleDataInformationHandler extends DefaultHandler {
if
(
_observedAreaSet
)
{
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
Position
Vector
(
lon
-
_startX
,
lat
-
_startY
,
0
)
,
heading
,
speed
));
}
}
else
{
_nextVehiclePositions
.
put
(
id
,
new
Position
(
lon
,
lat
,
0
,
heading
,
speed
));
_nextVehiclePositions
.
put
(
id
,
new
VehicleInformationContainer
(
new
Position
Vector
(
lon
,
lat
,
0
)
,
heading
,
speed
));
}
}
}
...
...
@@ -97,7 +98,7 @@ public class VehicleDataInformationHandler extends DefaultHandler {
return
_terminated
;
}
public
HashMap
<
String
,
Position
>
getVehiclePositions
()
{
public
HashMap
<
String
,
VehicleInformationContainer
>
getVehiclePositions
()
{
return
_vehiclePositions
;
}
...
...
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/xml/XMLSimulationController.java
View file @
a7ade2b5
...
...
@@ -10,10 +10,11 @@ import java.util.Map;
import
javax.xml.parsers.SAXParser
;
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.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.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.RoadNetworkEdge
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute
;
...
...
@@ -26,7 +27,7 @@ public class XMLSimulationController implements VehicleController, SimulationSet
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
boolean
_initalized
=
false
;
...
...
@@ -67,11 +68,11 @@ public class XMLSimulationController implements VehicleController, SimulationSet
}
@Override
public
Posi
tion
getVehiclePosition
(
String
pVehicleID
)
{
public
Loca
tion
getVehiclePosition
(
String
pVehicleID
)
{
return
getVehiclePosition
(
_step
,
pVehicleID
);
}
public
Position
requestVehicle
Posi
tion
(
String
pVehicleID
)
{
public
VehicleInformationContainer
requestVehicle
Informa
tion
(
String
pVehicleID
)
{
return
_vehicleDataInformationHandler
.
getVehiclePositions
().
get
(
pVehicleID
);
}
...
...
@@ -86,12 +87,12 @@ public class XMLSimulationController implements VehicleController, SimulationSet
double
newStep
=
_step
+
_futureInformation
;
if
(!
_positonsByTimestamp
.
containsKey
(
newStep
))
{
Map
<
String
,
Position
>
vehiclePositions
=
new
HashMap
<>();
Map
<
String
,
VehicleInformationContainer
>
vehiclePositions
=
new
HashMap
<>();
_positonsByTimestamp
.
put
(
newStep
,
vehiclePositions
);
List
<
String
>
allVehicles
=
new
ArrayList
<>(
_vehicleDataInformationHandler
.
getVehiclePositions
().
keySet
());
for
(
String
vehicle
:
allVehicles
)
{
Position
vehiclePosition
=
requestVehicle
Posi
tion
(
vehicle
);
VehicleInformationContainer
vehiclePosition
=
requestVehicle
Informa
tion
(
vehicle
);
if
(
vehiclePosition
!=
null
)
{
vehiclePositions
.
put
(
vehicle
,
vehiclePosition
);
}
...
...
@@ -135,15 +136,15 @@ public class XMLSimulationController implements VehicleController, SimulationSet
}
@Override
public
Posi
tion
getVehiclePosition
(
double
pStep
,
String
pVehicleID
)
{
Map
<
String
,
Position
>
map
=
_positonsByTimestamp
.
get
(
pStep
);
public
Loca
tion
getVehiclePosition
(
double
pStep
,
String
pVehicleID
)
{
Map
<
String
,
VehicleInformationContainer
>
map
=
_positonsByTimestamp
.
get
(
pStep
);
return
map
.
get
(
pVehicleID
);
return
map
.
get
(
pVehicleID
)
.
getPosition
()
;
}
@Override
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
());
}
...
...
@@ -156,7 +157,7 @@ public class XMLSimulationController implements VehicleController, SimulationSet
}
@Override
public
List
<
Posi
tion
>
getAllIntersections
(
boolean
pCluster
)
{
public
List
<
Loca
tion
>
getAllIntersections
(
boolean
pCluster
)
{
return
_roadSideUnitInformationHandler
.
getIntersections
();
}
...
...
src/de/tud/kom/p2psim/impl/topology/placement/RSUPlacement.java
View file @
a7ade2b5
...
...
@@ -25,11 +25,10 @@ import java.util.List;
import
de.tud.kom.p2psim.api.topology.TopologyComponent
;
import
de.tud.kom.p2psim.api.topology.placement.PlacementModel
;
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.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.information.Position
;
import
de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor
;
/**
...
...
@@ -48,7 +47,7 @@ public class RSUPlacement implements PlacementModel {
private
SimulationSetupExtractor
_controller
;
private
List
<
Posi
tion
>
_intersections
;
private
List
<
Loca
tion
>
_intersections
;
private
int
_currentIndex
=
0
;
@XMLConfigurableConstructor
({
"sumoExe"
,
"sumoConfigFile"
,
"offsetX"
,
"offsetY"
,
"width"
,
"height"
})
...
...
@@ -107,9 +106,9 @@ public class RSUPlacement implements PlacementModel {
@Override
public
PositionVector
place
(
TopologyComponent
comp
)
{
if
(
_currentIndex
<
_intersections
.
size
())
{
Posi
tion
intersection
=
_intersections
.
get
(
_currentIndex
);
Loca
tion
intersection
=
_intersections
.
get
(
_currentIndex
);
_currentIndex
++;
return
new
PositionVector
(
intersection
.
get
X
(),
intersection
.
get
Y
());
return
new
PositionVector
(
intersection
.
get
Longitude
(),
intersection
.
get
Latitude
());
}
else
{
return
new
PositionVector
(
Double
.
NaN
,
Double
.
NaN
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment