• <tfoot id='0fe3R'></tfoot>

        <i id='0fe3R'><tr id='0fe3R'><dt id='0fe3R'><q id='0fe3R'><span id='0fe3R'><b id='0fe3R'><form id='0fe3R'><ins id='0fe3R'></ins><ul id='0fe3R'></ul><sub id='0fe3R'></sub></form><legend id='0fe3R'></legend><bdo id='0fe3R'><pre id='0fe3R'><center id='0fe3R'></center></pre></bdo></b><th id='0fe3R'></th></span></q></dt></tr></i><div id='0fe3R'><tfoot id='0fe3R'></tfoot><dl id='0fe3R'><fieldset id='0fe3R'></fieldset></dl></div>
        <legend id='0fe3R'><style id='0fe3R'><dir id='0fe3R'><q id='0fe3R'></q></dir></style></legend>
        • <bdo id='0fe3R'></bdo><ul id='0fe3R'></ul>
      1. <small id='0fe3R'></small><noframes id='0fe3R'>

        在 Python 中通过正则表达式解析 GPS 接收器输出

        时间:2023-09-27

            <small id='Tl3C7'></small><noframes id='Tl3C7'>

            <tfoot id='Tl3C7'></tfoot>
              <bdo id='Tl3C7'></bdo><ul id='Tl3C7'></ul>

              <i id='Tl3C7'><tr id='Tl3C7'><dt id='Tl3C7'><q id='Tl3C7'><span id='Tl3C7'><b id='Tl3C7'><form id='Tl3C7'><ins id='Tl3C7'></ins><ul id='Tl3C7'></ul><sub id='Tl3C7'></sub></form><legend id='Tl3C7'></legend><bdo id='Tl3C7'><pre id='Tl3C7'><center id='Tl3C7'></center></pre></bdo></b><th id='Tl3C7'></th></span></q></dt></tr></i><div id='Tl3C7'><tfoot id='Tl3C7'></tfoot><dl id='Tl3C7'><fieldset id='Tl3C7'></fieldset></dl></div>
            • <legend id='Tl3C7'><style id='Tl3C7'><dir id='Tl3C7'><q id='Tl3C7'></q></dir></style></legend>

                    <tbody id='Tl3C7'></tbody>
                  本文介绍了在 Python 中通过正则表达式解析 GPS 接收器输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个朋友正在完成他的航空航天工程硕士学位.对于他的最后一个项目,他在一个小团队中负责编写一个跟踪气象气球、火箭和卫星的程序.该程序接收来自 GPS 设备的输入,对数据进行计算,并使用这些计算结果来控制一系列电机,这些电机旨在定向定向通信天线,因此气球、火箭或卫星始终保持焦点.

                  I have a friend who is finishing up his masters degree in aerospace engineering. For his final project, he is on a small team tasked with writing a program for tracking weather balloons, rockets and satellites. The program receives input from a GPS device, does calculations with the data, and uses the results of those calculations to control a series of motors designed to orientate a directional communication antenna, so the balloon, rocket or satellite always stays in focus.

                  虽然我自己有点(永恒的)初学者,但我比我的朋友有更多的编程经验.因此,当他向我寻求建议时,我说服他用我选择的语言 Python 编写程序.

                  Though somewhat of a (eternal) beginner myself, I have more programming experience than my friend. So when he asked me for advice, I convinced him to write the program in Python, my language of choice.

                  在项目的这一点上,我们正在处理解析来自 GPS 设备的输入的代码.这是一些示例输入,我们需要提取的数据以粗体显示:

                  At this point in the project, we are working on the code that parses the input from the GPS device. Here is some example input, with the data we need to extract in bold:

                  $GPRMC,092204.999,4250.5589,S,14718.5084,E,1,12,24.4,89.6,M,,,0000*1F$GPRMC,093345.679,4234.7899,N,11344.2567,W,3,02,24.5,1000.23,M,,,0000*1F$GPRMC,044584.936,1276.5539,N,88734.1543,E,2,04,33.5,600.323,M,,,*00$GPRMC,199304.973,3248.7780,N,11355.7832,W,1,06,02.2,25722.5,M,,,*00$GPRMC,066487.954,4572.0089,S,45572.3345,W,3,09,15.0,35000.00,M,,,*1F

                  $GPRMC,092204.999,4250.5589,S,14718.5084,E,1,12,24.4,89.6,M,,,0000*1F $GPRMC,093345.679,4234.7899,N,11344.2567,W,3,02,24.5,1000.23,M,,,0000*1F $GPRMC,044584.936,1276.5539,N,88734.1543,E,2,04,33.5,600.323,M,,,*00 $GPRMC,199304.973,3248.7780,N,11355.7832,W,1,06,02.2,25722.5,M,,,*00 $GPRMC,066487.954,4572.0089,S,45572.3345,W,3,09,15.0,35000.00,M,,,*1F

                  以下是对数据的进一步解释:

                  Here is some further explanation of the data:

                  我看起来需要五样东西从每一行.记住这些区域中的任何一个都可能是空的.意味着只有两个逗号紧挨着.这样的如 ',,,' 有两个字段可以随时吃饱.仅其中一些他们有两个或三个选项可能是,但我认为我不应该是指望这一点."

                  "I looks like I'll need five things out of every line. And bear in mind that any one of these area's may be empty. Meaning there will be just two commas right next to each other. Such as ',,,' There are two fields that may be full at any time. Some of them only have two or three options that they may be but I don't think I should be counting on that."

                  两天前,我的朋友能够从用于跟踪最近气象气球发射的 GPS 接收器获取完整日志.数据比较长,所以我都放在这个pastebin中.

                  Two days ago my friend was able to acquire the full log from the GPS receiver used to track a recent weather balloon launch. The data is quite long, so I put it all in this pastebin.

                  我自己对正则表达式还是很陌生,所以我正在寻求一些帮助.

                  I am still rather new with regular expressions myself, so I am looking for some assistance.

                  推荐答案

                  拆分应该可以解决问题.这也是一种提取数据的好方法:

                  splitting should do the trick. Here's a good way to extract the data, as well:

                  >>> line = "$GPRMC,199304.973,3248.7780,N,11355.7832,W,1,06,02.2,25722.5,M,,,*00"
                  >>> line = line.split(",")
                  >>> neededData = (float(line[2]), line[3], float(line[4]), line[5], float(line[9]))
                  >>> print neededData
                  (3248.7779999999998, 'N', 11355.7832, 'W', 25722.5)
                  

                  这篇关于在 Python 中通过正则表达式解析 GPS 接收器输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Python GPS 模块:读取最新的 GPS 数据 下一篇:在给定点、方位角和距离的情况下计算 gps 坐标

                  相关文章

                      <small id='P5gtm'></small><noframes id='P5gtm'>

                        <bdo id='P5gtm'></bdo><ul id='P5gtm'></ul>

                      <tfoot id='P5gtm'></tfoot>
                    1. <legend id='P5gtm'><style id='P5gtm'><dir id='P5gtm'><q id='P5gtm'></q></dir></style></legend>
                      <i id='P5gtm'><tr id='P5gtm'><dt id='P5gtm'><q id='P5gtm'><span id='P5gtm'><b id='P5gtm'><form id='P5gtm'><ins id='P5gtm'></ins><ul id='P5gtm'></ul><sub id='P5gtm'></sub></form><legend id='P5gtm'></legend><bdo id='P5gtm'><pre id='P5gtm'><center id='P5gtm'></center></pre></bdo></b><th id='P5gtm'></th></span></q></dt></tr></i><div id='P5gtm'><tfoot id='P5gtm'></tfoot><dl id='P5gtm'><fieldset id='P5gtm'></fieldset></dl></div>