In traffic simulation, intersection is the basic unit that we often need to meet. When simulating the traffic flow through the intersection, if you use the previous method, you need to define three traffic flows and move in three different directions. However, in sumo, the simulation of traffic turning at an intersection is realized by jtrouter command. The simulation of traffic flow is carried out by providing the probability of three turns. You can go to Official website see.
To define a steering simulation, three parts need to be defined: road network, probability of steering in each direction and traffic flow.
In the following example, the intersection used earlier is used, and the file name is cross_rode_2.net.xml
(if you use as like as two peas of road documents, there are no roads connecting, and minor changes are needed).
1. Prepare flow document
Use the method of writing traffic flow mentioned above to write the file. The code is as follows, named flows flows. xml:
<flowdefs> <flow id="f1" from='E1' begin='0' end='100' number='100'/> </flowdefs>
The code defines the traffic flow from E1 road.
2. Preparation of turn documents
Write the steering vehicle. The code is as follows: flows_turn.turns.xml:
<turns> <interval begin="0" end="3600"> <edgeRelation from="E1" to="-E2" probability="0.2"/> <edgeRelation from="E1" to="-E3" probability="0.7"/> <edgeRelation from="E1" to="E0" probability="0.1"/> </interval> </turns>
The code defines the probability of vehicles coming from E1 turning to each road. The probability of turning left, straight and right from top to bottom is 0.2, 0.7 and 0.1 respectively.
3. Generate routing file by combining flow and turn
In cmd, switch the path to the location where the file is stored. My path is D:/sumo/project. Type the following command:
jtrrouter --route-files=flows.flows.xml --turn-ratio-files=flows_turn.turns.xml --net-file=cross_road_2.net.xml --output-file=cross_turn.rou.xml --accept-all-destinations=t
The last -- accept all destinations = t is to receive all destinations. An error will be reported if it is not run. Of course, if you add < sink edges = "< edge_id > [< edge_id >] *" / > the edge where the surface can go out, you can also.
4. Combined with the previous part sumocfg file.
The code of this part is as follows:
<configuration> <input> <net-file value="cross_road_2.net.xml"/> <route-files value="cross_trun.rou.xml"/> </input> <time> <begin value="0"/> <end value="100000"/> </time> </configuration>
Pay attention to the file names of road network files and routing files, and modify them according to the actual situation.
5. Simulation results
Open the above in sumo GUI sumocfg file can be used for simulation. The specific simulation steps have been introduced in the previous article. The simulation results are as follows:
Finally, the code of road network file is attached. (because it has been modified from the previous one)
<?xml version="1.0" encoding="UTF-8"?> <!-- generated on 2021-12-20 10:54:31 by Eclipse SUMO netedit Version 1.11.0 <configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/netconvertConfiguration.xsd"> <input> <sumo-net-file value="D:\sumo\project\cross_road_2.net.xml"/> </input> <output> <output-file value="D:\sumo\project\cross_road_2.net.xml"/> </output> <processing> <geometry.min-radius.fix.railways value="false"/> <geometry.max-grade.fix value="false"/> <offset.disable-normalization value="true"/> <lefthand value="false"/> </processing> <junctions> <no-turnarounds value="true"/> <junctions.corner-detail value="5"/> <junctions.limit-turn-speed value="5.5"/> <rectangular-lane-cut value="false"/> </junctions> <pedestrian> <walkingareas value="false"/> </pedestrian> <report> <aggregate-warnings value="5"/> </report> </configuration> --> <net version="1.9" junctionCornerDetail="5" limitTurnSpeed="5.50" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/net_file.xsd"> <location netOffset="0.00,0.00" convBoundary="-100.00,-100.00,100.00,100.00" origBoundary="-10000000000.00,-10000000000.00,10000000000.00,10000000000.00" projParameter="!"/> <edge id=":J0_0" function="internal"> <lane id=":J0_0_0" index="0" speed="6.51" length="9.03" shape="-8.00,13.60 -8.35,11.15 -9.40,9.40 -11.15,8.35 -13.60,8.00"/> </edge> <edge id=":J0_1" function="internal"> <lane id=":J0_1_0" index="0" speed="13.89" length="27.20" shape="-8.00,13.60 -8.00,-13.60"/> <lane id=":J0_1_1" index="1" speed="13.89" length="27.20" shape="-4.80,13.60 -4.80,-13.60"/> <lane id=":J0_1_2" index="2" speed="13.89" length="27.20" shape="-1.60,13.60 -1.60,-13.60"/> </edge> <edge id=":J0_4" function="internal"> <lane id=":J0_4_0" index="0" speed="10.36" length="7.98" shape="-1.60,13.60 -0.65,6.95 -0.00,5.87"/> </edge> <edge id=":J0_19" function="internal"> <lane id=":J0_19_0" index="0" speed="10.36" length="16.53" shape="-0.00,5.87 2.20,2.20 6.95,-0.65 13.60,-1.60"/> </edge> <edge id=":J0_5" function="internal"> <lane id=":J0_5_0" index="0" speed="6.51" length="9.03" shape="13.60,8.00 11.15,8.35 9.40,9.40 8.35,11.15 8.00,13.60"/> </edge> <edge id=":J0_6" function="internal"> <lane id=":J0_6_0" index="0" speed="13.89" length="27.20" shape="13.60,8.00 -13.60,8.00"/> <lane id=":J0_6_1" index="1" speed="13.89" length="27.20" shape="13.60,4.80 -13.60,4.80"/> <lane id=":J0_6_2" index="2" speed="13.89" length="27.20" shape="13.60,1.60 -13.60,1.60"/> </edge> <edge id=":J0_9" function="internal"> <lane id=":J0_9_0" index="0" speed="10.36" length="7.98" shape="13.60,1.60 6.95,0.65 5.87,0.00"/> </edge> <edge id=":J0_20" function="internal"> <lane id=":J0_20_0" index="0" speed="10.36" length="16.53" shape="5.87,0.00 2.20,-2.20 -0.65,-6.95 -1.60,-13.60"/> </edge> <edge id=":J0_10" function="internal"> <lane id=":J0_10_0" index="0" speed="13.89" length="27.20" shape="8.00,-13.60 8.00,13.60"/> <lane id=":J0_10_1" index="1" speed="13.89" length="27.20" shape="4.80,-13.60 4.80,13.60"/> <lane id=":J0_10_2" index="2" speed="13.89" length="27.20" shape="1.60,-13.60 1.60,13.60"/> </edge> <edge id=":J0_13" function="internal"> <lane id=":J0_13_0" index="0" speed="10.36" length="7.98" shape="1.60,-13.60 0.65,-6.95 0.00,-5.87"/> </edge> <edge id=":J0_21" function="internal"> <lane id=":J0_21_0" index="0" speed="10.36" length="16.53" shape="0.00,-5.87 -2.20,-2.20 -6.95,0.65 -13.60,1.60"/> </edge> <edge id=":J0_14" function="internal"> <lane id=":J0_14_0" index="0" speed="6.51" length="9.03" shape="-13.60,-8.00 -11.15,-8.35 -9.40,-9.40 -8.35,-11.15 -8.00,-13.60"/> </edge> <edge id=":J0_15" function="internal"> <lane id=":J0_15_0" index="0" speed="13.89" length="27.20" shape="-13.60,-8.00 13.60,-8.00"/> <lane id=":J0_15_1" index="1" speed="13.89" length="27.20" shape="-13.60,-4.80 13.60,-4.80"/> <lane id=":J0_15_2" index="2" speed="13.89" length="27.20" shape="-13.60,-1.60 13.60,-1.60"/> </edge> <edge id=":J0_18" function="internal"> <lane id=":J0_18_0" index="0" speed="10.36" length="7.98" shape="-13.60,-1.60 -6.95,-0.65 -5.87,-0.00"/> </edge> <edge id=":J0_22" function="internal"> <lane id=":J0_22_0" index="0" speed="10.36" length="16.53" shape="-5.87,-0.00 -2.20,2.20 0.65,6.95 1.60,13.60"/> </edge> <edge id="-E0" from="J1" to="J0" priority="-1"> <lane id="-E0_0" index="0" speed="13.89" length="86.40" shape="8.00,-100.00 8.00,-13.60"/> <lane id="-E0_1" index="1" speed="13.89" length="86.40" shape="4.80,-100.00 4.80,-13.60"/> <lane id="-E0_2" index="2" speed="13.89" length="86.40" shape="1.60,-100.00 1.60,-13.60"/> </edge> <edge id="-E1" from="J0" to="J2" priority="-1"> <lane id="-E1_0" index="0" speed="13.89" length="86.40" shape="-13.60,8.00 -100.00,8.00"/> <lane id="-E1_1" index="1" speed="13.89" length="86.40" shape="-13.60,4.80 -100.00,4.80"/> <lane id="-E1_2" index="2" speed="13.89" length="86.40" shape="-13.60,1.60 -100.00,1.60"/> </edge> <edge id="-E2" from="J0" to="J3" priority="-1"> <lane id="-E2_0" index="0" speed="13.89" length="86.40" shape="13.60,-8.00 100.00,-8.00"/> <lane id="-E2_1" index="1" speed="13.89" length="86.40" shape="13.60,-4.80 100.00,-4.80"/> <lane id="-E2_2" index="2" speed="13.89" length="86.40" shape="13.60,-1.60 100.00,-1.60"/> </edge> <edge id="-E3" from="J0" to="J4" priority="-1"> <lane id="-E3_0" index="0" speed="13.89" length="86.40" shape="8.00,13.60 8.00,100.00"/> <lane id="-E3_1" index="1" speed="13.89" length="86.40" shape="4.80,13.60 4.80,100.00"/> <lane id="-E3_2" index="2" speed="13.89" length="86.40" shape="1.60,13.60 1.60,100.00"/> </edge> <edge id="E0" from="J0" to="J1" priority="-1"> <lane id="E0_0" index="0" speed="13.89" length="86.40" shape="-8.00,-13.60 -8.00,-100.00"/> <lane id="E0_1" index="1" speed="13.89" length="86.40" shape="-4.80,-13.60 -4.80,-100.00"/> <lane id="E0_2" index="2" speed="13.89" length="86.40" shape="-1.60,-13.60 -1.60,-100.00"/> </edge> <edge id="E1" from="J2" to="J0" priority="-1"> <lane id="E1_0" index="0" speed="13.89" length="86.40" shape="-100.00,-8.00 -13.60,-8.00"/> <lane id="E1_1" index="1" speed="13.89" length="86.40" shape="-100.00,-4.80 -13.60,-4.80"/> <lane id="E1_2" index="2" speed="13.89" length="86.40" shape="-100.00,-1.60 -13.60,-1.60"/> </edge> <edge id="E2" from="J3" to="J0" priority="-1"> <lane id="E2_0" index="0" speed="13.89" length="86.40" shape="100.00,8.00 13.60,8.00"/> <lane id="E2_1" index="1" speed="13.89" length="86.40" shape="100.00,4.80 13.60,4.80"/> <lane id="E2_2" index="2" speed="13.89" length="86.40" shape="100.00,1.60 13.60,1.60"/> </edge> <edge id="E3" from="J4" to="J0" priority="-1"> <lane id="E3_0" index="0" speed="13.89" length="86.40" shape="-8.00,100.00 -8.00,13.60"/> <lane id="E3_1" index="1" speed="13.89" length="86.40" shape="-4.80,100.00 -4.80,13.60"/> <lane id="E3_2" index="2" speed="13.89" length="86.40" shape="-1.60,100.00 -1.60,13.60"/> </edge> <tlLogic id="J0" type="static" programID="0" offset="0"> <phase duration="42" state="GGGGgrrrrrGGGgrrrrr"/> <phase duration="3" state="yyyyyrrrrryyyyrrrrr"/> <phase duration="42" state="rrrrrGGGGgrrrrGGGGg"/> <phase duration="3" state="rrrrryyyyyrrrryyyyy"/> </tlLogic> <junction id="J0" type="traffic_light" x="0.00" y="0.00" incLanes="E3_0 E3_1 E3_2 E2_0 E2_1 E2_2 -E0_0 -E0_1 -E0_2 E1_0 E1_1 E1_2" intLanes=":J0_0_0 :J0_1_0 :J0_1_1 :J0_1_2 :J0_19_0 :J0_5_0 :J0_6_0 :J0_6_1 :J0_6_2 :J0_20_0 :J0_10_0 :J0_10_1 :J0_10_2 :J0_21_0 :J0_14_0 :J0_15_0 :J0_15_1 :J0_15_2 :J0_22_0" shape="-9.60,13.60 9.60,13.60 10.04,11.38 10.60,10.60 11.38,10.04 12.38,9.71 13.60,9.60 13.60,-9.60 11.38,-10.04 10.60,-10.60 10.04,-11.38 9.71,-12.38 9.60,-13.60 -9.60,-13.60 -10.04,-11.38 -10.60,-10.60 -11.38,-10.04 -12.38,-9.71 -13.60,-9.60 -13.60,9.60 -11.38,10.04 -10.60,10.60 -10.04,11.38 -9.71,12.38"> <request index="0" response="0000000000000000000" foes="0000000000111000000" cont="0"/> <request index="1" response="1000000001000000000" foes="1111110001111000000" cont="0"/> <request index="2" response="1000000001000000000" foes="1111110001111000000" cont="0"/> <request index="3" response="1000000001000000000" foes="1111110001111000000" cont="0"/> <request index="4" response="1000001111000000000" foes="1111001111111000000" cont="1"/> <request index="5" response="0000001110000000000" foes="0000001110000000000" cont="0"/> <request index="6" response="0000011110000011111" foes="1000011110000011111" cont="0"/> <request index="7" response="0000011110000011111" foes="1000011110000011111" cont="0"/> <request index="8" response="0000011110000011111" foes="1000011110000011111" cont="0"/> <request index="9" response="0111011110000011110" foes="0111011110000011110" cont="1"/> <request index="10" response="1000000001000000000" foes="1111000001111110000" cont="0"/> <request index="11" response="1000000001000000000" foes="1111000001111110000" cont="0"/> <request index="12" response="1000000001000000000" foes="1111000001111110000" cont="0"/> <request index="13" response="1000000001000001110" foes="1111000001111001110" cont="1"/> <request index="14" response="0000000000000001110" foes="0000000000000001110" cont="0"/> <request index="15" response="0000011110000011110" foes="0000011111000011110" cont="0"/> <request index="16" response="0000011110000011110" foes="0000011111000011110" cont="0"/> <request index="17" response="0000011110000011110" foes="0000011111000011110" cont="0"/> <request index="18" response="0000011110111011110" foes="0000011110111011110" cont="1"/> </junction> <junction id="J1" type="dead_end" x="0.00" y="-100.00" incLanes="E0_0 E0_1 E0_2" intLanes="" shape="0.00,-100.00 -9.60,-100.00 0.00,-100.00"/> <junction id="J2" type="dead_end" x="-100.00" y="0.00" incLanes="-E1_0 -E1_1 -E1_2" intLanes="" shape="-100.00,0.00 -100.00,9.60 -100.00,0.00"/> <junction id="J3" type="dead_end" x="100.00" y="0.00" incLanes="-E2_0 -E2_1 -E2_2" intLanes="" shape="100.00,0.00 100.00,-9.60 100.00,0.00"/> <junction id="J4" type="dead_end" x="0.00" y="100.00" incLanes="-E3_0 -E3_1 -E3_2" intLanes="" shape="0.00,100.00 9.60,100.00 0.00,100.00"/> <junction id=":J0_19_0" type="internal" x="-0.00" y="5.87" incLanes=":J0_4_0 -E0_0 -E0_1 -E0_2" intLanes=":J0_6_0 :J0_6_1 :J0_6_2 :J0_9_0 :J0_10_0 :J0_10_1 :J0_10_2 :J0_15_0 :J0_15_1 :J0_15_2 :J0_18_0"/> <junction id=":J0_20_0" type="internal" x="5.87" y="0.00" incLanes=":J0_9_0 E1_0 E1_1 E1_2" intLanes=":J0_1_0 :J0_1_1 :J0_1_2 :J0_4_0 :J0_10_0 :J0_10_1 :J0_10_2 :J0_13_0 :J0_14_0 :J0_15_0 :J0_15_1 :J0_15_2"/> <junction id=":J0_21_0" type="internal" x="0.00" y="-5.87" incLanes=":J0_13_0 E3_0 E3_1 E3_2" intLanes=":J0_0_0 :J0_1_0 :J0_1_1 :J0_1_2 :J0_6_0 :J0_6_1 :J0_6_2 :J0_9_0 :J0_15_0 :J0_15_1 :J0_15_2 :J0_18_0"/> <junction id=":J0_22_0" type="internal" x="-5.87" y="-0.00" incLanes=":J0_18_0 E2_0 E2_1 E2_2" intLanes=":J0_1_0 :J0_1_1 :J0_1_2 :J0_4_0 :J0_5_0 :J0_6_0 :J0_6_1 :J0_6_2 :J0_10_0 :J0_10_1 :J0_10_2 :J0_13_0"/> <connection from="-E0" to="-E3" fromLane="0" toLane="0" via=":J0_10_0" tl="J0" linkIndex="10" dir="s" state="O"/> <connection from="-E0" to="-E3" fromLane="1" toLane="1" via=":J0_10_1" tl="J0" linkIndex="11" dir="s" state="O"/> <connection from="-E0" to="-E3" fromLane="2" toLane="2" via=":J0_10_2" tl="J0" linkIndex="12" dir="s" state="O"/> <connection from="-E0" to="-E1" fromLane="2" toLane="2" via=":J0_13_0" tl="J0" linkIndex="13" dir="l" state="o"/> <connection from="E1" to="E0" fromLane="0" toLane="0" via=":J0_14_0" tl="J0" linkIndex="14" dir="r" state="o"/> <connection from="E1" to="-E2" fromLane="0" toLane="0" via=":J0_15_0" tl="J0" linkIndex="15" dir="s" state="o"/> <connection from="E1" to="-E2" fromLane="1" toLane="1" via=":J0_15_1" tl="J0" linkIndex="16" dir="s" state="o"/> <connection from="E1" to="-E2" fromLane="2" toLane="2" via=":J0_15_2" tl="J0" linkIndex="17" dir="s" state="o"/> <connection from="E1" to="-E3" fromLane="2" toLane="2" via=":J0_18_0" tl="J0" linkIndex="18" dir="l" state="o"/> <connection from="E2" to="-E3" fromLane="0" toLane="0" via=":J0_5_0" tl="J0" linkIndex="5" dir="r" state="o"/> <connection from="E2" to="-E1" fromLane="0" toLane="0" via=":J0_6_0" tl="J0" linkIndex="6" dir="s" state="o"/> <connection from="E2" to="-E1" fromLane="1" toLane="1" via=":J0_6_1" tl="J0" linkIndex="7" dir="s" state="o"/> <connection from="E2" to="-E1" fromLane="2" toLane="2" via=":J0_6_2" tl="J0" linkIndex="8" dir="s" state="o"/> <connection from="E2" to="E0" fromLane="2" toLane="2" via=":J0_9_0" tl="J0" linkIndex="9" dir="l" state="o"/> <connection from="E3" to="-E1" fromLane="0" toLane="0" via=":J0_0_0" tl="J0" linkIndex="0" dir="r" state="O"/> <connection from="E3" to="E0" fromLane="0" toLane="0" via=":J0_1_0" tl="J0" linkIndex="1" dir="s" state="O"/> <connection from="E3" to="E0" fromLane="1" toLane="1" via=":J0_1_1" tl="J0" linkIndex="2" dir="s" state="O"/> <connection from="E3" to="E0" fromLane="2" toLane="2" via=":J0_1_2" tl="J0" linkIndex="3" dir="s" state="O"/> <connection from="E3" to="-E2" fromLane="2" toLane="2" via=":J0_4_0" tl="J0" linkIndex="4" dir="l" state="o"/> <connection from=":J0_0" to="-E1" fromLane="0" toLane="0" dir="r" state="M"/> <connection from=":J0_1" to="E0" fromLane="0" toLane="0" dir="s" state="M"/> <connection from=":J0_1" to="E0" fromLane="1" toLane="1" dir="s" state="M"/> <connection from=":J0_1" to="E0" fromLane="2" toLane="2" dir="s" state="M"/> <connection from=":J0_4" to="-E2" fromLane="0" toLane="2" via=":J0_19_0" dir="l" state="m"/> <connection from=":J0_19" to="-E2" fromLane="0" toLane="2" dir="l" state="M"/> <connection from=":J0_5" to="-E3" fromLane="0" toLane="0" dir="r" state="M"/> <connection from=":J0_6" to="-E1" fromLane="0" toLane="0" dir="s" state="M"/> <connection from=":J0_6" to="-E1" fromLane="1" toLane="1" dir="s" state="M"/> <connection from=":J0_6" to="-E1" fromLane="2" toLane="2" dir="s" state="M"/> <connection from=":J0_9" to="E0" fromLane="0" toLane="2" via=":J0_20_0" dir="l" state="m"/> <connection from=":J0_20" to="E0" fromLane="0" toLane="2" dir="l" state="M"/> <connection from=":J0_10" to="-E3" fromLane="0" toLane="0" dir="s" state="M"/> <connection from=":J0_10" to="-E3" fromLane="1" toLane="1" dir="s" state="M"/> <connection from=":J0_10" to="-E3" fromLane="2" toLane="2" dir="s" state="M"/> <connection from=":J0_13" to="-E1" fromLane="0" toLane="2" via=":J0_21_0" dir="l" state="m"/> <connection from=":J0_21" to="-E1" fromLane="0" toLane="2" dir="l" state="M"/> <connection from=":J0_14" to="E0" fromLane="0" toLane="0" dir="r" state="M"/> <connection from=":J0_15" to="-E2" fromLane="0" toLane="0" dir="s" state="M"/> <connection from=":J0_15" to="-E2" fromLane="1" toLane="1" dir="s" state="M"/> <connection from=":J0_15" to="-E2" fromLane="2" toLane="2" dir="s" state="M"/> <connection from=":J0_18" to="-E3" fromLane="0" toLane="2" via=":J0_22_0" dir="l" state="m"/> <connection from=":J0_22" to="-E3" fromLane="0" toLane="2" dir="l" state="M"/> </net>