涉及转弯时如何实现航位推算?

发布于 2024-07-30 06:57:00 字数 575 浏览 1 评论 0原文

“航位推算是根据先前确定的位置估计当前位置并根据经过时间和航向的已知或估计速度推进该位置的过程。” (维基百科

我目前正在实现一个利用航位推算优化的简单服务器,该服务器通过对客户端和服务器进行逻辑假设,最大限度地减少所需的更新。

用户控制的物体可以说是转动的,也可以说是不转动的。 这提出了航位推算的问题(我的看法)。

例如,假设您有由[位置、速度、转向:左/右/否]定义的时间点A。 现在您希望在 t 时间后获得点 B。 不转弯时,很容易推断出新位置。 由此产生的方向也很容易推断。 但是当这两个因素结合在一起时呢? 当物体翻转t时间时,速度方向将沿着曲线变化。

我是否应该采用另一种解决方案(例如让客户端发送每个新方向的更新,而不是仅仅告诉服务器“我现在要左转”)?

顺便说一句,为了简单起见,这是在 2D 空间中。

"Dead reckoning is the process of estimating one's current position based upon a previously determined position and advancing that position based upon known or estimated speeds over elapsed time, and course." (Wikipedia)

I'm currently implementing a simple server that makes use of dead reckoning optimization, which minimizes the updates required by making logical assumptions on both the clients and the server.

The objects controlled by users can be said to be turning, or not turning. This presents an issue with dead reckoning (the way I see it.)

For example, say you have point A in time defined by [position, velocity, turning: left/right/no]. Now you want point B after t amount of time. When not turning, the new position is easy to extrapolate. The resulting direction is also easy to extrapolate. But what about when these two factors are combined? The direction of the velocity will be changing along a curve as the object is turning over t amount of time.

Should I perhaps go with another solution (such as making the client send an update for every new direction rather than just telling the server "I'm turning left now")?

This is in a 2D space, by the way, for the sake of simplicity.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淡紫姑娘! 2024-08-06 06:57:00

好吧,我认为“转向:左/右/否”不足以确定位置 B - 您还需要知道进行转向的弧度。 如果您沿半径为 1 的圆形路径左转,则与沿半径为 10 的圆形路径左转相比,您最终会到达不同的位置,即使您的初始位置、速度和转弯方向都将是相同的。

如果可以选择让客户端发送每个新方向的更新并将它们视为线性段,那么计算起来会容易得多。 您可以简单地将来自客户端的每个新报告视为一个向量,并对它们求和。 计算一堆曲线将会更加复杂。

Well, I think "turning: left/right/no" is insufficient to determine position B - you also need to know the arc at which the turn is being made. If you are turning left along a circular path of radius 1, you will end up at a different place than if you are turning along a circular path of radius 10, even though your initial position, velocity, and direction of turn will all be the same.

If making the client send an update for every new direction and treating them as linear segments is an option, that is going to be a much easier calculation to make. You can simply treat each new report from the client as a vector, and sum them. Calculating a bunch of curves is going to be more complex.

近箐 2024-08-06 06:57:00

为简单起见,假设您的车辆的转弯半径 r 与速度无关。 因此,要计算给定初始坐标和时间的新位置:

  • 计算距离(即速度 * 时间)
  • 计算转动了多少(即距离 / (2*pi*r))
  • 将该弧添加到原始位置。

最后的步骤需要详细说明。

给定步骤 2 中计算出的角度 a,如果您以正北航向(即 pi/2 弧度)从 (0,0) 开始并向左转,则您的新位置为: (rcos(a)- 1、rsin(a))。

如果您的原始标题不同,假设它是“b”,然后只需相应地旋转新位置,即乘以此旋转矩阵:

 [ cos b , -sin b ]
 [ sin(b), cos(b) ]

最后,添加初始位置即可完成。 现在,如果您更改速度或转动方向,您只需发送更新即可。

For simplicity let's say that your vehicles have a turning radius r that's independant of speed. So to compute the new position given the initial coords and the time:

  • compute the distance (that's velocity * time)
  • compute how much you turned (that's distance / (2*pi*r))
  • add that arc to the original position.

The last steps needs elaboration.

Given the angle a computed in step 2, if you started at (0,0) with a due north heading (i.e. pi/2 radians) and are turning left then your new positions is: (rcos(a)-1, rsin(a)).

If your original heading was different, say it was "b", then simply rotate the new position accordingly, i.e. multiply by this rotation matrix:

 [ cos b , -sin b ]
 [ sin(b), cos(b) ]

Finally, add the initial position and you're done. Now you only need to send an update if you change the velocity or turning direction.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文