我如何获得相扑中存在的红绿灯并改变其脉相?
How can I get a traffic light that exists in sumo and change its phase in veins?
在相扑中,我的模拟有一个名为 539320442
的红绿灯。
我想要一个 RSU(存在于静脉中)改变这个红绿灯的相位。
所以我在 TraCIDemoRSU11p.h
中创建了一个 Trafficlight
变量,如下所示:
TraCICommandInterface::Trafficlight* RSU_traffic_light;
现在我想要得到这个 ID 为 539320442
的红绿灯,并使用以下方法改变它的相位:
void TraCICommandInterface::Traffic_light::setPhase(string, integer)
问题是在TraCIDemoRSU11p.cc
我找不到红绿灯,保存在:
RSU_traffic_light;
所以我想知道如何获取这个红绿灯并将其保存在 RSU_traffic_light
:
RSU_traffic_light = getTrafficLightbyID("539320442");
会是那样吗?它的确切语法是什么?
设置交通灯的程序和阶段是 Veins 4.5 中包含的简单测试应用程序所做的。你可以参考its source code看看它是如何改变红绿灯相位的:
#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);
注意这里使用了the test scenario的SUMO红绿灯id和phase id,即
<tlLogic id="10" type="static" programID="myProgramRed" offset="0">
<phase duration="999" state="GggGGgrrr"/>
<phase duration="999" state="GggGGgrrr"/>
</tlLogic>
您的场景可能会使用不同的红绿灯 ID 和相位 ID。
在相扑中,我的模拟有一个名为 539320442
的红绿灯。
我想要一个 RSU(存在于静脉中)改变这个红绿灯的相位。
所以我在 TraCIDemoRSU11p.h
中创建了一个 Trafficlight
变量,如下所示:
TraCICommandInterface::Trafficlight* RSU_traffic_light;
现在我想要得到这个 ID 为 539320442
的红绿灯,并使用以下方法改变它的相位:
void TraCICommandInterface::Traffic_light::setPhase(string, integer)
问题是在TraCIDemoRSU11p.cc
我找不到红绿灯,保存在:
RSU_traffic_light;
所以我想知道如何获取这个红绿灯并将其保存在 RSU_traffic_light
:
RSU_traffic_light = getTrafficLightbyID("539320442");
会是那样吗?它的确切语法是什么?
设置交通灯的程序和阶段是 Veins 4.5 中包含的简单测试应用程序所做的。你可以参考its source code看看它是如何改变红绿灯相位的:
#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);
注意这里使用了the test scenario的SUMO红绿灯id和phase id,即
<tlLogic id="10" type="static" programID="myProgramRed" offset="0">
<phase duration="999" state="GggGGgrrr"/>
<phase duration="999" state="GggGGgrrr"/>
</tlLogic>
您的场景可能会使用不同的红绿灯 ID 和相位 ID。