Dalia Adly
Dalia Adly

Reputation: 53

How to get the accurate vehicle speed?

I have made some modifications to run GPSR protocol in INET framework on the network scenario existing in the veins-inet subproject.

The problem is that the current speed (mobility->getCurrentSpeed) of any vehicle varies between (zero and 1 or -1 ) and the maximum speed is always = nan.

The mobility type used is veins-inet mobility.

Here are some results of The current speed for node[1] at different time intervals :

** Event #177  t=13.778533849167  Scenario.node[1].networkLayer.ip (IPv4, id=107)  on ping1 (inet::ICMPMessage, id=134)
INFO (GPSR)Scenario.node[1].gpsr: Scenario.node[1].gpsr: self position= (120.706, 129.627, 0)
INFO (GPSR)Scenario.node[1].gpsr: Scenario.node[1].gpsr: self speed= (0.99343, -0.11444, 0)

* Event #240  t=16.778533849167  Scenario.node[1].networkLayer.ip (IPv4, id=107)  on ping4 (inet::ICMPMessage, id=192)
INFO (GPSR)Scenario.node[1].gpsr: Scenario.node[1].gpsr: self position= (129.95, 90.9386, 0)
INFO (GPSR)Scenario.node[1].gpsr: Scenario.node[1].gpsr: self speed= (6.12323e-17, -1, 0)

** Event #317  t=20.778533849167  Scenario.node[1].networkLayer.ip (IPv4, id=107)  on ping8 (inet::ICMPMessage, id=258)
INFO (GPSR)Scenario.node[1].gpsr: Scenario.node[1].gpsr: self position= (129.95, 35.6802, 0)
INFO (GPSR)Scenario.node[1].gpsr: Scenario.node[1].gpsr: self speed= (6.12323e-17, -1, 0)

So, I have two questions:
1-what kind of speed mentioned in the result. Is it velocity?
2-How to get the actual speed of vehicles in(m/s) as mentioned in sumo?

Finally, I am using instant veins-4.7.1

Upvotes: 1

Views: 282

Answers (1)

Christoph Sommer
Christoph Sommer

Reputation: 6943

Thank you! This appears to be a bug in Veins 4.7.1 (mobility->getCurrentSpeed() is supposed to return how many meters per second in x/y/z direction the host is currently moving) - in Veins 4.7.1, it instead reports values normalized to a unit vector.

To fix the bug in your codebase, the following patch should be sufficient. Kindly let me know if it is:

https://github.com/sommer/veins/commit/58333692f93c6ebe5597c663421c19abd8fa06dd

Upvotes: 1

Related Questions