0

I am using Veins, Omnet++ and Simu5G in this project. I am trying to have my vehicle stop in front of a traffic light and for that I want to use the stopAt function in the TraciCommandInterface however I am unsure of some of the arguments. The function is declared as:

void stopAt(std::string roadId, double pos, uint8_t laneid, double radius, simtime_t waittime)

The arguments seem to be self explanatory but I keep getting errors saying that the vehicle will not be in the selected edge in the future.

Furthermore, I only want it to stop if the light is red, but the light might change in the time it takes the vehicle to reach its position to stop using the stopAt function, or other vehicles might already be stopped creating a queue. Is there a way to cancel the stopAt function? That is, to cancel the event to stop at that specific point if the light turns green?

I am aware I could use the SUMO traffic lights but I need the lights to change based on messages being exchanged by the vehicles and the traffic light using 5G. This is what I have so far:

if(laneId == alert->getROILane() and (alert->getROIPosition()-alert->getROISize()) < lanePosition and lanePosition < alert->getROIPosition()){ 
if(!strcmp(light, "red")){ 
    traciVehicle->stopAt(traciVehicle->getRoadId(), alert->getROIPosition()-10, 0, 5, 0);
}else if(!strcmp(light, "green")){ 
    if(traciVehicle->getSpeed() == 0){ 
        traciVehicle->setSpeed(17); 
    } 
}

Thank you so much!

1 Answers1

0

Reading your code it might actually happen that you are already past the intended stop position at alert->getROIPosition()-10 when you try to set the stop. This will trigger an error.

Concerning the deletion of a stop: If you set a stop on the same lane and position as an existing one but with duration 0, the existing stop will be deleted.

Michael
  • 3,510
  • 1
  • 11
  • 23