GPSD - Getting configuration right

EDIT: Adding answers as I come across them

Hi all,

I am trying to get gpsd / SatNOGS working with a GPS Pi Hat. The hat and gpsd works with demo code, but it does not appear to be being used by SatNOGS despite configuring as below:

GPSD_ENABLED=True

I have found little documentation or references to this, so thought it might be a good time to investigate and ask some questions to gather the knowledge.

1. How should the Basic Configuration be set on the DEVICE for Lat/Lon/Alt when this will vary?

2. How (if at all), is this reflected when scheduling observations (on WEB)?

Answer: When a station sends new location details, these are automatically updated on the network for future observations. This will NOT be reflected in any already scheduled observations.

3. What other configuration is required for this to work?

4. Should the /etc/default/satnogs-client contain references to using gpsd?

Presently my observations just use the details in the /etc/default/satnogs-client file (lat/lon/alt).

Any thoughts would be great.

A quick reply on this after a quick search, it looks like that client supports GPSD, however the configuration menu has never been completed to support all the necessary menu items. In other words it was never completely added as feature but it seems we are really close to complete it.

In client code there are functions/methods that get the position and set it for use. In the file above there are four related settings:

settings.SATNOGS_GPSD_CLIENT_ENABLED
settings.SATNOGS_GPSD_HOST
settings.SATNOGS_GPSD_PORT
settings.SATNOGS_GPSD_TIMEOUT

However only SATNOGS_GPSD_CLIENT_ENABLED is available in configuration menu. There was a merge request to add the rest but it was closed by the author and it hasn’t been merged.

I’m not sure how easy is or if it is impossible to set these extra settings without using the configuration tool. I’ll try to find out more details and let you know.

1 Like

Hi!

Im looking to make an existing station portable - have there been any updates to getting the SatNOGS client to auto update position based on a GPS sensor? Either through GPSD or some other means?

Thanks in advance!

1 Like

Unfortunately there aren’t any updates since my last post. We still need someone to complete its development and test it.

However maybe it needs more care as we currently move to docker containers all the parts of the client. Maybe @Acinonyx has better view on this.

@cameron or anyone else who may be interested on develop this please join the #satnogs-dev channel where the discussions about development take place.

I would be happy to complete development & test this / help with testing by others!

The move to a docker-based setup might spark the need for some additional work, but should be no blocker. Essentially the following components of a SatNOGS Station need modifications to support mobile stations:

  • satnogs-client (done by @drid & released!)
  • satnogs-client-ansible (done by @drid & released !)
  • satnogs-config: partially done, missing variables: SATNOGS_GPSD_HOST/SATNOGS_GPSD_PORT / SATNOGS_GPSD_TIMEOUT

So, already right now you can run a mobile station, but you have to add the configuration for it into the /etc/default/satnogs-client manually (and remember to re-add it each time after running satnogs-setup).

Let me know if you are interested in testing this.

A bit reluctant in answering because there a quite a couple of issue you will run into.

It is possible, I have a running gpsd daemon on my SatNOGS client.

I am using a cheap USB u-blox gps receiver and by default the only thing you have to do is add the gps device file in /etc/default/gpsd, in my case it is /dev/ttyUSB0 check the access right for the device

ls -l /dev/ttyUSB0 
crw-rw---- 1 root dialout 188, 0 Jan 18 14:30 /dev/ttyUSB0

The user interacting with /dev/ttyUSB0 need to be member of the dialout group.

# Devices gpsd should collect to at boot time.
# They need to be read/writeable, either by user gpsd or the group dialout.
DEVICES="/dev/ttyUSB0"

# Other options you want to pass to gpsd
GPSD_OPTIONS=""

# Automatically hot add/remove USB GPS devices via gpsdctl
USBAUTO="true"

This should be enough to get it up and running sudo systemctl enable gpsd and sudo systemctl start gpsd' but in my case I ran into a problem, by default gpsd want to use ipv6 address ::1 and that was available on my system and I have to modify/lib/systemd/system/gpsd.socket`

[Unit]
Description=GPS (Global Positioning System) Daemon Sockets

[Socket]
ListenStream=/run/gpsd.sock
# ListenStream=[::1]:2947
ListenStream=127.0.0.1:2947
# To allow gpsd remote access, start gpsd with the -G option and
# uncomment the next two lines:
# ListenStream=[::]:2947
# ListenStream=0.0.0.0:2947
SocketMode=0600
BindIPv6Only=no

[Install]
WantedBy=sockets.target

Now run sudo systemctl daemon-reload and try to start sudo systemctl restart gpsd.socket and sudo systemctl restart gpsd with sudo systemctl status gpsd you can see if it is up and running.

Now with gpsmon -n I can see if gpsd is working.

dev/ttyACM0                  NMEA0183>
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚Time: 2023-01-18T13:16:43.000Z   Lat: xx 43.264000' N   Lon:   x 01.809200' E β”‚
└───────────────────────────────── Cooked TPV β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ GPZDA GPGGA GPRMC GPGSA GPGSV GPGBS GPALM                                    β”‚
└───────────────────────────────── Sentences β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ SVID  PRN  Az El SN HUβ”‚Time:     131643.00      β”‚Time:      131643.00        β”‚
β”‚GP 10   10 264  8 16  Yβ”‚Latitude:    xx43.2640 N β”‚Latitude:  xx43.2640        β”‚
β”‚GP 12   12 241 76 11  Yβ”‚Longitude:  xxx01.8092 E β”‚Longitude: xxx01.8092       β”‚
β”‚GP 17   17  35 11 14  Yβ”‚Speed:    0.0194         β”‚Altitude:  -16.58           β”‚
β”‚GP 19   19  55 36  9  Yβ”‚Course:   65.765         β”‚Quality:   1   Sats: 13     β”‚
β”‚GP 24   24 130 63 22  Yβ”‚Status:   A        FAA:  β”‚HDOP:      0.96             β”‚
β”‚GP 25   25 248 45 13  Yβ”‚MagVar:   1.5  E         β”‚Geoid:     44.83            β”‚
β”‚GP 32   32 302 37 11  Y└───────── RMC ───────────└─────────── GGA β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚GA  2  302 253 55 11  Yβ”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚GP  6    6  85 14  0  Nβ”‚Mode: A3 Sats: 10 12 17 +β”‚UTC:           RMS:         β”‚
β”‚GP 11   11 119  2  0  Nβ”‚DOP H=1.0  V=1.2  P=1.5  β”‚MAJ:           MIN:         β”‚
β”‚GP 15   15 175  5 21  Nβ”‚TOFF:  0.039455254       β”‚ORI:           LAT:         β”‚
β”‚GP 22   22 322 12  0  Nβ”‚PPS: N/A                 β”‚LON:           ALT:         β”‚
└───v──── GSV ──────────└────── GSA + PPS ────────└─────────── GST β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
(32) $GPGSV,9,9,33,428,18,157,00*7D
(91) $GPALM,1,1,09,0197,00,1515,63,08a7,fffffd5c,a10d12,4ff77d,1119f6,ffdfede0,f
fffff0b,002*4B
(38) $GPZDA,131643.00,18,01,2023,00,00*6F
(76) $GPGGA,131643.00,5143.2640,N,00501.8092,E,1,13,0.96,-16.58,M,44.836,M,,*7D
(75) $GPRMC,131643.00,A,5143.2640,N,00501.8092,E,0.0194,65.765,180123,1.5,E*58
(56) $GPGSA,A,3,10,12,17,19,24,25,32,302,,,,,1.5,1.0,1.2*09
(44) $GPGBS,131643.00,7.363,12.371,5.913,,,,*7A
(70) $GPGSV,9,1,33,06,14,085,00,10,08,264,16,11,02,119,00,12,76,241,11*7F

So with some obstacles gpsd is running and active, now how to tell the SatNOGS client to use the location data provided with gpsd?

My best guess is to set the following variables:

SATNOGS_GPSD_CLIENT_ENABLED=True
SATNOGS_GPSD_HOST=127.0.0.1
SATNOGS_GPSD_PORT=2947
SATNOGS_GPSD_TIMEOUT=0

I do wonder if the satnogs-client location will also be managed by these settings maybe @kerel can answer this.

Some commands to see if thing are working:

SatNOGS logging sudo journalctl -f -u satnogs-client -n 512
GPS logging sudo journalctl -f -u gpsd -n 512
GPS socket logging sudo journalctl -f -u gpsd.socket -n 512

I hope this is useful and will get people starting.

1 Like

Yes, exactly! If you enable gpsd usage in satnogs-client by setting SATNOGS_GPSD_CLIENT_ENABLED=True (in addition to the three variables mentioned above), then the client will update the station location every time it fetches new jobs from SatNOGS Network, by default every 60 seconds, and ignore the location defined in the configuration.

1 Like

the SATNOGS_GPSD_TIMEOUT should probably not be set to 0, as it never quits waiting for position. perhaps 10-30s is more sensible ?
I have station dev-351 ready for testing.

Jan 18 18:30:15 raspi-sat2 satnogs-client[1871]: satnogsclient.locator.locator - INFO - Waiting for GPS (timeout 10s)
Jan 18 18:30:26 raspi-sat2 satnogs-client[1871]: satnogsclient.locator.locator - INFO - GPS timeout, using last known coordinates
Jan 18 18:30:26 raspi-sat2 satnogs-client[1871]: satnogsclient.scheduler.tasks - INFO - Trying to GET observation jobs from the network
Jan 18 18:31:15 raspi-sat2 satnogs-client[1871]: satnogsclient.locator.locator - INFO - Last coordinates 63.854000 20.208000 35
Jan 18 18:31:15 raspi-sat2 satnogs-client[1871]: satnogsclient.locator.locator - INFO - Connecting to GPSD 127.0.0.1:2947
Jan 18 18:31:15 raspi-sat2 satnogs-client[1871]: satnogsclient.locator.locator - INFO - Waiting for GPS (timeout 10s)
Jan 18 18:31:15 raspi-sat2 satnogs-client[1871]: satnogsclient.scheduler.tasks - INFO - Post data started

and some reboot later, the gps doesn’t respond, so the client gets stuck anyways.

Jan 18 20:55:08 raspi-sat2 satnogs-client[382]: satnogsclient.locator.locator - INFO - Waiting for GPS (timeout 10s)
Jan 18 20:56:08 raspi-sat2 satnogs-client[382]: apscheduler.scheduler - WARNING - Execution of job "get_jobs (trigger: interval[0:01:00], next run at: 2023-01-18 20:56:08 UTC)" skipped: maximum number of running instances reached (1)
Jan 18 20:56:08 raspi-sat2 satnogs-client[382]: satnogsclient.scheduler.tasks - INFO - Post data started

After setting the option GPSD_OPTIONS="-b -s 4800" it at least works… But the NaN as height (?) throws an exception.

Jan 18 21:18:49 raspi-sat2 satnogs-client[389]: --- Logging error ---
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]: Traceback (most recent call last):
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:   File "/usr/lib/python3.9/logging/__init__.py", line 1079, in emit
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:     msg = self.format(record)
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:   File "/usr/lib/python3.9/logging/__init__.py", line 923, in format
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:     return fmt.format(record)
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:   File "/usr/lib/python3.9/logging/__init__.py", line 659, in format
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:     record.message = record.getMessage()
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:   File "/usr/lib/python3.9/logging/__init__.py", line 363, in getMessage
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:     msg = msg % self.args
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]: ValueError: cannot convert float NaN to integer
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]: Call stack:
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:   File "/usr/lib/python3.9/threading.py", line 912, in _bootstrap
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:     self._bootstrap_inner()
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:   File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:     self.run()
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:   File "/usr/lib/python3.9/threading.py", line 892, in run
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:     self._target(*self._args, **self._kwargs)
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:   File "/usr/lib/python3.9/concurrent/futures/thread.py", line 77, in _worker
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:     work_item.run()
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:   File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:     result = self.fn(*self.args, **self.kwargs)
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:   File "/var/lib/satnogs/lib/python3.9/site-packages/apscheduler/executors/base.py", line 125, in run_job
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:     retval = job.func(*job.args, **job.kwargs)
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:   File "/var/lib/satnogs/lib/python3.9/site-packages/satnogsclient/scheduler/tasks.py", line 176, in get_jobs
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:     gps_locator.update_location()
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:   File "/var/lib/satnogs/lib/python3.9/site-packages/satnogsclient/locator/locator.py", line 35, in update_location
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]:     LOGGER.info('Last coordinates %f %f %d', settings.SATNOGS_STATION_LAT,
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]: Message: 'Last coordinates %f %f %d'
Jan 18 21:18:49 raspi-sat2 satnogs-client[389]: Arguments: (63.837188333, 20.173745, nan)
1 Like

I have started a issue here to track the problems I’m seeing.

2 Likes