sumo

Is there a way to turn off a vehicle signal in SUMO?


I know that you can turn on a vehicle signal (for example, the left indicator) in traci using:

traci.vehicle.setSignals(vehID, int)

where the integer related to the specific signal can be found using the following link (https://sumo.dlr.de/docs/TraCI/Vehicle_Signalling.html#signaling), but is there a way of turning off a specific signal that would be otherwise turned on by the program (i.e., a setSignalOff)?

I think that there is a function in the underlying C++ code (switchOffSignal() in MSVehicle.h) but there doesn't appear to be a traci command that turns off a specific signal.

I appreciate that it is (generally) a pleasant visual aesthetic and has no impact on vehicle behaviour, but it would be very useful for what I am trying to do!


Solution

  • So, Michael is right in that:

    traci.vehicle.setSignals("ego", 0)

    should turn off all signals (although the signals still appeared on for me visually, which confused me initially).

    To turn off individual signals but keep the others on you need to:

    1. For all the "on" signals find the value of 2^n, where n is the bit integer (which can be found using the following link: https://sumo.dlr.de/docs/TraCI/Vehicle_Signalling.html)
    2. Sum all these 2^n values (let's call this variable x) and use this value in the setSignals function: traci.vehicle.setSignals("ego", x).

    So for example, if we want the brake light, the right indicator and the high beam on (but all the other signals off) we would do:

    RightIndicatorValue = pow(2,0)
    BrakeLightValue = pow(2,3)
    HighBeamValue = (2,6)
    SignalValue = RightIndicatorValue + BrakeLightValue + HighBeamValue
    traci.vehicle.setSignals(("ego", SignalValue)