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
dc10deed
Commit
dc10deed
authored
May 09, 2019
by
Tobias Meuser
Browse files
Minor fixes in movement
parent
80c3581d
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/movement/RSUMovementModel.java
View file @
dc10deed
...
...
@@ -141,7 +141,7 @@ public class RSUMovementModel implements MovementModel {
*/
protected
void
initializeModel
()
{
if
(
this
.
sumoExe
!=
null
)
{
_controller
=
TraciSimulationController
.
createSimulationController
(
sumoExe
,
sumoConfigFile
);
_controller
=
TraciSimulationController
.
createSimulationController
(
sumoExe
,
sumoConfigFile
,
1
);
_controller
.
init
(
Time
.
SECOND
);
_controller
.
setObservedArea
(
offsetX
,
offsetY
,
offsetX
+
width
,
offsetY
+
height
);
_intersections
=
_controller
.
getAllIntersections
(
true
);
...
...
src/de/tud/kom/p2psim/impl/topology/movement/VehicleMovementModel.java
View file @
dc10deed
...
...
@@ -67,6 +67,8 @@ public class VehicleMovementModel implements MovementModel, EventHandler {
private
static
VehicleMovementModel
MOVEMENT
;
public
static
final
int
TIMESTEP_RATIO
=
5
;
private
long
timeBetweenMoveOperations
;
private
final
List
<
SimLocationActuator
>
components
;
...
...
@@ -244,10 +246,10 @@ public class VehicleMovementModel implements MovementModel, EventHandler {
protected
void
initializeModel
()
{
// Schedule first step
if
(!
initialized
)
{
Event
.
scheduleWithDelay
(
timeBetweenMoveOperations
,
this
,
null
,
0
);
Event
.
scheduleWithDelay
(
timeBetweenMoveOperations
*
TIMESTEP_RATIO
,
this
,
null
,
0
);
if
(
sumoExe
!=
null
)
{
TraciSimulationController
simulationController
=
TraciSimulationController
.
createSimulationController
(
sumoExe
,
sumoConfigFile
);
TraciSimulationController
simulationController
=
TraciSimulationController
.
createSimulationController
(
sumoExe
,
sumoConfigFile
,
TIMESTEP_RATIO
);
_controller
=
simulationController
;
_controller
.
setObservedArea
(
offsetX
,
offsetY
,
offsetX
+
width
,
offsetY
+
height
);
simulationController
.
setStartTime
(
_startTime
);
...
...
@@ -345,7 +347,7 @@ public class VehicleMovementModel implements MovementModel, EventHandler {
}
// Reschedule next step
Event
.
scheduleWithDelay
(
timeBetweenMoveOperations
,
this
,
null
,
0
);
Event
.
scheduleWithDelay
(
timeBetweenMoveOperations
*
TIMESTEP_RATIO
,
this
,
null
,
0
);
}
/**
...
...
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/VehicleInformationContainer.java
View file @
dc10deed
...
...
@@ -52,4 +52,8 @@ public class VehicleInformationContainer {
public
RoadNetworkRoute
getRoute
()
{
return
_route
;
}
public
void
setRoute
(
RoadNetworkRoute
pRoute
)
{
_route
=
pRoute
;
}
}
\ No newline at end of file
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/traci/TraciSimulationController.java
View file @
dc10deed
...
...
@@ -60,7 +60,7 @@ import it.polito.appeal.traci.SumoTraciConnection;
public
class
TraciSimulationController
implements
VehicleController
,
SimulationSetupExtractor
,
EdgeController
,
SimulatorObserver
{
private
static
final
File
TEMP_FILE
=
new
File
(
new
File
(
System
.
getProperty
(
"user.home"
)
+
"/.simonstrator"
),
"road_network.tmp"
);
private
static
final
boolean
TRAIN_PATH_PROBABILITIES
=
tru
e
;
private
static
final
boolean
TRAIN_PATH_PROBABILITIES
=
fals
e
;
private
Random
_random
=
Randoms
.
getRandom
(
getClass
());
...
...
@@ -95,16 +95,19 @@ public class TraciSimulationController implements VehicleController, SimulationS
private
RoutingAlgorithm
_algorithm
=
new
DijkstraAlgorithm
();
public
static
synchronized
TraciSimulationController
createSimulationController
(
String
pSumoExe
,
String
pConfigFile
)
{
private
int
_timestepRatio
;
public
static
synchronized
TraciSimulationController
createSimulationController
(
String
pSumoExe
,
String
pConfigFile
,
int
pTimestepRatio
)
{
if
(!
CONTROLLER
.
containsKey
(
pConfigFile
))
{
CONTROLLER
.
put
(
pConfigFile
,
new
TraciSimulationController
(
pSumoExe
,
pConfigFile
));
CONTROLLER
.
put
(
pConfigFile
,
new
TraciSimulationController
(
pSumoExe
,
pConfigFile
,
pTimestepRatio
));
}
return
CONTROLLER
.
get
(
pConfigFile
);
}
private
TraciSimulationController
(
String
pSumoExe
,
String
pConfigFile
)
{
private
TraciSimulationController
(
String
pSumoExe
,
String
pConfigFile
,
int
pTimestepRatio
)
{
_sumoExe
=
pSumoExe
;
_configFile
=
pConfigFile
;
_timestepRatio
=
pTimestepRatio
;
}
public
void
setStartTime
(
int
pStartTime
)
{
...
...
@@ -127,6 +130,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
* prevent vehicles form teleporting (http://sumo.dlr.de/wiki/Simulation/Why_Vehicles_are_teleporting)
*/
_connection
.
addOption
(
"time-to-teleport"
,
Integer
.
toString
(-
1
));
_connection
.
addOption
(
"step-length"
,
String
.
valueOf
(
pTimeScale
/
(
double
)
Time
.
SECOND
));
try
{
_connection
.
runServer
();
...
...
@@ -146,7 +150,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
if
(
TRAIN_PATH_PROBABILITIES
)
{
Map
<
String
,
VehicleInformationContainer
>
positions
=
nextStep
();
for
(
Entry
<
String
,
VehicleInformationContainer
>
entry
:
positions
.
entrySet
())
{
VehiclePathTrackerFactory
.
getVehiclePathTracker
().
setEdge
(
entry
.
getKey
(),
entry
.
getValue
().
getRoute
().
getStart
(),
i
*
Time
.
SECOND
);
VehiclePathTrackerFactory
.
getVehiclePathTracker
().
setEdge
(
entry
.
getKey
(),
entry
.
getValue
().
getRoute
().
getStart
(),
i
*
p
Time
Scale
);
}
}
else
{
try
{
...
...
@@ -246,7 +250,9 @@ public class TraciSimulationController implements VehicleController, SimulationS
private
Map
<
String
,
VehicleInformationContainer
>
nextStep
()
{
try
{
_connection
.
do_timestep
();
for
(
int
i
=
0
;
i
<
_timestepRatio
;
i
++)
{
_connection
.
do_timestep
();
}
try
{
Map
<
String
,
VehicleInformationContainer
>
vehiclePositions
=
new
HashMap
<>();
...
...
@@ -453,7 +459,11 @@ public class TraciSimulationController implements VehicleController, SimulationS
add
=
true
;
}
if
(
add
)
{
streets
.
add
(
_roadNetwork
.
getEdge
(
street
));
RoadNetworkEdge
edge
=
_roadNetwork
.
getEdge
(
street
);
streets
.
add
(
edge
);
if
(!
edge
.
isUsable
())
{
break
;
}
}
}
...
...
@@ -655,6 +665,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
routeEdges
.
add
(
edge
.
getEdgeID
());
}
execute
(
Vehicle
.
setRoute
(
pVehicle
,
routeEdges
));
_positons
.
get
(
pVehicle
).
setRoute
(
pRoute
);
}
@Override
...
...
@@ -888,10 +899,12 @@ public class TraciSimulationController implements VehicleController, SimulationS
if
(
_observedAreaSet
)
{
List
<
RoadNetworkLane
>
lanes
=
_roadNetwork
.
getEdge
(
pEdgeID
).
getLanes
();
if
(
lanes
.
size
()
>
0
)
{
List
<
Location
>
laneShape
=
getLaneShape
(
lanes
.
get
(
0
).
getLaneID
());
if
(
laneShape
.
size
()
>
1
)
{
return
true
;
}
for
(
RoadNetworkLane
lane
:
lanes
)
{
List
<
Location
>
laneShape
=
getLaneShape
(
lane
.
getLaneID
());
if
(
laneShape
.
size
()
>
1
)
{
return
true
;
}
}
}
return
false
;
}
...
...
src/de/tud/kom/p2psim/impl/topology/placement/RSUPlacement.java
View file @
dc10deed
...
...
@@ -87,7 +87,7 @@ public class RSUPlacement implements PlacementModel {
*/
protected
void
initializeModel
()
{
if
(
this
.
sumoExe
!=
null
)
{
_controller
=
TraciSimulationController
.
createSimulationController
(
sumoExe
,
sumoConfigFile
);
_controller
=
TraciSimulationController
.
createSimulationController
(
sumoExe
,
sumoConfigFile
,
1
);
_controller
.
init
(
Time
.
SECOND
);
_controller
.
setObservedArea
(
offsetX
,
offsetY
,
offsetX
+
width
,
offsetY
+
height
);
_intersections
=
_controller
.
getAllIntersections
(
true
);
...
...
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