riebl / artery

OMNeT++ V2X simulation framework for ETSI ITS-G5
GNU General Public License v2.0
202 stars 128 forks source link

Traffic Lights management #323

Closed alizz-99 closed 4 months ago

alizz-99 commented 4 months ago

Hello! I have created a service to incorporate it in the RSU, and I would like to control the traffic lights from this service. For example, the vehicles has the mVehicleController = &getFacilities().get_const(); but for the RSU-s this doesn't work for me. I don't know if there is any other way to get to the traci data from these service files.

Thank you!!

riebl commented 4 months ago

An RSU is not a vehicle and thus has no VehicleController. You can get access to the TraCI API via the World.traci.core module, though.

  1. Look up the World.traci.core module: cModule* traci = getModuleByPath("World.traci.core");
  2. Cast cModule* to traci::Core*: auto core = check_and_cast<traci::Core*>(source);
  3. Get API object from Core: core->getAPI()

Of course, you should check for each step if the operation was successful, i.e. that no null pointer is returned.