introduction
A laneAreaDetector is used to capture traffic on an area along a lane or lanes. In reality this would be similar to a vehicle tracking cameras. In contrast to an induction loop, a lane-area detector has a certain length which is specified by the length
attribute or by the attributes pos,endPos
. The outputs of an E2 Detector are tailored for measuring queues of standing/jammed vehicles and it keeps track of all vehicles which currently are on its area, see attributes timeThreshold
, speedThreshold
and jamThreshold
in the table below. Further it is possible to couple the E2 detector with a traffic light, see attributes tl
and to
.
Attribute
output
如在程序运行中需要获取lane的排队长度,
traci.lanearea.getJamLengthMeters(lane.id)
additional 文件
使用python的sumolib库写additional文件。
目标:在每条lane铺设一条lanearea detector,长度为lane的长度。
# 用于生成路网的additional文件
import sumolib
import traci
traci.start([
r"E:\SUMO\\bin\sumo.exe", "-c",
r"C:\\Users\\HP\Sumo\beijing_sumo\\trial.sumocfg"
])
# 生成测速车的additional file
addtional_file = 'trial' + '.additional.xml'
with open(r"C:\\Users\\HP\Sumo\beijing_sumo\\trial.additional.xml", 'w') as f:
sumolib.xml.writeHeader(f, root='additional')
for lane in traci.lane.getIDList():
if ":" not in lane:
length = traci.lane.getLength(lane)
print('<laneAreaDetector id="{0}" lane="{1}" pos="0" length="{2}" period="300.00" file="{3}" friendlyPos="1" />'.format(lane, lane, length, lane), file=f)
print('</additional>', file=f)
traci.close()
生成的xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<!-- generated on 2023-08-21 12:13:34.846036 by file_creator.py v1_15_0+0002-e6790248698
options:
-->
<additional xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/additional_file.xsd">
<laneAreaDetector id="-E0_0" lane="-E0_0" pos="0" length="86.8" period="300.00" file="-E0_0" friendlyPos="1" />
<laneAreaDetector id="-E0_1" lane="-E0_1" pos="0" length="86.8" period="300.00" file="-E0_1" friendlyPos="1" />
<laneAreaDetector id="-E1_0" lane="-E1_0" pos="0" length="64.25" period="300.00" file="-E1_0" friendlyPos="1" />
<laneAreaDetector id="-E1_1" lane="-E1_1" pos="0" length="64.25" period="300.00" file="-E1_1" friendlyPos="1" />
<laneAreaDetector id="-E2_0" lane="-E2_0" pos="0" length="89.0" period="300.00" file="-E2_0" friendlyPos="1" />
<laneAreaDetector id="-E2_1" lane="-E2_1" pos="0" length="89.0" period="300.00" file="-E2_1" friendlyPos="1" />
<laneAreaDetector id="-E3_0" lane="-E3_0" pos="0" length="55.51" period="300.00" file="-E3_0" friendlyPos="1" />
<laneAreaDetector id="E0_0" lane="E0_0" pos="0" length="86.8" period="300.00" file="E0_0" friendlyPos="1" />
<laneAreaDetector id="E0_1" lane="E0_1" pos="0" length="86.8" period="300.00" file="E0_1" friendlyPos="1" />
<laneAreaDetector id="E1_0" lane="E1_0" pos="0" length="64.25" period="300.00" file="E1_0" friendlyPos="1" />
<laneAreaDetector id="E1_1" lane="E1_1" pos="0" length="64.25" period="300.00" file="E1_1" friendlyPos="1" />
<laneAreaDetector id="E2_0" lane="E2_0" pos="0" length="89.0" period="300.00" file="E2_0" friendlyPos="1" />
<laneAreaDetector id="E2_1" lane="E2_1" pos="0" length="89.0" period="300.00" file="E2_1" friendlyPos="1" />
<laneAreaDetector id="E3_0" lane="E3_0" pos="0" length="55.51" period="300.00" file="E3_0" friendlyPos="1" />
</additional>