Search code examples
omnet++veins

Identify node types using Veins


I'm working with veins and OMNeT++ in a scenario that has different types of nodes (cars, pedestrians, and others). For evaluation purposes, I'm getting the std::map using the TraCIScenarioManager::getManagedHosts method based on this post (I also answered one of my related questions).

Now, I want to check the type of each node in the scenario. To be clearer, I want to obtain some kind of list that indicates the type of each node (is it a pedestrian? Is it a bus?). Is there any way to obtain this from the map? Is there any attribute that identifies the node type?

I already can identify the type of nodes through messages adding specifics tags to it, but now I need to obtain the type of node independent of the arrival of messages.

I really appreciate any help you can provide.


Solution

  • TraCIScenarioManager::getManagedHosts returns a std::map<std::string, cModule*> which maps each SUMO identifier to one OMNeT++ cModule*. Depending on how cars, buses, etc differ in your simulation, I can think of multiple ways of figuring out what type of SUMO object a host models.

    Maybe they are named differently in SUMO? Then you can use the std::string to tell them apart.

    Maybe they are named differently in OMNeT++? Then you can use getFullName() of the cModule* to tell them apart.

    Maybe they use different C++ classes as models for their application layers? Then you can use something like getSubmodule() of the cModule* to get a pointer to their application layer module and check if a dynamic_cast<ApplicationOfACar*> of this pointer is successful.