1

I am a beginner about Veins. Now I am trying to simulate dynamic adjustment of the transmission power and speed between 2 running vehicles based on their distance with each other with Veins 4.5, Omnet 5.0 and Sumo 0.29. So far I have built the Sumo model and run the model in Omnet but without any programming which means the transmission power and speed between 2 vehicles are all set in the .ini file. Now I want to implement an algorithm to adjust them dynamically. As a beginner I barely know how to start this job. The Veins tutorial didn't tell how to apply the functions provided by Veins. I now build a new .cc file based on our .ned file. And from MyVeinsApp.cc I found some methods I need to implement. But still I need some programming instructions about my problem. 1 how to get the realtime distance between 2 running vehicles? 2 is it possible to control the transmission power and speed with Veins 4.5?

I am sorry for these initial questions.But I really don't know how to develop a Veins simulation from the very beginning step by step at the programming level

Thank you very much!

1 Answers1

2

To get the distance between two vehicles you can use the built-in function distance() from Coord (see this post).

To control the transmit power you can use the parameter txPower from Mac1609_4.

For changing the speed of the vehicle you can check this post.

Community
  • 1
  • 1
Julian Heinovski
  • 1,822
  • 3
  • 16
  • 27
  • Thank you very much! So far I have a few submodules in my NED file and all of them are the existing modules in Veins, such as ConnectionManager,TraciScenrioMangerLaunchd. Should I modify the corresponded cc file of them or implement my algorithm in my own cc file? if the latter, how can I connect my cc file with my NED file? It is a Network in which I can't use @class in it. – Xiaofeng Liu Apr 17 '17 at 16:13
  • Please start with OMNeT's [TicToc Tutorial](https://omnetpp.org/doc/omnetpp/tictoc-tutorial/) to find out how to work with modules and setup a simulation. For your algorithms you can create a new module or use *MyVeinsApp*. – Julian Heinovski Apr 17 '17 at 16:21
  • Thank you very much. When I added a MyVeinsApp into my NED file without adding any code into MyVeinsApp.cc and ran the simulation, it just crashed with the exit code 255. And I deleted the MyVeinsApp submodule, everything is ok again. Why did this happen? I thought it should be ok. I mean the existing submodules are necessary to run my SUMO model. What I want is how to add a new submodule into my NED file and program in the related cc file. The Tictoc taught me how to build a simulation step by step but no instructions to deal with this situation. – Xiaofeng Liu Apr 18 '17 at 21:33
  • Can you rephrase what exactly you did and what you are trying to do? – Julian Heinovski Apr 21 '17 at 07:54