Calculating distance between cars nodes VEINS

前端 未结 2 511
你的背包
你的背包 2021-01-07 14:31

I am new to VEINS and trying to implement weighted p-persistence inside MyVeinsApp.cc. Distance between the sending node and receiving is used in that formula. I saw the 2 f

相关标签:
2条回答
  • 2021-01-07 14:56

    For the distance you obviously need the two positions. You can get the position of the current node by asking the mobility module and the position of the sender from the message you received. Then you can use the following method from Coord to calculate the distance between two points:

    /**
     * @brief Returns the distance to Coord 'a'.
     */
    double distance(const Coord& a) const {
        Coord dist(*this - a);
        return dist.length();
    }
    
    0 讨论(0)
  • 2021-01-07 15:08

    Look for the Path Loss Model implemented by your application. This can be seen in the Analog Model type within your config.xml file. For example, by default, veins4.7.1 uses SimplePathLossModel. In the behavior description of this path loss model (.cc file), you can see the variables

    reveiverPos, senderPos

    And by just finding the length between them, it is possible to have the distance between the sender and the receiver.

    double yourDistance = (receiverPos-sendersPos).length();

    And if, like me, you use prefer the debugging tags, you can see this distance by printing it in the debug using:

    splmEV << "Distance between sender and receiver is: " << yourDistance << endl;

    Make sure to define splmEV.

    0 讨论(0)
提交回复
热议问题