OpenWRT上的C程序,GPSD接收错误/奇怪的坐标 [英] C program on OpenWRT with GPSD receiving wrong/weird coordinates

查看:347
本文介绍了OpenWRT上的C程序,GPSD接收错误/奇怪的坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用连接到运行OpenWRT(姿态调整12.09)和GPSD(3.7)的TP-Link TL-WR703N的USB端口的GPS加密狗(Bluenext - BN903S)以及我的C程序来接收和显示坐标。 br />


当我出去测试它时,清除天空和所有,GPS加密狗的LED闪烁,表示它有一个修复,在运行我的应用程序时,显示的坐标每5-7秒左右似乎在不断变化。但是,正如您在下面的屏幕截图中看到的那样,即使我在区域内移动(图像中以红线显示),程序也记录了我在有标记的位置。所以坐标会改变,但它们都是错误的,都集中在一个小区域......



GPS坐标图像:http://i40.tinypic.com/2ex5x7d .jpg



这是我上次的源代码。就源代码而言,没有什么复杂的,这就是为什么我想知道它甚至可能不是源代码的错。我已经尝试了很多技术来接收它们但是都有类似的结果。



有谁可以帮助解决这里可能出现的问题?



非常感谢帮助。



I use a GPS dongle (Bluenext - BN903S) connected to the USB port of a TP-Link TL-WR703N running OpenWRT (Attitude Adjustment 12.09) and GPSD (3.7) along with my C program to receive and display coordinates.

When I go out to test it, clear sky and all, the GPS dongle's LED flashes, which indicates it has a fix, and while running my application, the coordinates displayed every 5-7 seconds or so seem to be constantly changing. However, as you can see in the screenshot below, even though I move around the area (displayed in red line in the image), the program logged that I was in the spots where there are markers. So the coordinates change, but they are wrong and all concentrated in one small area...

GPS coords image: http://i40.tinypic.com/2ex5x7d.jpg

This is the source code I had last. Nothing complex as far as the source-code goes, that's why I am wondering that it might not even be the source code's fault. I have tried so many "techniques" to receive them but all have similar result.

Can anyone help out what might the problem be here?

Help is much appreciated.

if(gps_open("127.0.0.1", "2947", &gpsdata)<0)   // Check if GPS initialized ok ports: 2947
{
    printf("GPS open failed with error: %d\n", gps_open("127.0.0.1", "2947", &gpsdata));
    exit(EXIT_FAILURE);
}
else
{
    printf("GPS open OK\n");
    if(gps_stream(&gpsdata, WATCH_ENABLE, NULL) != 0)
    {
        printf("Data stream failed\n");
    }
    else
    {
        printf("GPS stream OK\n");
    }
}

AGAIN:while(1)
{
    double lat, longi;

    if(gps_waiting(&gpsdata, 2000)) // Checks if there is new data from the GPS. True means data, false no data or error
    {
        printf("there is data waiting\n");
        if(gps_read(&gpsdata) == -1)
        {
            printf("gps_read error\n");
        }
        else if(gpsdata.status > 0)     // GPS does have a fix
        {
                printf("Using %d satellites of %d visible\n", gpsdata.satellites_used, gpsdata.satellites_visible);

                lat = gpsdata.fix.latitude;
                longi = gpsdata.fix.longitude;

                if((isnan(lat) != 0) && (isnan(longi) != 0))        // To check if values are NaN (Not A Number)
                {
                    curTime = time(NULL);           // Update the current time
                    printf("Time %s : GPS fix is NaN %f, %f\n", ctime(&curTime), lat, longi);
                }
                else
                {
                    printf("MY Latitude %f and Longitude %f\n", lat, longi);
                }
        }
    } //END OF IF WAITING
    sleep(5);
}   //end of while(1)

推荐答案

引用:

所以坐标发生了变化,但它们都是错误的,都集中在一个小区域......

So the coordinates change, but they are wrong and all concentrated in one small area...





这不是一个精确的陈述。在我看来,gps确切地知道你在一个可指定的错误栏中的位置。



我要做的第一件事是将你的结果与手持gps进行比较 - 例如Garmin etrex。



我没有使用GPSD,可能不会。我更愿意知道发生了什么。几乎所有gps模块都可以配置为发送NMEA记录,这些非常容易解析。我更喜欢使用它们,因为它们直接来自gps,并提供了gps正在做什么的非常全面的图片。每条记录都会显示当时的gps状态。我不知道GPSD在这方面做了什么。



编写自己的GPS应用程序:第一部分 [ ^ ]



你需要建立的是HDOP。这是对修复的水平质量的度量。如果你可以用GPSD做到这一点,并学习如何解释结果。所有gps修复都有错误 - 它们并不准确。可见卫星的一些几何形状将允许建立修复但质量非常差。



http://en.wikipedia.org/wiki/Dilution_of_precision_(GPS) [ ^ ]



在结束您的代码存在问题之前,我会做所有这些。



但是我会评论说,在我看来这是一个很差的库,可以返回一个nan。有效的修复应始终是有效数据。它应该返回修复的状态 - 有效或无效。

此外,time()从不用于gps数据。与每次读数相关的gps的时间值远比主机时间准确得多 - 它来自原子钟。



另外我看到gpsd是基于nmea而你可以输出日志。我建议你这样做。



This is not a precise statement. It seems to me the gps knows exactly where you are within a specifiable error bar.

The first thing I would do is compare your results with a handheld gps - eg Garmin etrex.

I have not used GPSD and probably would not. I prefer to know what is going on. Almost all gps modules can be configured to send NMEA records and these are very easy to parse. I prefer to use these because they come directly from the gps and provide a very comprehensive picture of what the gps is doing. Each record gives gps status at the time. I don't know what GPSD is doing in this regard.

Writing Your Own GPS Applications: Part I[^]

What you need to establish is the HDOP. This is a measure of the horizontal quality of the fix. If you can do this with GPSD do it and learn how to interpret the result. All gps fixes have an error - they are not exact. Some geometries of visible satellites will allow a fix to be established but of very poor quality.

http://en.wikipedia.org/wiki/Dilution_of_precision_(GPS)[^]

I would do all this before concluding there is a problem with your code.

I would however comment that in my opinion it is a poor library that returns a nan. A valid fix should always be valid data. It should return the status of the fix - valid or invalid.
Also time() is never used for gps data. The time value from the gps associated with each reading is far more accurate than host computer time - it comes from atomic clock.

Also I see gpsd is nmea based and you can output a log. I suggest you do this.


这篇关于OpenWRT上的C程序,GPSD接收错误/奇怪的坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆