你会为Python推荐哪个gps库?

发布于 2024-07-22 20:56:51 字数 1542 浏览 12 评论 0原文

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

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

发布评论

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

评论(6

国产ˉ祖宗 2024-07-29 20:56:51

我不确定我是否理解您的确切要求,但是,根据您的设备和c,似乎有很多可能的候选者,例如:

如果你的意思是你已经获得了 GPS 的单位输出并且只是需要解析它&c,我怀疑上面的一个或多个示例(不幸的是我没有尝试过)将包含用于该任务的良好隔离的模块,根据许可条件,您可以重新调整其用途; 这个问题可能也会有帮助,如果这就是你的意思正在做。

I'm not sure I understand your exact requirements, but, depending on your device &c, there seem to be many possible candidates, such as:

If what you mean is that you've already obtained the GPS' unit output and just need to parse it &c, I suspect that one or more of the above examples (which unfortunately I have not tried) will contain well-isolated modules for that task, which, depending on licensing conditions, you could repurpose; this SO question might also help if that's what you're doing.

謸气贵蔟 2024-07-29 20:56:51

《Beginning Python Visualization》一书就包含了这样一个例子——解析 GPS 数据并从中推断速度和位置。 其源代码可在线获取:http://www.apress.com/

The book "Beginning Python Visualization" includes just such an example - parsing GPS data and inferring speed and location from it. Its source code is available online at http://www.apress.com/

给我一枪 2024-07-29 20:56:51

从 GPS 设备接收到的 GPS 语句非常容易解码,这看起来是一个有趣的项目。 我不确定你从 gspd 得到了什么,但如果是这些句子,几周前我实际上不得不为学校做这样的事情(但在 LabView 中):

$GPGGA,hhmmss.ss,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx

hhmmss.ss = UTC of position 
llll.ll = latitude of position
a = N or S
yyyyy.yy = Longitude of position
a = E or W 
x = GPS Quality indicator (0=no fix, 1=GPS fix, 2=Dif. GPS fix) 
xx = number of satellites in use 
x.x = horizontal dilution of precision 
x.x = Antenna altitude above mean-sea-level
M = units of antenna altitude, meters 
x.x = Geoidal separation
M = units of geoidal separation, meters 
x.x = Age of Differential GPS data (seconds) 
xxxx = Differential reference station ID 

所以你可以做 gpsstring.split(',' ),您将获得一个包含所有元素的数组,然后您可以对其进行解析。 要了解有关这些句子的更多信息(我认为还有其他句子的速度和方向),请点击此处

例如,要获取两点之间的近似距离,您可以使用 Haversine 公式

distance=R*2*asin(sqrt((sin((lat1-lat2)/2))**2
               +cos(lat1)*cos(lat2)*(sin((long1-long2)/2))**2))

其中 R是地球的半径,以您想要获得结果的测量单位表示(例如 R=6372km)。 该实际行取自我手边的 LabView 程序,但语法与 Python 非常相似(也许检查 division 运算符,您可能需要执行“from future import 除法”。

另外,lat1、lat2、long1 和 long2 必须以弧度格式表示。 它们非常奇怪(hhmm.ff,其中 ff 是分钟的分数,所以它们从 0 到 99 而不是 0 到 59(作为秒))

你得到的

h=floor(x/100);
m=floor(x-(h*100));
s=(x-floor(x))*60;
deg=sgn*(h+(m/60)+(s/3600));
rad=deg*pi/180;

。 1 表示北和东,-1 表示南和东。同样,

我认为检查边界是最简单的部分,如果您已经获得了弧度或度数的位置,则可以检查纬度是否为。在两个纬度边界之间,并对经度执行相同的操作,为

所有内容编写一个包装器,然后您就得到了 GPS 库:)

The GPS sentences that you receive from a GPS device are pretty easy to decode, and this looks like a fun project. I'm not sure what you get from gspd, but if it's these sentences, I actually had to do something like this for school a few weeks ago (but in LabView):

$GPGGA,hhmmss.ss,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx

hhmmss.ss = UTC of position 
llll.ll = latitude of position
a = N or S
yyyyy.yy = Longitude of position
a = E or W 
x = GPS Quality indicator (0=no fix, 1=GPS fix, 2=Dif. GPS fix) 
xx = number of satellites in use 
x.x = horizontal dilution of precision 
x.x = Antenna altitude above mean-sea-level
M = units of antenna altitude, meters 
x.x = Geoidal separation
M = units of geoidal separation, meters 
x.x = Age of Differential GPS data (seconds) 
xxxx = Differential reference station ID 

So you could just do a gpsstring.split(',') and you'll get an array of all elements which you can then parse. To see more about these sentences (there are others I think for speed and direction), click here.

For example, to get the approximate distance between two points you can use the Haversine Formula:

distance=R*2*asin(sqrt((sin((lat1-lat2)/2))**2
               +cos(lat1)*cos(lat2)*(sin((long1-long2)/2))**2))

Where R is the radius of the Earth in the unit of measurement you want to get your result in (for example R=6372km). That actual line is taken from the LabView program I had lying around, but the syntax is pretty similar to Python's (maybe check the division operator, you might want to do "from future import division".

Also, lat1, lat2, long1 and long2 have to be expressed in radians. The format you're getting them in is pretty strange (hhmm.ff, where ff are fractions of minutes, so they go from 0 to 99 instead of 0 to 59 (as seconds)).

The code I used for that is:

h=floor(x/100);
m=floor(x-(h*100));
s=(x-floor(x))*60;
deg=sgn*(h+(m/60)+(s/3600));
rad=deg*pi/180;

Where sign is 1 for North and East, and -1 for South and East. Again, watch out for division.

Checking boundaries is I think the easiest part. If you've already got the positions in radians or degrees, you can just check if latitude is between two lat boundaries, and do the same for longitude.

Write a wrapper around everything, and you've got your GPS library :)

世界等同你 2024-07-29 20:56:51

显然 gpsd 附带的 python 模块是最适合我们的模块。

gpsd 附带的 gps 模块有一些非常有用的功能。 第一个是从 GPSD 获取数据并将这些数据转换为可用的数据结构。
然后,这些模块可以让您访问您的速度以及当前相对于北方的航向。
还包括一个计算地球上两个坐标之间的距离的函数,考虑到地球的球形性质。

我们的特殊情况缺少的功能是:

  • 计算点之间的航向。 意味着我位于朝北的点,我必须转向哪个角度才能面向我想要导航到的点。

  • 利用第一个函数的数据和当前航向来计算我们必须面对所需点的转角(没什么大不了的,因为它主要只是减法)

使用这个库的最大问题是它主要是 gpsd 的包装器,因此如果您在不同的操作系统上编程,那么您的 gpscode 应该像 Windows 或 MacOS 一样工作,您将无法运行代码或安装模块。

Apparently the python module that comes with gpsd is the best module to go with for us.

The gps module coming with the gpsd has some very useful functions. The first one is getting the data from gpsd and transforming those data in a usable data structure.
Then the moduls give you access to your speed, and your current heading relative to north.
Also included is a function for calculating the distance between two coordinates on the earth taking the spherical nature of earth into account.

The functions that are missing for our special case are:

  • Calculating the heading between to points. Means I am at point a facing north to which degree do I have to turn to face the point I want to navigate to.

  • Taking the data of the first function and our current heading to calculate a turn in degrees that we have to do to face a desired point (not a big deal because it is mostly only a subtraction)

The biggest problem for working with this library is that it is mostly a wrapper for the gpsd so if you are programming on a different OS then you gpscode should work on like Windows or MacOS you are not able to run the code or to install the module.

山有枢 2024-07-29 20:56:51

大多数好的 GPS 设备(我们使用 Oncore M12M)实际上都会为您提供速度和航向作为输出。 我首先会检查您的 GPS 接收器的文档,看看是否已发送此信息,或者是否可以启用此类消息。 根据我的经验,这些数据通常是接收器向您提供的标准遥测数据的一部分。

如果这不起作用,我认为最好的选择是使用 WGS-84(GPS 坐标系)的详细信息来获取实际的 (x,y,z) 坐标,然后将其与下一个坐标相区别以找到您的航向并获取时间间隔内差异的大小来找到速度。 这里有一些细节:
http://topex.ucsd.edu/geodynamics/14gravity1_2.pdf

如果你真的想要一个包可以完成这一切,我认为 pyEphem 非常好,尽管我认为您可以通过自己编写它来节省一些搜索时间并获得一些好的知识。

(抱歉,如果没有帮助,第一次发帖,仍在学习如何堆栈溢出)

Most good GPS units (we use Oncore M12M) will actually give you, as output, your velocity and heading. I would first check your GPS receiver's documentation to see if this information is already being sent, or if such a message can be enabled. In my experience, this data is usually part of the standard telemetry a receiver will give you.

If that doesn't work, I think your best bet is using the details of WGS-84 (the GPS coordinate system) to obtain an actual (x,y,z) coordinate and then difference it with the next one to find your heading and take the magnitude of the difference over the time interval to find your velocity. Some details here:
http://topex.ucsd.edu/geodynamics/14gravity1_2.pdf

If you really want a package that does all this, I think pyEphem is pretty good, although I think you might save a little time searching and gain some good knowledge by writing it yourself.

(Sorry if unhelpful, first time poster, still learning how to stack overflow)

弃爱 2024-07-29 20:56:51

我发现 gpsd-py3 库 对于您描述的任务非常有用。

I found the gpsd-py3 library very useful for the task you describe.

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