0

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.

1 Answers1

1

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.

Christoph Sommer
  • 6,893
  • 1
  • 17
  • 35
  • By "named differently in OMNeT++," do you mean different names in the veinsManager.moduleType parameter? In that case, I have the first two options. I'll try each option. Thanks a lot! – Tomás Lara Mar 29 '21 at 12:50
  • I was referring to the instance name (by default, the created OMNeT++ modules are called `node`, that is, `node[1]`, `node[2]`, ...). This value is configured in https://github.com/sommer/veins/blob/veins-5.1/src/veins/modules/mobility/traci/TraCIScenarioManager.ned#L52 – Christoph Sommer Mar 30 '21 at 13:56