使用 GPS/指南针/加速计到达航路点 - 算法?
我目前有一个带有一些传感器的机器人,例如 GPS、加速计和指南针。我想做的事情是让我的机器人到达我输入的 GPS 坐标。我想知道是否已经存在任何可以做到这一点的算法。我不需要源代码,因为它没有任何意义,只需要我的机器人执行此操作所需遵循的程序,以便我能够理解我所做的事情......此刻,让我们想象一下我每次都可以访问GPS坐标,因此不需要卡尔曼滤波器。我知道这是不现实的,但我想一步一步地对其进行编程,卡尔曼是下一步。
如果有人有想法...
I currently have a robot with some sensors, like a GPS, an accelerometer and a compass. The thing I would like to do is my robot to reach a GPS coordinate that I enter. I wondered if any algorithm to do that already existed. I don't want a source code, which wouldn't have any point, just the procedure to follow for my robot to do so, for me to be able to understand what I do... At the moment, let's imagine that I can access the GPS coordinate everytime, so no need of a Kalman filter. I know it's unrealistic, but I would like to programm it step by step, and Kalman is the next step.
If anyone has an idea...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
要获得两个经纬度点之间的方位角(北东正角),请使用:
bearing=mod(atan2(sin(lon2-lon1)*cos(lat2),(lat1)*sin(lat2)-sin) (lat1)*cos(lat2)*cos(lon2-lon1)),2*pi)
但对于小距离,您只需计算您所在位置的纬度和经度以 1 度为单位有多少米,然后将它们视为平面 X、Y 坐标。
对于典型的 45 度纬度,纬度约为 111.132 公里/度,经度约为 78.847 公里/度。
To get a bearing (positive angle east of north) between two lat-long points use:
bearing=mod(atan2(sin(lon2-lon1)*cos(lat2),(lat1)*sin(lat2)-sin(lat1)*cos(lat2)*cos(lon2-lon1)),2*pi)
But for small distances you can just calculate how many meters in one degree of lat and long at your position and then treat them as flat X,Y coords.
For typical 45deg latitudes it's around 111.132 km/deg lat, 78.847 km/deg lon.
1) 将机器人定向到目的地。
2) 向前移动,直到您和目的地之间的距离增加,您应该返回到 1)
3) 但是...如果您足够近(低于阈值),则认为您已到达目的地。
1) orient your robot toward its destination.
2) Move forward until the distance between you and your destination is increasing where you should go back to 1)
3) BUT ... if you are close enough (under a threshold), consider that you arrived at the destination.
您可以使用
Location
类。它的BearingTo
函数计算您必须遵循的方位才能到达另一个位置。You can use the
Location
class. It'sBearingTo
function computes the bearing you have to follow to reach another location.有一个非常好的页面解释了我一直在使用的基于 GPS 的距离、方位等计算之间的公式:
http://www.movable-type.co.uk/scripts/latlong.html
我目前正在尝试自己进行这些计算,刚刚在 Martin Becket 中发现回答有错误。如果您与该网页的信息进行比较,您会发现中间的部分:
(lat1)*sin(lat2)
实际上应该是:
cos(lat1)*sin(lat2) )
本来会留下评论,但还没有声誉......
There is a very nice page explaining the formulas between GPS-based distance, bearing, etc. calculation, which I have been using:
http://www.movable-type.co.uk/scripts/latlong.html
I am currently trying to do these calculations myself, and just found out that in Martin Becket answer there is an error. If you compare to the info of that webpage, you will see that the part in the middle:
(lat1)*sin(lat2)
should actually be:
cos(lat1)*sin(lat2)
Would have left a comment, but don't have the reputation yet...