Getting speed of a vehicle using TraCIMobility module of VEINS

510 views
Skip to first unread message

Neeraj Mudgil

unread,
Feb 23, 2012, 6:07:35 AM2/23/12
to omn...@googlegroups.com

Hello Everyone,

I am using VEINS for my project. I want to find out the speed of a particular vehicle.I came to know it from http://veins.car2x.org/documentation/modules/traci/ that compound module can get speed of a vehicle using getSpeed() method. Can any One please tell me how exactly can I use this method. The steps which I have followed are:

1. Defined a simple  module speed.
2. In its c++ file wrote the following code

cModule* parent =getParentModule();
c*mobility=parent->getSubmodule("TraCIMobility");
double myspeed=mobility->getspeed();

3. Then included this simple module as submodule in the compound module Car given in traci_launchd example of veins. But this is not working and giving the error cModule* does not have member function getSpeed().

Ithink the approach I am following is wrong. Van anyone tell me what is correct way to use getspeed() method of TraCIMobility.

Thank You!



--
Neeraj Mudgil
M.Tech Computer Engg.(2010-12)
NIT Kurukshetra
Contact: 09992300873

(¨`·.·´¨) Alwayz
`·.¸(¨`·.·´¨) Keep
       (¨`·.·´¨)¸.·´ Smiling!
        `·.¸.·´


Luca Bedogni

unread,
Feb 23, 2012, 7:42:36 AM2/23/12
to omn...@googlegroups.com
Hi
you have to cast the module to type TraciMobility instead of
cModule *, using, for instance,
dynamic_cast<TraciMobility *>()

Plus, make sure to use getSpeed() instead of getspeed() as you wrote
in your code.

--
Luca Bedogni
PhD Student in Computer Science
University of Bologna
http://lbedogni.web.cs.unibo.it

> --
> Sent from the OMNeT++ mailing list. To configure your membership,
> visit http://groups.google.com/group/omnetpp

Neeraj Mudgil

unread,
Feb 23, 2012, 10:39:38 PM2/23/12
to omn...@googlegroups.com
Thank you very much for replying Luca Sir. It was a great help and solved my problem. Thanks again.

Hải Nguyễn Hồ Bá

unread,
Oct 12, 2014, 4:51:09 AM10/12/14
to omn...@googlegroups.com
Hi Neeraj,
I got same problem. Could you share your module that had work with me, please.
Thanks
Hai Nguyen
Reply all
Reply to author
Forward
0 new messages