Skip to content

Repeated messages from gpsd_client #3

@hordurk

Description

@hordurk

I'm not sure if this is a result of my gpsd configuration or my gps units (u-blox 5 series), but I've been getting repeated (not identical) ROS messages published by gpsd_client with use_gps_time off:

$ rostopic echo /fix

---
header: 
  seq: 15
  stamp: 
    secs: 1399540052
    nsecs: 800140800
  frame_id: ''
status: 
  status: 0
  service: 1
latitude: 34.146363167
longitude: -118.137884833
altitude: 282.3
position_covariance: [10.58, 0.0, 0.0, 0.0, 17.533, 0.0, 0.0, 0.0, 32.785]
position_covariance_type: 2

---
header: 
  seq: 16
  stamp: 
    secs: 1399540052
    nsecs: 801611257
  frame_id: ''
status: 
  status: 0
  service: 1
latitude: 34.146361667
longitude: -118.137885833
altitude: 282.5
position_covariance: [10.58, 0.0, 0.0, 0.0, 17.533, 0.0, 0.0, 0.0, 32.785]
position_covariance_type: 2

---
header: 
  seq: 17
  stamp: 
    secs: 1399540053
    nsecs: 814012306
  frame_id: ''
status: 
  status: 0
  service: 1
latitude: 34.146361667
longitude: -118.137885833
altitude: 282.5
position_covariance: [10.58, 0.0, 0.0, 0.0, 17.533, 0.0, 0.0, 0.0, 32.785]
position_covariance_type: 2

---
header: 
  seq: 18
  stamp: 
    secs: 1399540053
    nsecs: 815928396
  frame_id: ''
status: 
  status: 0
  service: 1
latitude: 34.146360333
longitude: -118.137886833
altitude: 282.6
position_covariance: [10.58, 0.0, 0.0, 0.0, 17.533, 0.0, 0.0, 0.0, 32.785]
position_covariance_type: 2

---

As can be seen in the above, messages 15 and 16 are sent at almost the same time but have different lat,lon values, while 16 and 17 have the same lat,lon but are a second apart. The same goes for the extended fix.

I've tracked down the cause of this and it seems that libgps is receiving the full fix in two separate messages as can be seen using gpspipe:

$ gpspipe -w 
{"class":"SKY","tag":"GSV","device":"/dev/ttyACM0","xdop":0.62,"ydop":0.65,"vdop":1.28,"tdop":0.71,"hdop":0.90,"gdop":1.72,"pdop":1.56,"satellites":[{"PRN":5,"el":7,"az":46,"ss":23,"used":true},{"PRN":15,"el":43,"az":99,"ss":29,"used":true},{"PRN":16,"el":18,"az":310,"ss":43,"used":true},{"PRN":18,"el":62,"az":235,"ss":34,"used":true},{"PRN":21,"el":60,"az":327,"ss":45,"used":true},{"PRN":22,"el":23,"az":231,"ss":0,"used":false},{"PRN":25,"el":9,"az":188,"ss":33,"used":true},{"PRN":26,"el":25,"az":61,"ss":31,"used":true},{"PRN":27,"el":0,"az":317,"ss":0,"used":false},{"PRN":29,"el":62,"az":136,"ss":37,"used":true},{"PRN":51,"el":49,"az":161,"ss":30,"used":false}]}
{"class":"TPV","tag":"GLL","device":"/dev/ttyACM0","mode":3,"time":"2014-05-08T08:51:11.000Z","ept":0.005,"lat":34.146406500,"lon":-118.137705667,"alt":270.300,"epx":9.292,"epy":9.817,"epv":29.402,"track":0.0000,"speed":0.030,"climb":0.000,"eps":19.63}

This results in two gps->read() calls in quick succession and therefore two calls to process_data and then publish. What should happen instead is that the first message (GSV) needs to be read but process_data not called, instead calling it on the second message (GLL). I've done a quick fix for this on my part with the following patch:

diff --git a/gpsd_client/src/client.cpp b/gpsd_client/src/client.cpp
index 06ecd18..54eb220 100644
--- a/gpsd_client/src/client.cpp
+++ b/gpsd_client/src/client.cpp
@@ -60,7 +60,11 @@ class GPSDClient {
 #else
       gps_data_t *p = gps->poll();
 #endif
+      if(strcmp(p->tag,"GSV")==0) {
+          return;
+      }
       process_data(p);
+
     }

     void stop() {

But since I don't have another GPS to test with, I'm not sure if this is a good solution to the problem (doubt it).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions