eclipse-sumo / sumo

Eclipse SUMO is an open source, highly portable, microscopic and continuous traffic simulation package designed to handle large networks. It allows for intermodal simulation including pedestrians and comes with a large set of tools for scenario creation.
https://eclipse.dev/sumo
Eclipse Public License 2.0
2.57k stars 1.44k forks source link

Failure of Vehicle.setRoute by startEdgeID (junction) in TraaS #5718

Closed YenKang closed 5 years ago

YenKang commented 5 years ago

When I execute setRoute function and the current Edge of the vehicle is the junction whoes ID is ":cluster_1240288780_2365426109_0", the system would crash due to the error of route arrangement.

The sumo console showd the error message

Warning: Invalid route replacement for vehicle '1'. No connection between edge '381410220#2' and edge ':cluster_1240288780_2365426109_0'. Error: Answered with error to command 0xc4: Route replacement failed for 1 Error: tcpip::Socket::recvAndCheck @ recv: peer shutdown Quitting (on error).

My codes

String vType ="truck"; 
double depart = 0.0; 
int routingMode = 0;
String startEdgeID = ":cluster_1240288780_2365426109_0";
String endEdgeID= "30438916#0";
SumoStage stage = (SumoStage)conn.do_job_get(Simulation.findRoute(startEdgeID, 
    endEdgeID, vType, depart,routingMode));

LinkedList<String> v1_route_from_Junctions_to_validEdge = new LinkedList<String>(); 

for (String edge :stage.edges){ 
    v1_route_from_Junctions_to_validEdge.add(edge); 
}

System.out.println("v1_route_from_Junctions_to_validEdge:"+ v1_route_from_Junctions_to_validEdge);
conn.do_job_set(Vehicle.setRoute("1", stage.edges));

My outpot console

currentEdgeId::cluster_3846116384_5209464726_10

converted_road_Edge::cluster_3846116384_5209464726_10

v1_route_from_Junctions_to_validEdge:[:cluster_1240288780_2365426109_0, 227913949#0, 298271086#1, 30438916#0]

it.polito.appeal.traci.TraCIException: SUMO error for command 196: Route replacement failed for 1

My questuion

Is any solution for us to setRoute by "junction"?

behrisch commented 5 years ago

You can give the edge following the internal edge as first edge of the routing. There is currently no way to find this edge via traci / traas. You will need to parse the network or use sumolib to do so.

namdre commented 5 years ago

You should also be able to retrieve the subsequent edge using lane.getLinks(internalLaneID)