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
056e56ef
Commit
056e56ef
authored
Nov 14, 2017
by
Tobias Meuser
Browse files
Additional features for vehicle controller
parent
053e7093
Changes
5
Show whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/movement/VehicleMovementModel.java
View file @
056e56ef
...
@@ -268,14 +268,6 @@ public class VehicleMovementModel implements MovementModel, EventHandler {
...
@@ -268,14 +268,6 @@ public class VehicleMovementModel implements MovementModel, EventHandler {
}
}
SimLocationActuator
component
=
requestSimActuator
(
vehicle
);
SimLocationActuator
component
=
requestSimActuator
(
vehicle
);
if
(
scenarioHeight
!=
-
1
)
{
component
.
updateCurrentLocation
(
new
PositionVector
(
position
.
getLongitude
(),
Math
.
min
(
scenarioHeight
,
height
)
-
position
.
getLatitude
()));
}
else
{
// This would be vertically mirrored
component
.
updateCurrentLocation
(
new
PositionVector
(
position
.
getLongitude
(),
position
.
getLatitude
()));
}
component
.
setMovementSpeed
(
position
.
getSpeed
());
try
{
try
{
RoutedNetLayer
routedNetLayer
=
component
.
getHost
().
getComponent
(
RoutedNetLayer
.
class
);
RoutedNetLayer
routedNetLayer
=
component
.
getHost
().
getComponent
(
RoutedNetLayer
.
class
);
...
@@ -287,6 +279,16 @@ public class VehicleMovementModel implements MovementModel, EventHandler {
...
@@ -287,6 +279,16 @@ public class VehicleMovementModel implements MovementModel, EventHandler {
}
catch
(
ComponentNotAvailableException
e
)
{
}
catch
(
ComponentNotAvailableException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
if
(
scenarioHeight
!=
-
1
)
{
component
.
updateCurrentLocation
(
new
PositionVector
(
position
.
getLongitude
(),
Math
.
min
(
scenarioHeight
,
height
)
-
position
.
getLatitude
()));
}
else
{
// This would be vertically mirrored
component
.
updateCurrentLocation
(
new
PositionVector
(
position
.
getLongitude
(),
position
.
getLatitude
()));
}
component
.
setMovementSpeed
(
_controller
.
getVehicleSpeed
(
vehicle
));
}
}
if
(
allVehicles
.
size
()
!=
idComponentMatcher
.
size
())
{
if
(
allVehicles
.
size
()
!=
idComponentMatcher
.
size
())
{
...
...
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/traci/TraciSimulationController.java
View file @
056e56ef
...
@@ -58,8 +58,6 @@ public class TraciSimulationController implements VehicleController, SimulationS
...
@@ -58,8 +58,6 @@ public class TraciSimulationController implements VehicleController, SimulationS
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
;
...
@@ -650,6 +648,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
...
@@ -650,6 +648,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
}
}
}
}
}
}
SumoCommand
laneIDCommand
=
Lane
.
getIDList
();
SumoCommand
laneIDCommand
=
Lane
.
getIDList
();
Map
<
String
,
RoadNetworkEdge
>
roadNetwork
=
new
HashMap
<>();
Map
<
String
,
RoadNetworkEdge
>
roadNetwork
=
new
HashMap
<>();
...
@@ -695,7 +694,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
...
@@ -695,7 +694,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
}
}
_roadNetwork
=
new
RoadNetwork
(
roadNetwork
);
_roadNetwork
=
new
RoadNetwork
(
roadNetwork
,
this
,
true
);
try
{
try
{
ObjectOutputStream
outputStream
=
new
ObjectOutputStream
(
new
FileOutputStream
(
TEMP_FILE
));
ObjectOutputStream
outputStream
=
new
ObjectOutputStream
(
new
FileOutputStream
(
TEMP_FILE
));
...
@@ -734,6 +733,30 @@ public class TraciSimulationController implements VehicleController, SimulationS
...
@@ -734,6 +733,30 @@ public class TraciSimulationController implements VehicleController, SimulationS
return
angle
;
return
angle
;
}
}
@Override
public
Location
getEdgeMeanPosition
(
String
pEdgeID
)
{
List
<
SumoPosition2D
>
positions
=
new
ArrayList
<>();
for
(
RoadNetworkLane
lane
:
_roadNetwork
.
getEdge
(
pEdgeID
).
getLanes
())
{
String
laneID
=
lane
.
getLaneID
();
SumoCommand
laneShapeCommand
=
Lane
.
getShape
(
laneID
);
SumoGeometry
geometry
=
(
SumoGeometry
)
requestObject
(
laneShapeCommand
);
positions
.
addAll
(
geometry
.
coords
);
}
double
x
=
0
;
double
y
=
0
;
int
count
=
0
;
for
(
SumoPosition2D
sumoPosition2D
:
positions
)
{
x
+=
sumoPosition2D
.
x
;
y
+=
sumoPosition2D
.
y
;
count
++;
}
return
new
PositionVector
(
x
/
(
count
),
y
/
(
count
));
}
@Override
@Override
public
double
getVehicleSpeed
(
String
pVehicleID
)
{
public
double
getVehicleSpeed
(
String
pVehicleID
)
{
SumoCommand
speedCommand
=
Vehicle
.
getSpeed
(
pVehicleID
);
SumoCommand
speedCommand
=
Vehicle
.
getSpeed
(
pVehicleID
);
...
@@ -742,6 +765,14 @@ public class TraciSimulationController implements VehicleController, SimulationS
...
@@ -742,6 +765,14 @@ public class TraciSimulationController implements VehicleController, SimulationS
return
(
Double
)
object
;
return
(
Double
)
object
;
}
}
@Override
public
double
getLastStepMeanSpeed
(
String
pEdgeID
)
{
SumoCommand
speedCommand
=
Edge
.
getLastStepMeanSpeed
(
pEdgeID
);
Object
object
=
requestObject
(
speedCommand
);
return
(
Double
)
object
;
}
@Override
@Override
public
void
setEdgeMaxSpeed
(
String
pEdgeID
,
double
pMaxSpeed
)
{
public
void
setEdgeMaxSpeed
(
String
pEdgeID
,
double
pMaxSpeed
)
{
SumoCommand
setMaxSpeedCommand
=
Edge
.
setMaxSpeed
(
pEdgeID
,
pMaxSpeed
);
SumoCommand
setMaxSpeedCommand
=
Edge
.
setMaxSpeed
(
pEdgeID
,
pMaxSpeed
);
...
@@ -753,4 +784,44 @@ public class TraciSimulationController implements VehicleController, SimulationS
...
@@ -753,4 +784,44 @@ public class TraciSimulationController implements VehicleController, SimulationS
edge
.
setMaxSpeed
(
pMaxSpeed
);
edge
.
setMaxSpeed
(
pMaxSpeed
);
}
}
/**
* @return the startX
*/
@Override
public
double
getStartX
()
{
return
_startX
;
}
/**
* @return the startY
*/
@Override
public
double
getStartY
()
{
return
_startY
;
}
/**
* @return the endX
*/
@Override
public
double
getEndX
()
{
return
_endX
;
}
/**
* @return the endY
*/
@Override
public
double
getEndY
()
{
return
_endY
;
}
/**
* @return the observedAreaSet
*/
@Override
public
boolean
isObservedAreaSet
()
{
return
_observedAreaSet
;
}
}
}
src/de/tud/kom/p2psim/impl/vehicular/DefaultVehicleInformationComponent.java
View file @
056e56ef
...
@@ -21,9 +21,18 @@
...
@@ -21,9 +21,18 @@
package
de.tud.kom.p2psim.impl.vehicular
;
package
de.tud.kom.p2psim.impl.vehicular
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
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.route.Route
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.route.Route
;
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
;
...
@@ -46,6 +55,37 @@ public class DefaultVehicleInformationComponent implements VehicleInformationCom
...
@@ -46,6 +55,37 @@ public class DefaultVehicleInformationComponent implements VehicleInformationCom
this
.
controller
=
controller
;
this
.
controller
=
controller
;
this
.
extractor
=
extractor
;
this
.
extractor
=
extractor
;
try
{
SiSComponent
siSComponent
=
getHost
().
getComponent
(
SiSComponent
.
class
);
siSComponent
.
provide
().
nodeState
(
SiSTypes
.
ROAD_EDGE
,
new
SiSDataCallback
<
RoadNetworkEdge
>()
{
@Override
public
RoadNetworkEdge
getValue
(
INodeID
pNodeID
,
SiSProviderHandle
pProviderHandle
)
throws
InformationNotAvailableException
{
if
(
pNodeID
==
getHost
().
getId
())
{
if
(
isValid
())
{
return
getCurrentRoute
().
getStart
();
}
}
return
null
;
}
@Override
public
Set
<
INodeID
>
getObservedNodes
()
{
return
INodeID
.
getSingleIDSet
(
getHost
().
getId
());
}
@Override
public
SiSInfoProperties
getInfoProperties
()
{
return
new
SiSInfoProperties
();
}
});
}
catch
(
ComponentNotAvailableException
e
)
{
// Nothing to do!
}
}
}
@Override
@Override
...
@@ -106,6 +146,11 @@ public class DefaultVehicleInformationComponent implements VehicleInformationCom
...
@@ -106,6 +146,11 @@ public class DefaultVehicleInformationComponent implements VehicleInformationCom
}
}
}
}
@Override
public
boolean
isValid
()
{
return
vehicleID
!=
null
;
}
@Override
@Override
public
void
stopVehicle
()
{
public
void
stopVehicle
()
{
controller
.
stopVehicle
(
vehicleID
);
controller
.
stopVehicle
(
vehicleID
);
...
...
src/de/tud/kom/p2psim/impl/vehicular/caching/decision/OptimalCacheDecisionStrategy.java
View file @
056e56ef
...
@@ -22,15 +22,12 @@ package de.tud.kom.p2psim.impl.vehicular.caching.decision;
...
@@ -22,15 +22,12 @@ package de.tud.kom.p2psim.impl.vehicular.caching.decision;
import
java.util.List
;
import
java.util.List
;
import
de.tud.kom.p2psim.impl.topology.movement.VehicleMovementModel
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.caching.decision.CacheDecisionStrategy
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.caching.decision.CacheDecisionStrategy
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.AvailableInformationAttributes
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.PointInformation
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.PointInformation
;
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
;
public
class
OptimalCacheDecisionStrategy
implements
CacheDecisionStrategy
{
public
class
OptimalCacheDecisionStrategy
implements
CacheDecisionStrategy
{
private
RoadNetwork
_roadNetwork
;
public
OptimalCacheDecisionStrategy
()
{
public
OptimalCacheDecisionStrategy
()
{
}
}
...
@@ -44,14 +41,10 @@ public class OptimalCacheDecisionStrategy implements CacheDecisionStrategy {
...
@@ -44,14 +41,10 @@ public class OptimalCacheDecisionStrategy implements CacheDecisionStrategy {
return
null
;
return
null
;
}
}
if
(
_roadNetwork
==
null
)
{
RoadNetworkEdge
edge
=
(
RoadNetworkEdge
)
pSimilarPointInformation
.
get
(
0
).
getAttribute
(
AvailableInformationAttributes
.
EDGE
);
_roadNetwork
=
VehicleMovementModel
.
getRoadNetwork
();
}
RoadNetworkEdge
edge
=
_roadNetwork
.
getEdge
(
"A5.8"
);
boolean
jam
=
false
;
boolean
jam
=
false
;
if
(
edge
.
get
Max
Speed
()
<
1
)
{
if
(
edge
.
get
LastStepMean
Speed
()
<
5
)
{
jam
=
true
;
jam
=
true
;
}
}
...
...
src/de/tud/kom/p2psim/impl/vehicular/relevance/PredictionBasedEventRelevanceCalculationComponent.java
deleted
100755 → 0
View file @
053e7093
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.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.vehicular.relevance
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.PriorityQueue
;
import
java.util.Queue
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.VehicleInformationComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.VehicularPointInformation
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.relevance.EventRelevanceCalculationComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
public
class
PredictionBasedEventRelevanceCalculationComponent
implements
EventRelevanceCalculationComponent
{
private
static
final
double
ABORT_THRESHOLD
=
0.001d
;
private
Host
_host
;
public
PredictionBasedEventRelevanceCalculationComponent
(
Host
pHost
)
{
_host
=
pHost
;
}
@Override
public
double
calculateRelevance
(
VehicleInformationComponent
pVehicle
,
VehicularPointInformation
pInformation
)
{
double
relevance
=
0
;
RoadNetworkEdge
eventLocation
=
pInformation
.
getEdge
();
Queue
<
RoadNetworkPath
>
currentPaths
=
new
PriorityQueue
<>(
new
RoadNetworkPathComperator
());
RoadNetworkEdge
currentVehiclePosition
=
pVehicle
.
getCurrentRoute
().
getStart
();
currentPaths
.
add
(
new
RoadNetworkPath
(
currentVehiclePosition
,
1
,
0
));
while
(!
currentPaths
.
isEmpty
())
{
RoadNetworkPath
roadNetworkPath
=
currentPaths
.
poll
();
if
(
roadNetworkPath
.
getProbability
()
<
ABORT_THRESHOLD
)
{
break
;
}
List
<
RoadNetworkEdge
>
accessibleEdges
=
roadNetworkPath
.
getEdge
().
getAccessibleEdges
();
for
(
RoadNetworkEdge
accessibleEdge
:
accessibleEdges
)
{
double
accessibleEdgeProbability
=
1
/
((
double
)
accessibleEdges
.
size
());
long
travelTime
=
Time
.
SECOND
;
if
(
accessibleEdge
==
eventLocation
)
{
long
totalTravelTime
=
roadNetworkPath
.
getTravelTime
();
double
totalProbability
=
roadNetworkPath
.
getProbability
();
double
temporalRelevance
=
calculateTemporalRelevance
(
pVehicle
,
Time
.
getCurrentTime
()
+
totalTravelTime
,
pInformation
);
relevance
+=
totalProbability
*
temporalRelevance
;
}
else
{
RoadNetworkPath
newPath
=
roadNetworkPath
.
createPath
(
accessibleEdge
,
accessibleEdgeProbability
,
travelTime
);
currentPaths
.
add
(
newPath
);
}
}
}
return
relevance
;
}
/**
* This method calculates the temporal relevance of an event for a vehicle
* at a certain point in time.
*
* @param pVehicle
* The vehicle for which the information is relevant.
* @param pTime
* The time for which the relevance should be calculated.
* @param pInformation
* The information for which the relevance is calculated.
* @return The temporal relevance of the event.
*/
private
double
calculateTemporalRelevance
(
VehicleInformationComponent
pVehicle
,
double
pTime
,
VehicularPointInformation
pInformation
)
{
return
1
;
}
private
class
RoadNetworkPathComperator
implements
Comparator
<
RoadNetworkPath
>
{
public
RoadNetworkPathComperator
()
{
}
@Override
public
int
compare
(
RoadNetworkPath
pPath0
,
RoadNetworkPath
pPath1
)
{
return
Double
.
compare
(
pPath0
.
getProbability
(),
pPath1
.
getProbability
());
}
}
private
class
RoadNetworkPath
{
private
double
probability
;
private
long
travelTime
;
private
RoadNetworkEdge
edge
;
public
RoadNetworkPath
(
RoadNetworkEdge
pEdge
,
double
pProbability
,
long
pTravelTime
)
{
edge
=
pEdge
;
probability
=
pProbability
;
travelTime
=
pTravelTime
;
}
public
RoadNetworkEdge
getEdge
()
{
return
edge
;
}
public
double
getProbability
()
{
return
probability
;
}
public
long
getTravelTime
()
{
return
travelTime
;
}
public
RoadNetworkPath
createPath
(
RoadNetworkEdge
pCurrentEdge
,
double
pProbability
,
long
pTravelTime
)
{
return
new
RoadNetworkPath
(
pCurrentEdge
,
getProbability
()
*
pProbability
,
getTravelTime
()
+
pTravelTime
);
}
}
@Override
public
void
initialize
()
{
}
@Override
public
void
shutdown
()
{
}
@Override
public
Host
getHost
()
{
return
_host
;
}
}
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