Hi Bart,
Yes, all subscribe results are returned in one batch. But that is probably the better thing to do. Realise that all these calls are really TCP send & receive calls to 'sumo-gui' or 'sumo'. So if you would intend to call getSubscriptionResults() multiple times per simulation step (each with a different filter), you're probably reducing performance quite a bit.
So it's better to cache the results and make multiple passes in your own code instead of calling expensive TraCI functions.
So something like this would be much faster:
void ProcessSubResults()
{
auto sub_results = Vehicle::getSubscriptionResults(name.c_str());
ProcessArrivedVehicles(sub_results);
ProcessDepartedVehicles(sub_results);
}
void ProcessArrivedVehicles(...) {...}
You probably have something like this at subscription init time already; do you request VAR_ARRIVED_VEHICLES_IDS when subscribing?
std::vector<int> vars;
// Info we need from vehicles in vicinity
vars.push_back(libsumo::VAR_SPEED);
vars.push_back(libsumo::VAR_ANGLE);
vars.push_back(libsumo::VAR_SLOPE);
vars.push_back(libsumo::VAR_SIGNALS);
vars.push_back(libsumo::VAR_POSITION3D);
Vehicle::subscribeContext(veh_id, libsumo::CMD_GET_VEHICLE_VARIABLE, prefSubscribeDistance, vars);
So, get all sub results in one call (which is probably one TCP send and receive call in the background), then do processing on the batch of results in your own code (where it's now local in memory).
Indeed, the variable id (int) is the first item of every pair.
Cheers,
Ruud