sumo icon indicating copy to clipboard operation
sumo copied to clipboard

Traci multiple parameter subscriptions

Open extremeCrazyCoder opened this issue 1 year ago • 3 comments
trafficstars

Is there a way to add subscriptions to multiple parameters?

I would like to to get the "device.battery.actualBatteryCapacity" and the "device.battery.energyCharged" parameters using subscriptions.

I can get one of them using the following code:

traci.vehicle.subscribe(veh, [traci.constants.VAR_PARAMETER], parameters={
    traci.constants.VAR_PARAMETER: "device.battery.actualBatteryCapacity"
})

But this will not work for multiple ones (since the output of getSubscriptionResults is an dictionary with the key set to traci.constants.VAR_PARAMETER

extremeCrazyCoder avatar Jun 06 '24 08:06 extremeCrazyCoder

No, currently there is no way to do this. I keep it open as a feature request

behrisch avatar Jun 11 '24 05:06 behrisch

One tiny workaround is to use another subscription with VAR_PARAMETER_WITH_KEY. This way you will at least get two values

behrisch avatar Jun 11 '24 19:06 behrisch

Thank you for that Idea. I actually only need two (as of now), thus it should work.

My current workaround is that I added new Traci constants for the two parameters that I need.

extremeCrazyCoder avatar Jun 11 '24 19:06 extremeCrazyCoder