0

How do I configure Veins to get the receiving vehicle's position (x and y) in a BSM message? I am using this configuration of veins: https://github.com/josephkamel/veins-f2md.

Yurroff
  • 1
  • 2

1 Answers1

0

When a vehicle receives a BSM, you can read the position of the current vehicle by using the mobility module:

mobility->getPositionAt(simTime()).x
mobility->getPositionAt(simTime()).y
mobility->getPositionAt(simTime()).z

It makes little sense to encode the receiver position in the message itself -- you are sending a broadcast. Apart from that, there are other reasons against the proposed procedure.

You could furthermore get the position from the Signal of a message.

signal.getReceiverPoa().pos.getPositionAt(simTime()).x
signal.getReceiverPoa().pos.getPositionAt(simTime()).y
signal.getReceiverPoa().pos.getPositionAt(simTime()).z
thardes2
  • 1,162
  • 12
  • 28
  • Thank you for your response. How can I actually access the mobility module? Furthermore, is it as simple as augmenting the BasicSafetyMessage.msg file with the necessary fields (i.e., RecvPosx, RecvPosy, etc.) or adding Signal object in the .msg file? – Yurroff Apr 06 '22 at 19:17
  • The C++ code of the `DemoBaseApplLayer` contains examples that answer your question. – thardes2 Apr 09 '22 at 09:25
  • I see, but how may I actually access that mobility object when I wish to log the receiver position in another file. Do I need to just instantiate the DemoBaseApplLayer? – Yurroff Apr 10 '22 at 01:19