Closed xrispa-m closed 3 years ago
Sure, every SUMO feature exposed by its C++ TraCI API can be used in Artery. I think you are looking for TraCIAPI::TrafficLightScope::setRedYellowGreenState
.
Thank you for the reply! Is there a certain class that I should use to add the code for the traffic light? Is CaService and the RsuCaService something similar to the onWSM?
An ItsG5Service
's indicate
method is invoked whenever a message has arrived for the respective service. In general, I recommend creating a dedicated service for each independent use case.
I was using the RsuCaService before seeing your comment and I tried to create a new object that will be connected to the TraCIAPI. I've created a different program for the traffic lights and then I used the setProgram to change the original program at a given time.
Even though I don't get any errors, the traffic light programs is being set to the last program I'll have in the .net.xml file and it never changes to the new program.
Is there any chance that while the code has no errors, the functionality of the traffic lights is not used correctly?
I don't have a lot of experience controlling SUMO traffic lights. Please see the SUMO manual on how to change their programs properly.
I found a way to access the traffic light using the mVehicleContoller.
mVehicleController = &getFacilities().get_const<traci::VehicleController>();
const std::string id = mVehicleController->getVehicleId();
auto& vehicle_api = mVehicleController->getTraCI()->vehicle;
auto& trafficLight_api = mVehicleController->getTraCI()->trafficlights;
Hi! I need to create a scenario with traffic lights in Artery where the state of the traffic light could change at a certain time. I have created a similar scenario using Veins and Sumo in OMNeT++ and I have used the traci trafficlight class and the setState function. I added the following code in the onWSM from OMNeT++.
if (simTime() > 30 && simTime() < 50) {traci->trafficlight("cluster_254108781_257412131").setState("rrrrrrrrrrrrrrrrrrrr");}
Is there a similar way to do something like that using Artery?
Thanks!