riebl / artery

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

SUMO overrides TraCI speed decisions sent from a Service #179

Closed MadeInPierre closed 3 years ago

MadeInPierre commented 3 years ago

Hi,

I am trying to develop an Artery service that can control a vehicle's speed in SUMO. The goal is to build a new V2X-communications based intersection management algorithm. In my service, I simply call the provided TraCI methods to control the speed in the trigger() service method:

auto mVehicleController = &getFacilities().get_mutable<traci::VehicleController>();
mVehicleController->setSpeed(finalSpeed * units::si::meter_per_second);

However, I have found that SUMO keeps its own 'AI' behavior active and overrides my speed decisions. The only workaround I found is to set the intersection type as unregulated in SUMO's .net.xml file, but it disables collisions checks and other logging features. It also only disables SUMO's decisions when the vehicles are inside the specified junction, but not on the whole road network.

Has anyone found a clean way to disable SUMO's 'AI' to control the vehicles' speeds through Artery? Maybe @riebl knows if there is an 'official' or clean way to control the vehicles?

Thank you for your help.

riebl commented 3 years ago

According to https://sumo.dlr.de/docs/TraCI/Change_Vehicle_State.html, you may need to manipulate the "speed mode" as well. VehicleController does not directly provide a setter for the speed mode; however, you can easily get access to SUMO's TraCIAPI::VehicleScope object via VehicleController::getTraCI. If you find that the vehicles are just too fast, you may also try to enforce an upper speed limit via setMaxSpeed.

MadeInPierre commented 3 years ago

Well this was easy, thanks a lot. Here is the solution added in initialize() if anyone needs it:

auto mVehicleController = &getFacilities().get_mutable<traci::VehicleController>();
mVehicleController->getLiteAPI().vehicle().setSpeedMode(mVehicleController->getVehicleId(), 23);