I'm used Veins 5.0
in my simulation environment.
There are currently 4 RSU nodes in use. The omnetpp.ini
code is as follows:
omnetpp.ini
*.fRSU[0].mobility.x = 125
*.fRSU[0].mobility.y = 125
*.fRSU[0].mobility.z = 3
...
Here is the C++ code for RSU:
fRSUBehavior.cc
posX = check_and_cast<BaseMobility*>(getSimulation() -> getModuleByPath("fRSU[0].mobility.x")) -> getPositionAt(simTime()).x;
posY = check_and_cast<BaseMobility*>(getSimulation() -> getModuleByPath("fRSU[0].mobility.y")) -> getPositionAt(simTime()).y;
EV << "X: " << posX << " Y: " << posY << std::endl;
In this file I want to get the location of that node. However, the value of the log output is always defined as 0.
How should I modify the code?
The getModuleByPath("fRSU[0].mobility.x"))
is unlikely to work. The module name is very likely fRSU[0].mobility
, that is, it does not include the parameter name. Very likely, the getModuleByPath
returns a Null pointer and, by chance, your program does not crash but you are instead reading somewhat sensible values.