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
a26dad62
Commit
a26dad62
authored
Jul 05, 2017
by
Tobias Meuser
Committed by
Jose Ignacio Monreal Bailey
Aug 20, 2019
Browse files
Fixed bug preventing rerouting on internal edges
parent
8b07b101
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/traci/TraciSimulationController.java
View file @
a26dad62
...
@@ -290,21 +290,42 @@ public class TraciSimulationController implements VehicleController, SimulationS
...
@@ -290,21 +290,42 @@ public class TraciSimulationController implements VehicleController, SimulationS
return
new
ArrayList
<>(
map
.
keySet
());
return
new
ArrayList
<>(
map
.
keySet
());
}
}
public
RoadNetworkEdge
getCurrentEdge
(
String
pVehicleID
)
{
obtainRoadNetwork
();
SumoCommand
roadIDCommand
=
Vehicle
.
getRoadID
(
pVehicleID
);
String
currentRoadID
=
(
String
)
requestObject
(
roadIDCommand
);
RoadNetworkEdge
edge
=
_roadNetwork
.
getEdge
(
currentRoadID
);
while
(
edge
.
isInternal
())
{
if
(
edge
.
getAccessibleEdges
().
size
()
==
1
)
{
edge
=
edge
.
getAccessibleEdges
().
get
(
0
);
}
else
{
break
;
}
}
return
edge
;
}
@Override
@Override
public
RoadNetworkRoute
getCurrentRoute
(
String
pVehicleID
)
{
public
RoadNetworkRoute
getCurrentRoute
(
String
pVehicleID
)
{
obtainRoadNetwork
();
SumoCommand
routeCommand
=
Vehicle
.
getRoute
(
pVehicleID
);
SumoCommand
routeCommand
=
Vehicle
.
getRoute
(
pVehicleID
);
Object
object
=
requestObject
(
routeCommand
);
Object
object
=
requestObject
(
routeCommand
);
SumoStringList
streetList
=
(
SumoStringList
)
object
;
SumoStringList
streetList
=
(
SumoStringList
)
object
;
SumoCommand
roadIDCommand
=
Vehicle
.
getRoadID
(
pVehicleID
);
RoadNetworkEdge
currentEdge
=
getCurrentEdge
(
pVehicleID
);
String
currentRoadID
=
(
String
)
requestObject
(
roadIDCommand
);
obtainRoadNetwork
();
if
(
currentEdge
==
null
)
{
return
null
;
}
List
<
RoadNetworkEdge
>
streets
=
new
ArrayList
<>();
List
<
RoadNetworkEdge
>
streets
=
new
ArrayList
<>();
boolean
add
=
false
;
boolean
add
=
false
;
for
(
String
street
:
streetList
)
{
for
(
String
street
:
streetList
)
{
if
(
street
.
equals
(
current
RoadID
))
{
if
(
street
.
equals
(
current
Edge
.
getEdgeID
()
))
{
add
=
true
;
add
=
true
;
}
}
if
(
add
)
{
if
(
add
)
{
...
@@ -314,9 +335,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
...
@@ -314,9 +335,7 @@ public class TraciSimulationController implements VehicleController, SimulationS
if
(
streets
.
size
()
==
0
)
{
if
(
streets
.
size
()
==
0
)
{
for
(
String
street
:
streetList
)
{
return
new
RoadNetworkRoute
(
new
ArrayList
<>());
streets
.
add
(
_roadNetwork
.
getEdge
(
street
));
}
}
}
return
new
RoadNetworkRoute
(
streets
);
return
new
RoadNetworkRoute
(
streets
);
...
@@ -418,6 +437,11 @@ public class TraciSimulationController implements VehicleController, SimulationS
...
@@ -418,6 +437,11 @@ public class TraciSimulationController implements VehicleController, SimulationS
public
RoadNetworkRoute
findNewRoute
(
String
pVehicle
)
throws
NoAdditionalRouteAvailableException
{
public
RoadNetworkRoute
findNewRoute
(
String
pVehicle
)
throws
NoAdditionalRouteAvailableException
{
List
<
RoadNetworkRoute
>
routes
=
new
ArrayList
<>();
List
<
RoadNetworkRoute
>
routes
=
new
ArrayList
<>();
RoadNetworkRoute
route
=
getCurrentRoute
(
pVehicle
);
RoadNetworkRoute
route
=
getCurrentRoute
(
pVehicle
);
if
(
route
.
getRoute
().
isEmpty
())
{
return
null
;
}
routes
.
add
(
route
);
routes
.
add
(
route
);
RoadNetworkRoute
findRoute
=
_algorithm
.
findRoute
(
_roadNetwork
,
route
.
getStart
(),
route
.
getDestination
(),
routes
);
RoadNetworkRoute
findRoute
=
_algorithm
.
findRoute
(
_roadNetwork
,
route
.
getStart
(),
route
.
getDestination
(),
routes
);
if
(
findRoute
==
null
)
{
if
(
findRoute
==
null
)
{
...
@@ -431,6 +455,11 @@ public class TraciSimulationController implements VehicleController, SimulationS
...
@@ -431,6 +455,11 @@ public class TraciSimulationController implements VehicleController, SimulationS
if
(
pKeepDestination
)
{
if
(
pKeepDestination
)
{
List
<
RoadNetworkRoute
>
routes
=
new
ArrayList
<>();
List
<
RoadNetworkRoute
>
routes
=
new
ArrayList
<>();
RoadNetworkRoute
route
=
getCurrentRoute
(
pVehicle
);
RoadNetworkRoute
route
=
getCurrentRoute
(
pVehicle
);
if
(
route
.
getRoute
().
isEmpty
())
{
return
null
;
}
routes
.
add
(
route
);
routes
.
add
(
route
);
RoadNetworkRoute
findRoute
=
_algorithm
.
findRoute
(
_roadNetwork
,
route
.
getStart
(),
route
.
getDestination
(),
routes
,
pEdgesToAvoid
);
RoadNetworkRoute
findRoute
=
_algorithm
.
findRoute
(
_roadNetwork
,
route
.
getStart
(),
route
.
getDestination
(),
routes
,
pEdgesToAvoid
);
...
@@ -440,6 +469,11 @@ public class TraciSimulationController implements VehicleController, SimulationS
...
@@ -440,6 +469,11 @@ public class TraciSimulationController implements VehicleController, SimulationS
return
findRoute
;
return
findRoute
;
}
else
{
}
else
{
RoadNetworkRoute
route
=
getCurrentRoute
(
pVehicle
);
RoadNetworkRoute
route
=
getCurrentRoute
(
pVehicle
);
if
(
route
.
getRoute
().
isEmpty
())
{
return
null
;
}
List
<
RoadNetworkEdge
>
routeList
=
route
.
getRoute
();
List
<
RoadNetworkEdge
>
routeList
=
route
.
getRoute
();
RoadNetworkEdge
lastEdge
=
null
;
RoadNetworkEdge
lastEdge
=
null
;
...
...
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