如何从TraCIDem11p.cc获取RSU坐标? [英] How to get RSU coordinate from TraCIDem11p.cc?

查看:159
本文介绍了如何从TraCIDem11p.cc获取RSU坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道当车辆靠近RSU时如何开始编写能够发送消息的程序. 首先,我仍然对某些定义感到困惑,但是,一点一点地,我认为我会学习脉络.

I was wondering how can I start writing a program able to send message when a vehicle is close to the RSU. First, I still get confused by some definitions, but, little by little, I think I will learn veins.

module = simulation.getModuleByPath("rsu[0]");
c = MobilityAccess().get(module)->getCurrentPosition();

我在此线程中找到了这部分代码:获取两个位置不同的模块

I found this part of code in this thread: Getting the location of two different modules

但是仍然有一些问题:

1)Module是什么样的对象?我猜TraCIMobility*

1) Module is what kind of object? I would guess TraCIMobility*

2)simulation怎么样?我不知道.

2) How about simulation? I have no idea.

那么,任何人都可以先向我解释如何在TraCIDemo11p.cc中获取RSU坐标吗?

So, could anyone please first explain to me how to get RSU coordinates in the TraCIDemo11p.cc?

谢谢!

推荐答案

如果您研究Veins 4.4教程仿真(例如,通过在OMNeT ++的TkEnv中运行它),您将看到rsu[0]包含名为mobility的子模块类型为BaseMobility.如果研究BaseMobility类,您会发现它具有方法getCurrentPosition().大概通过阅读OMNeT ++用户手册,您已经知道如何获得指向仿真中任何模块的指针.

If you investigate the Veins 4.4 tutorial simulation (e.g., by running it in OMNeT++'s TkEnv), you will see that rsu[0] contains a submodule named mobility which is of type BaseMobility. If you investigate the BaseMobility class you will see that it has a method getCurrentPosition(). Presumably from reading the OMNeT++ user manual you already know how to get a pointer to any module in your simulation.

将这些知识放在一起,您已经找到了一种方法(在许多可能的方法中)来获得Veins模拟中(命名的)节点的位置.

Put this knowledge together and you have found one way (of many possible ways) to get the position of a (named) node in a Veins simulation.

假设您使用的是Veins 4.4,则以下代码可以由模拟中的任何OMNeT ++模块执行,以获取名为rsu[0]的节点的位置:

Assuming you are using Veins 4.4, the following code can be executed by any OMNeT++ module in the simulation to get the position of a node named rsu[0]:

Coord pos = check_and_cast<BaseMobility*>(getSimulation()->getModuleByPath("rsu[0].mobility"))->getCurrentPosition();

这篇关于如何从TraCIDem11p.cc获取RSU坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆