Hi Bart,
Here are some snippets. For getSubscriptionResults():
auto sub_results = Vehicle::getSubscriptionResults(name.c_str());
for (auto r : sub_results) {
pt_LogDbg("- Ego subscr result type 0x%x: '%s'", r.first, r.second->getString().c_str());
}
I'm using a context subscription really (only report within a specific radius):
libsumo::SubscriptionResults subscriptionResults;
if (prefLogSumoCalls)
pt_Log("SUMO call: Vehicle::getContextSubscriptionResults(%s)", name.c_str());
subscriptionResults = Vehicle::getContextSubscriptionResults(name.c_str());
// Go through results (parse)
std::string entity_id;
for (auto e : subscriptionResults) {
entity_id = e.first;
//pt_LogDbg("- Ego ctx subscr result type '%s'", entity_id.c_str());
auto res = e.second;
for (auto r : res) {
//pt_LogDbg(" - subscr result var 0x%x value '%s''", r.first, r.second->getString().c_str());
switch (r.first) {
case libsumo::VAR_ANGLE:
vehicle->angle = ParseDouble(r.second->getString());
break;
case libsumo::VAR_POSITION3D:
// Convert string to Vector3-like struct
ParsePosition(r.second->getString(), vehicle->position);
break;
case libsumo::VAR_TYPE:
//pt_LogDbg("VAR_TYPE='%s'", r.second->getString().c_str());
vehicle->type_sumo = r.second->getString();
break;
//////////////// etc
default:
pt_LogWarn("Var 0x%x is not parsed; fix the source", r.first);
break;
}
}
}
Hope that helps,
Ruud