How to get RSU coordinate from TraCIDem11p.cc?

前端 未结 2 1894
刺人心
刺人心 2021-02-11 10:51

I was wondering how can I start writing a program able to send message when a vehicle is close to the RSU. First, I still get confused by some definitions, but, little by little

2条回答
  •  无人及你
    2021-02-11 11:23

    If you investigate the Veins 4.4 tutorial simulation (e.g., by running it in OMNeT++'s TkEnv), you will see that rsu[0] contains a submodule named mobility which is of type BaseMobility. If you investigate the BaseMobility class you will see that it has a method getCurrentPosition(). Presumably from reading the OMNeT++ user manual you already know how to get a pointer to any module in your simulation.

    Put this knowledge together and you have found one way (of many possible ways) to get the position of a (named) node in a Veins simulation.

    Assuming you are using Veins 4.4, the following code can be executed by any OMNeT++ module in the simulation to get the position of a node named rsu[0]:

    Coord pos = check_and_cast(getSimulation()->getModuleByPath("rsu[0].mobility"))->getCurrentPosition();
    

提交回复
热议问题