如何指示移动节点在特定的轨迹中移动? [英] How can a mobile node be instructed to move in a particular trajectory?
本文介绍了如何指示移动节点在特定的轨迹中移动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
推荐答案
在节点B上,确保启用了mobility
,并设置了location
和origin
,这样您就处于以米为单位的本地坐标系中。如果您的坐标系没有地理参考,则可以将origin
设置为[NaN, NaN]
:
def node = agentForService org.arl.unet.Services.NODE_INFO
node.origin = [Float.NaN, Float.NaN] // or GPS coordinates
node.location = [0, 0, 0] // or wherever you want to start
node.mobility = true
现在,当您在节点B上收到数据报时,您的代理可以将node.speed
和node.heading
设置为您所需的速度和方向。例如:
node.heading = 90 // head East
node.speed = 1 // at 1 m/s
实际上,您可能需要计算到达所需路点的航向。
您的代理可以监控节点的位置(可能使用TickerBehavior
),当到了停止时间(例如,您已经到达足够接近您的路点[2,0,0]
)时,将速度设置为0:
// if within 1 m of waypoint, stop
if (MathUtils.distance(node.location, [2,0,0] as double[]) < 1) {
node.speed = 0
}
这篇关于如何指示移动节点在特定的轨迹中移动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文