Sumo中Traci.trafficlight详解(上)
Sumo中Traci.trafficlight详解(上)
记录慢慢学习traci的每一天,希望也能帮到你
文章目录
- Sumo中Traci.trafficlight详解(上)
- Traci.trafficlight
- 信号灯参数讲解
- 1.getAllProgramLogics(self,tlsID)
- 2.getBlockingVehicles(self, tlsID, linkIndex)
- 3.getConstraints(self, tlsID, tripId='')
- 4.getConstraintsByFoe(self, foeSignal, foeId='')
- 5.getControlledLanes(self, tlsID)
- 6.getControlledLinks(self, tlsID)
- 7.getNemaPhaseCalls(self, tlsID)
- 8.getNextSwitch(self, tlsID)
- 9.getPhase(self, tlsID) 、getPhaseDuration(self, tlsID)、getPhaseName(self, tlsID)
Traci.trafficlight
导入库
import traci
#这里不需要全部导入
信号灯参数讲解
getAllProgramLogics(ID)输入为信号灯ID,其中xml文件中对信号灯的定义方式如下:
<tlLogic id="0" type="static" programID="0" offset="0"><phase duration="31" state="GrGr"/><phase duration="6" state="yryr"/><phase duration="31" state="rGrG"/><phase duration="6" state="ryry"/></tlLogic>
从上面可以得出,第一个id为信号控制所在node的id,信号灯的programID为‘0’,当然这个id可以自己给定,数据类型为字符串(str),控制类型为static,即定时信号控制,另外在sumo中还有其它的控制类型:

可以自己多多尝试。duration为当前相位持续时间,单位为s;
state为信号相位,即通行权解释,sumo的信号灯配置比较麻烦,这里详细讲解一下:

每一个state代表一个或者多个流线的放行,如gggrrrrgggrrrr代表南北方向通行,东西方向禁行g[0]g[1]g[2]r[3]r[4]r[5]r[6]按照索引位置进行对应。为了方便讲解,这里以上面给的xml文件中的参数进行trafficlight的相关用法及返回值的讲解
<tlLogic id="0" type="static" programID="0" offset="0"><phase duration="31" state="GrGr"/><phase duration="6" state="yryr"/><phase duration="31" state="rGrG"/><phase duration="6" state="ryry"/></tlLogic>
1.getAllProgramLogics(self,tlsID)
getAllProgramLogics(self, tlsID)= getCompleteRedYellowGreenDefinition
getAllProgramLogics(string) -> list(Logic)返回值为元组数据,功能等同于getCompleteRedYellowGreenDefinition方法Returns a list of Logic objects.Each Logic encodes a traffic light program for the given tlsID.
返回逻辑对象的列表。每个逻辑为给定的tlsID编码一个红绿灯程序。
traci.trafficlight.getAllProgramLogics( tlsID='0')
#(Logic(programID='0', type=0, currentPhaseIndex=2,
#phases=(Phase(duration=31.0, state='GrGr', minDur=31.0, maxDur=31.0, next=()),
#Phase(duration=6.0, state='yryr', minDur=6.0, maxDur=6.0, next=()),
#Phase(duration=31.0, state='rGrG', minDur=31.0, maxDur=31.0, next=()),
#Phase(duration=6.0, state='ryry', minDur=6.0, maxDur=6.0, next=())), subParameter={}),)
通过getAllProgramLogics(self,tlsID)可以获得当前信号灯配时的全部信息。
2.getBlockingVehicles(self, tlsID, linkIndex)
输入为信号控制灯ID以及信号灯相位索引
getBlockingVehicles(self, tlsID, linkIndex)
getBlockingVehicles(string, int) -> int
Returns the list of vehicles that are blocking the subsequent block for the given tls-linkIndex
返回在信号交叉口阻塞的车辆ID列表
代码如下(示例):
traci.trafficlight.getBlockingVehicles( tlsID='0',0)
#返回值为空表示没有阻塞车辆
3.getConstraints(self, tlsID, tripId=‘’)
getConstraints(self, tlsID, tripId='')
getConstraint(self, tlsID, tripId='')
getConstraints(string, string) -> list(Constraint)
Returns the list of rail signal constraints for the given rail signal.
If tripId is not "", only constraints with the given tripId are
returned. Otherwise, all constraints are returned
返回给定轨道信号的轨道信号约束列表。
如果tripId不为“”,则只有具有给定tripId的约束为返回。否则,将返回所有约束
代码如下(示例):
traci.trafficlight.getConstraints( tlsID='0',0)
#针对轨道信号,普通交叉口会报错
4.getConstraintsByFoe(self, foeSignal, foeId=‘’)
getConstraintByFoe(self, foeSignal, foeId='')
getConstraintsByFoe(string, string) -> list(Constraint)
Returns the list of rail signal constraints that have the given rail signal id as their foeSignal.
If foeId is not "", only constraints with the given foeId are
returned. Otherwise, all constraints are returned
返回具有给定轨道的轨道信号约束的列表信号id作为他们的foeSignal。
如果foeId不是“”,则只有具有给定foeId的约束为返回。否则,将返回所有约束
traci.trafficlight.getConstraints( foeSignal, foeId='')
#针对轨道信号,普通交叉口会报错
5.getControlledLanes(self, tlsID)
getControlledLanes(self, tlsID)
getControlled Lanes(self, tlsID)
getControlledLanes(string) -> c
Returns the list of lanes which are controlled by the named traffic light.
返回由命名红绿灯控制的车道列表
traci.trafficlight.getControlledLanes(tlsID='0')
#('4i_0', '2i_0', '3i_0', '1i_0')返回车道列表id
6.getControlledLinks(self, tlsID)
getControlled Links(self, tlsID)
getControlledLinks(string) -> list(list(list(string)))
Returns the links controlled by the traffic light, sorted by the signal index and described by giving
the incoming, outgoing, and via lane.
返回由红绿灯控制的链接,按信号索引排序,并通过给出传入、传出和通过通道。
traci.trafficlight.getControlledLinks(tlsID='0')
#[[('4i_0', '3o_0', ':0_0_0')],
#[('2i_0', '1o_0', ':0_1_0')],
#[('3i_0', '4o_0', ':0_2_0')],
#[('1i_0', '2o_0', ':0_3_0')]]
#返回车道id,这里的车道指的是经过交叉口的所有车道,包括进口道出口道的路径
7.getNemaPhaseCalls(self, tlsID)
getNemaPhaseCalls(self, tlsID)
getNemaPhaseCalls(string) -> list(string)
Get the vehicle calls for the phases.The output is vehicle calls (coming from the detectors) for the phases.
获取车辆对相位的调用。输出为车辆对相位(来自检测器)的调用。
注意:需要是Nema类型的信号灯才可以调用,其它类型调用会报错
8.getNextSwitch(self, tlsID)
getNextSwitch(self, tlsID)
getNextSwitch(string) -> double
Return the absolute simulation time at which the traffic light is schedule to switch to the next phase (in seconds).
返回红绿灯计划切换到下一阶段的绝对模拟时间(以秒为单位)
traci.trafficlight.getNextSwitch('0')
#31.0
9.getPhase(self, tlsID) 、getPhaseDuration(self, tlsID)、getPhaseName(self, tlsID)
这三个方法的用法类似,放在一起讲:
getPhase(self, tlsID)获取当前相位信息
getPhase(string) -> integer
Returns the index of the current phase within the list of all phases of the current program.
返回红绿灯计划切换到下一阶段的绝对模拟时间(以秒为单位)。返回当前程序所有阶段列表中当前阶段的索引。
traci.trafficlight.getPhase('0')
# 返回值为 2
getPhaseDuration(string) -> doubleReturns the total duration of the current phase (in seconds). This value is not affected by the elapsed or remaining duration of the current phase.
返回当前相位的总共时长,不受剩余相位时间影响,相当于返回某个信号周期的某个相位的完整时长
traci.trafficlight.getPhaseDuration('0')
#返回值为31.0
getPhaseName(self, tlsID)
getPhaseName(string) -> string
Returns the name of the current phase.
返回相位名称(自定义,如果没有定义,返回为空字符串)
traci.trafficlight.getPhaseName('0')
仿真示例代码链接如下:
链接:https://pan.baidu.com/s/1IFs4UJUBPxPM_LUTSrcmSw
**提取码:**Sumo
欢迎交流!
相关文章:
Sumo中Traci.trafficlight详解(上)
Sumo中Traci.trafficlight详解(上) 记录慢慢学习traci的每一天,希望也能帮到你 文章目录 Sumo中Traci.trafficlight详解(上)Traci.trafficlight信号灯参数讲解1.getAllProgramLogics(self,tlsID)2.getBlockingVehicle…...
手写Mybatis:第13章-通过注解配置执行SQL语句
文章目录 一、目标:注解配置执行SQL二、设计:注解配置执行SQL三、实现:注解配置执行SQL3.1 工程结构3.2 注解配置执行SQL类图3.3 脚本语言驱动器3.3.1 脚本语言驱动器接口3.3.2 XML语言驱动器 3.4 注解配置构建器3.4.1 定义增删改查注解3.4.2…...
spring security - 快速整合 springboot
1.引入依赖<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spr…...
NPM 常用命令(二)
目录 1、npm bugs 1.1 配置 browser registry 2、npm cache 2.1 概要 2.2 详情 2.3 关于缓存设计的说明 2.4 配置 cache 3、 npm ci 3.1 描述 3.2 配置 install-strategy legacy-bundling global-style omit strict-peer-deps foreground-scripts ignore-s…...
ctfhub ssrf(3关)
文章目录 内网访问伪协议读取文件扫描端口 内网访问 根据该题目,是让我们访问127.0.0.1/falg.php,访问给出的链接后用bp抓包,修改URL,发送后得到flag: 伪协议读取文件 这题的让我们用伪协议,而网站的目录…...
跨源资源共享(CORS)Access-Control-Allow-Origin
1、浏览器的同源安全策略 没错,就是这家伙干的,浏览器只允许请求当前域的资源,而对其他域的资源表示不信任。那怎么才算跨域呢? 请求协议http,https的不同域domain的不同端口port的不同 好好好,大概就是这么回事啦&…...
【嵌入式软件开发 】学习笔记
本文主要记录 【嵌入式软件开发】 学习笔记,参考相关大佬的文章 1.RTOS 内功修炼笔记 RTOS内功修炼记(一)—— 任务到底应该怎么写? RTOS内功修炼记(二)—— 优先级抢占式调度到底是怎么回事?…...
CentOS 7上安装Python 3.11.5,支持Django
CentOS 7上安装Python 3.11.5,支持Django 今天安装django,报了“Django - deterministicTrue requires SQLite 3.8.3 or higher upon running python manage.py runserver”。查了一番资料,记录下来。 参考链接: 参考链接: Django的web项目…...
COMPFEST 15H「组合数学+容斥」
Problem - H - Codeforces 题意: 定义一个集合S为T的孩子是,对于S中的每一个元素x,在T中都能找到x1。 给定n,k,每一个集合中的元素x必须满足 1 < x < k 1<x<k 1<x<k且 c n t [ x ] < 1 cnt[x…...
react快速开始(三)-create-react-app脚手架项目启动;使用VScode调试react
文章目录 react快速开始(三)-create-react-app脚手架项目启动;使用VScode调试react一、create-react-app脚手架项目启动1. react-scripts2. 关于better-npm-runbetter-npm-run安装 二、使用VScode调试react1. 浏览器插件React Developer Tools2. 【重点】用 VSCode …...
【C++入门】string类常用方法(万字详解)
目录 1.STL简介1.1什么是STL1.2STL的版本1.3STL的六大组件1.4STL的缺陷 2.string类的使用2.1C语言中的字符串2.2标准库中的string类2.3string类的常用接口说明 (只讲解最常用的接口)2.3.1string类对象的常见构造2.3.2 string类对象的容量操作2.3.3string…...
大数据错误
question1 : Could not locate Hadoop executable: D:\hadoop-3.3.1\bin\winutils.exe - 【已解决】Could not locate executable E:\Hadoop\bin\winutils.exe in the Hadoop binaries._could not locate executable e:\hadoop-3.3.1\bin\wi_君问归期魏有期的博客-CSDN博客 q…...
【Node.js】Express-Generator:快速生成Express应用程序的利器
在Node.js世界中,Express是一个广泛使用的、强大的Web应用程序框架。它为开发者提供了一系列的工具和选项,使得创建高效且可扩展的Web应用程序变得轻而易举。然而,对于初学者来说,配置和初始化Express应用程序可能会有些困难。为了…...
SpringMVC的工作流程及入门
目录 一、概述 ( 1 ) 是什么 ( 2 ) 作用 二、工作流程 ( 1 ) 流程 ( 2 ) 步骤 三、入门实例 ( 1 ) 入门实例 ( 2 ) 静态资源处理 给我们带来的收获 一、概述 ( 1 ) 是什么 SpringMVC是一个基于Java的Web应用开发框架,它是Spring Framework的一部…...
logging.level的含义及设置 【java 日志 (logback、log4j)】
日志级别 trace<debug<info<warn<error<fatal 常用的有:debug,info,warn,error 通常我们想设置日志级别,会用到 logging.level.rootinfo logging.level设置日志级别,后面跟生效的区域。r…...
第 3 章 栈和队列(链栈)
1. 背景说明 链栈是指用单链表实现的栈,其存储结构为链式存储,实现类似于队列的链式实现,不过在插入元素时链栈在头部插入,而 链式队列在尾部插入,本示例中实现为带头结点的链栈,即栈顶元素为栈指针的下一…...
嵌入式面试-经典问题
1、c语言内存模型 2、C语言中的变量定义在什么地方 3、C语言代码如何运行的、关于栈的相关 4、指针函数与函数指针的区分 5、Static关键字的作用 6、const作用 7、进程与线程的区别 8、链表与数组的区别 9、#define宏定义与typedef的区别...
ZLMeidaKit在Windows上启动时:计算机中丢失MSVCR110.dll,以及rtmp推流后无法转换为flv视频流解决
场景 ZLMediaKit在Windows上实现Rtmp流媒体服务器以及模拟rtmp推流和http-flv拉流播放: ZLMediaKit在Windows上实现Rtmp流媒体服务器以及模拟rtmp推流和http-flv拉流播放_zlm流媒体服务器_霸道流氓气质的博客-CSDN博客 按照以上教程启动MediaServer.exe时提示&am…...
项目(智慧教室)第二部分,人机交互页面实现,
使用软件: 1.BmCvtST.exe 这是stm32Cubemx工程下的带三方软件。存在STemWin中。 作用: 图片变成.c文件格式。 2.CodeBlock 3.模拟器工程(具体请看上一节) 一。emWin环境的搭建 1.codeBlock下载 开源免费。 2.使用stm的C…...
【docker】docker的一些常用命令-------从小白到大神之路之学习运维第92天
目录 一、安装docker-ce 1、从阿里云下载docker-cer.epo源 2、下载部分依赖 3、安装docker 二、启用docker 1、启动docker和不启动查看docker version 2、启动服务查看docker version 有什么区别?看到了吗? 3、看看docker启动后的镜像仓库都有什…...
应用升级/灾备测试时使用guarantee 闪回点迅速回退
1.场景 应用要升级,当升级失败时,数据库回退到升级前. 要测试系统,测试完成后,数据库要回退到测试前。 相对于RMAN恢复需要很长时间, 数据库闪回只需要几分钟。 2.技术实现 数据库设置 2个db_recovery参数 创建guarantee闪回点,不需要开启数据库闪回。…...
相机Camera日志实例分析之二:相机Camx【专业模式开启直方图拍照】单帧流程日志详解
【关注我,后续持续新增专题博文,谢谢!!!】 上一篇我们讲了: 这一篇我们开始讲: 目录 一、场景操作步骤 二、日志基础关键字分级如下 三、场景日志如下: 一、场景操作步骤 操作步…...
大型活动交通拥堵治理的视觉算法应用
大型活动下智慧交通的视觉分析应用 一、背景与挑战 大型活动(如演唱会、马拉松赛事、高考中考等)期间,城市交通面临瞬时人流车流激增、传统摄像头模糊、交通拥堵识别滞后等问题。以演唱会为例,暖城商圈曾因观众集中离场导致周边…...
java调用dll出现unsatisfiedLinkError以及JNA和JNI的区别
UnsatisfiedLinkError 在对接硬件设备中,我们会遇到使用 java 调用 dll文件 的情况,此时大概率出现UnsatisfiedLinkError链接错误,原因可能有如下几种 类名错误包名错误方法名参数错误使用 JNI 协议调用,结果 dll 未实现 JNI 协…...
Cloudflare 从 Nginx 到 Pingora:性能、效率与安全的全面升级
在互联网的快速发展中,高性能、高效率和高安全性的网络服务成为了各大互联网基础设施提供商的核心追求。Cloudflare 作为全球领先的互联网安全和基础设施公司,近期做出了一个重大技术决策:弃用长期使用的 Nginx,转而采用其内部开发…...
Web后端基础(基础知识)
BS架构:Browser/Server,浏览器/服务器架构模式。客户端只需要浏览器,应用程序的逻辑和数据都存储在服务端。 优点:维护方便缺点:体验一般 CS架构:Client/Server,客户端/服务器架构模式。需要单独…...
windows系统MySQL安装文档
概览:本文讨论了MySQL的安装、使用过程中涉及的解压、配置、初始化、注册服务、启动、修改密码、登录、退出以及卸载等相关内容,为学习者提供全面的操作指导。关键要点包括: 解压 :下载完成后解压压缩包,得到MySQL 8.…...
echarts使用graphic强行给图增加一个边框(边框根据自己的图形大小设置)- 适用于无法使用dom的样式
pdf-lib https://blog.csdn.net/Shi_haoliu/article/details/148157624?spm1001.2014.3001.5501 为了完成在pdf中导出echarts图,如果边框加在dom上面,pdf-lib导出svg的时候并不会导出边框,所以只能在echarts图上面加边框 grid的边框是在图里…...
如何做好一份技术文档?从规划到实践的完整指南
如何做好一份技术文档?从规划到实践的完整指南 🌟 嗨,我是IRpickstars! 🌌 总有一行代码,能点亮万千星辰。 🔍 在技术的宇宙中,我愿做永不停歇的探索者。 ✨ 用代码丈量世界&…...
比特币:固若金汤的数字堡垒与它的四道防线
第一道防线:机密信函——无法破解的哈希加密 将每一笔比特币交易比作一封在堡垒内部传递的机密信函。 解释“哈希”(Hashing)就是一种军事级的加密术(SHA-256),能将信函内容(交易细节…...
