SUMO lanearea detector

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 timeThresholdspeedThreshold 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>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值