How can we find the current direction of a node in veins

529 views Asked by At

I would like to implement distance measurements between nodes using spherical coordinates. How do we find the direction of a particular node in veins simulation.

Thanks

1

There are 1 answers

0
Christoph Sommer On BEST ANSWER

Veins uses planar (x/y) coordinates with 1 unit equal to 1 meter for all of its computations.

(Even the road map uses planar coordinates. To get a planar road map of a real city, the import process for a .net.xml file uses map projection - for example, the Veins 4.4 tutorial simulation used UTM projection).

As a consequence, you can use simple trigonometry to get the distance between any two points (or, as most coordinates are stored using class Coord, you can call its distance method.

The recommended way to get the position of any car in the simulation is to call its mobility module's getCurrentPosition method.

If you absolutely need to determine the longitude/latitude of a given x/y position, you will need to apply the inverse of the map projection used when importing the road map. If this information is present in the .net.xml file, this can also be done by calling the getLonLat function of a TraCICommandInterface (obtained, for example, like in the tutorial simulation in TraCIDemo11p.cc, line 34).