如何获得相扑中存在的交通信号灯并改变其相静脉? [英] How can I get a traffic light that exists in sumo and change its phase in veins?

查看:165
本文介绍了如何获得相扑中存在的交通信号灯并改变其相静脉?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

总而言之,我的模拟中有一个名为539320442的交通信号灯.

In sumo, my simulation has a traffic light called 539320442.

我希望RSU(存在于静脉中)改变该交通信号灯的相位.

I want that a RSU (that exists in veins) changes this traffic light's phase.

因此,我在TraCIDemoRSU11p.h中创建了一个Trafficlight变量,如下所示:

So I created a Trafficlight variable in the TraCIDemoRSU11p.h as it follows:

TraCICommandInterface::Trafficlight* RSU_traffic_light;

现在,我想获得ID为539320442的交通信号灯,并使用以下命令更改其相位:

Now I would like to get this traffic light that has id: 539320442 and change its phase by using:

void TraCICommandInterface::Traffic_light::setPhase(string, integer)

问题是在TraCIDemoRSU11p.cc中我无法获得交通信号灯并将其保存在以下位置:

The problem is that in the TraCIDemoRSU11p.cc I couldn't get the traffic light and save it in:

RSU_traffic_light;

所以我想知道如何获得这个交通信号灯并将其保存在RSU_traffic_light中:

So I was wondering how can I get this traffic light and save it in RSU_traffic_light:

RSU_traffic_light = getTrafficLightbyID("539320442");

会是那样吗?确切的语法是什么?

Would it be something like that? What is the exactly syntax for it?

推荐答案

设置交通信号灯的程序和阶段是Veins 4.5中包含的简单测试应用程序所要做的.您可以参考其源代码以查看其如何更改交通信号灯相位:

Setting a traffic light's program and phase is what the simple test application included in Veins 4.5 does. You can refer to its source code to see how it changes traffic light phases:

#include "veins/modules/mobility/traci/TraCIMobility.h"
#include "veins/modules/mobility/traci/TraCICommandInterface.h"

TraCIMobility* mobility;
TraCICommandInterface* traci;

mobility = TraCIMobilityAccess().get(getParentModule());
traci = mobility->getCommandInterface();
traci->trafficlight("10").setProgram("myProgramGreenRed");
traci->trafficlight("10").setPhaseIndex(1);

请注意,这使用了SUMO交通灯ID和测试场景,即

Note that this uses the SUMO traffic light id and phase id of the test scenario, that is,

<tlLogic id="10" type="static" programID="myProgramRed" offset="0">
 <phase duration="999" state="GggGGgrrr"/>
 <phase duration="999" state="GggGGgrrr"/>
</tlLogic>

您的方案可能会使用不同的交通信号灯ID和阶段ID.

Your scenario will likely use a different traffic light ID and phase ID.

这篇关于如何获得相扑中存在的交通信号灯并改变其相静脉?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆