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启动后的镜像仓库都有什…...

接口测试中缓存处理策略
在接口测试中,缓存处理策略是一个关键环节,直接影响测试结果的准确性和可靠性。合理的缓存处理策略能够确保测试环境的一致性,避免因缓存数据导致的测试偏差。以下是接口测试中常见的缓存处理策略及其详细说明: 一、缓存处理的核…...
Cursor实现用excel数据填充word模版的方法
cursor主页:https://www.cursor.com/ 任务目标:把excel格式的数据里的单元格,按照某一个固定模版填充到word中 文章目录 注意事项逐步生成程序1. 确定格式2. 调试程序 注意事项 直接给一个excel文件和最终呈现的word文件的示例,…...

Prompt Tuning、P-Tuning、Prefix Tuning的区别
一、Prompt Tuning、P-Tuning、Prefix Tuning的区别 1. Prompt Tuning(提示调优) 核心思想:固定预训练模型参数,仅学习额外的连续提示向量(通常是嵌入层的一部分)。实现方式:在输入文本前添加可训练的连续向量(软提示),模型只更新这些提示参数。优势:参数量少(仅提…...
C++:std::is_convertible
C++标志库中提供is_convertible,可以测试一种类型是否可以转换为另一只类型: template <class From, class To> struct is_convertible; 使用举例: #include <iostream> #include <string>using namespace std;struct A { }; struct B : A { };int main…...

MongoDB学习和应用(高效的非关系型数据库)
一丶 MongoDB简介 对于社交类软件的功能,我们需要对它的功能特点进行分析: 数据量会随着用户数增大而增大读多写少价值较低非好友看不到其动态信息地理位置的查询… 针对以上特点进行分析各大存储工具: mysql:关系型数据库&am…...

聊聊 Pulsar:Producer 源码解析
一、前言 Apache Pulsar 是一个企业级的开源分布式消息传递平台,以其高性能、可扩展性和存储计算分离架构在消息队列和流处理领域独树一帜。在 Pulsar 的核心架构中,Producer(生产者) 是连接客户端应用与消息队列的第一步。生产者…...

汽车生产虚拟实训中的技能提升与生产优化
在制造业蓬勃发展的大背景下,虚拟教学实训宛如一颗璀璨的新星,正发挥着不可或缺且日益凸显的关键作用,源源不断地为企业的稳健前行与创新发展注入磅礴强大的动力。就以汽车制造企业这一极具代表性的行业主体为例,汽车生产线上各类…...

WordPress插件:AI多语言写作与智能配图、免费AI模型、SEO文章生成
厌倦手动写WordPress文章?AI自动生成,效率提升10倍! 支持多语言、自动配图、定时发布,让内容创作更轻松! AI内容生成 → 不想每天写文章?AI一键生成高质量内容!多语言支持 → 跨境电商必备&am…...

【Java_EE】Spring MVC
目录 Spring Web MVC 编辑注解 RestController RequestMapping RequestParam RequestParam RequestBody PathVariable RequestPart 参数传递 注意事项 编辑参数重命名 RequestParam 编辑编辑传递集合 RequestParam 传递JSON数据 编辑RequestBody …...
精益数据分析(97/126):邮件营销与用户参与度的关键指标优化指南
精益数据分析(97/126):邮件营销与用户参与度的关键指标优化指南 在数字化营销时代,邮件列表效度、用户参与度和网站性能等指标往往决定着创业公司的增长成败。今天,我们将深入解析邮件打开率、网站可用性、页面参与时…...