gps_tool is now in public github as qtGPS
This commit is contained in:
@ -1,202 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
################################################################################
|
||||
## Form generated from reading UI file 'mainwindow.ui'
|
||||
##
|
||||
## Created by: Qt User Interface Compiler version 6.5.2
|
||||
##
|
||||
## WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||
################################################################################
|
||||
|
||||
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
|
||||
QMetaObject, QObject, QPoint, QRect,
|
||||
QSize, QTime, QUrl, Qt)
|
||||
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
|
||||
QFont, QFontDatabase, QGradient, QIcon,
|
||||
QImage, QKeySequence, QLinearGradient, QPainter,
|
||||
QPalette, QPixmap, QRadialGradient, QTransform)
|
||||
from PySide6.QtWidgets import (QApplication, QFrame, QGraphicsView, QLabel,
|
||||
QMainWindow, QMenuBar, QPushButton, QSizePolicy,
|
||||
QStatusBar, QTextEdit, QWidget)
|
||||
|
||||
class Ui_MainWindow(object):
|
||||
def setupUi(self, MainWindow):
|
||||
if not MainWindow.objectName():
|
||||
MainWindow.setObjectName(u"MainWindow")
|
||||
MainWindow.resize(737, 359)
|
||||
self.centralwidget = QWidget(MainWindow)
|
||||
self.centralwidget.setObjectName(u"centralwidget")
|
||||
self.label_2 = QLabel(self.centralwidget)
|
||||
self.label_2.setObjectName(u"label_2")
|
||||
self.label_2.setGeometry(QRect(10, 100, 61, 16))
|
||||
self.label = QLabel(self.centralwidget)
|
||||
self.label.setObjectName(u"label")
|
||||
self.label.setGeometry(QRect(10, 80, 61, 16))
|
||||
self.label_3 = QLabel(self.centralwidget)
|
||||
self.label_3.setObjectName(u"label_3")
|
||||
self.label_3.setGeometry(QRect(10, 160, 51, 16))
|
||||
self.txtLongitude = QLabel(self.centralwidget)
|
||||
self.txtLongitude.setObjectName(u"txtLongitude")
|
||||
self.txtLongitude.setGeometry(QRect(70, 100, 81, 18))
|
||||
self.txtLongitude.setFrameShape(QFrame.Panel)
|
||||
self.txtLongitude.setFrameShadow(QFrame.Sunken)
|
||||
self.txtSpeed = QLabel(self.centralwidget)
|
||||
self.txtSpeed.setObjectName(u"txtSpeed")
|
||||
self.txtSpeed.setGeometry(QRect(70, 160, 61, 18))
|
||||
self.txtSpeed.setFrameShape(QFrame.Panel)
|
||||
self.txtSpeed.setFrameShadow(QFrame.Sunken)
|
||||
self.txtLatitude = QLabel(self.centralwidget)
|
||||
self.txtLatitude.setObjectName(u"txtLatitude")
|
||||
self.txtLatitude.setGeometry(QRect(70, 80, 81, 18))
|
||||
self.txtLatitude.setFrameShape(QFrame.Panel)
|
||||
self.txtLatitude.setFrameShadow(QFrame.Sunken)
|
||||
self.label_4 = QLabel(self.centralwidget)
|
||||
self.label_4.setObjectName(u"label_4")
|
||||
self.label_4.setGeometry(QRect(10, 140, 61, 16))
|
||||
self.exitButton = QPushButton(self.centralwidget)
|
||||
self.exitButton.setObjectName(u"exitButton")
|
||||
self.exitButton.setGeometry(QRect(640, 300, 84, 32))
|
||||
self.txtHeading = QLabel(self.centralwidget)
|
||||
self.txtHeading.setObjectName(u"txtHeading")
|
||||
self.txtHeading.setGeometry(QRect(70, 140, 61, 18))
|
||||
self.txtHeading.setFrameShape(QFrame.Panel)
|
||||
self.txtHeading.setFrameShadow(QFrame.Sunken)
|
||||
self.txtTime = QLabel(self.centralwidget)
|
||||
self.txtTime.setObjectName(u"txtTime")
|
||||
self.txtTime.setGeometry(QRect(70, 60, 151, 20))
|
||||
self.txtTime.setFrameShape(QFrame.Panel)
|
||||
self.txtTime.setFrameShadow(QFrame.Sunken)
|
||||
self.label_7 = QLabel(self.centralwidget)
|
||||
self.label_7.setObjectName(u"label_7")
|
||||
self.label_7.setGeometry(QRect(10, 60, 51, 16))
|
||||
self.label_5 = QLabel(self.centralwidget)
|
||||
self.label_5.setObjectName(u"label_5")
|
||||
self.label_5.setGeometry(QRect(10, 120, 61, 16))
|
||||
self.label_8 = QLabel(self.centralwidget)
|
||||
self.label_8.setObjectName(u"label_8")
|
||||
self.label_8.setGeometry(QRect(10, 40, 51, 16))
|
||||
self.txtStatus = QLabel(self.centralwidget)
|
||||
self.txtStatus.setObjectName(u"txtStatus")
|
||||
self.txtStatus.setGeometry(QRect(70, 40, 61, 16))
|
||||
self.txtStatus.setFrameShape(QFrame.Panel)
|
||||
self.txtStatus.setFrameShadow(QFrame.Sunken)
|
||||
self.label_10 = QLabel(self.centralwidget)
|
||||
self.label_10.setObjectName(u"label_10")
|
||||
self.label_10.setGeometry(QRect(10, 180, 49, 20))
|
||||
self.label_11 = QLabel(self.centralwidget)
|
||||
self.label_11.setObjectName(u"label_11")
|
||||
self.label_11.setGeometry(QRect(10, 200, 49, 16))
|
||||
self.txtHDOP = QLabel(self.centralwidget)
|
||||
self.txtHDOP.setObjectName(u"txtHDOP")
|
||||
self.txtHDOP.setGeometry(QRect(70, 180, 61, 16))
|
||||
self.txtHDOP.setFrameShape(QFrame.Panel)
|
||||
self.txtHDOP.setFrameShadow(QFrame.Sunken)
|
||||
self.txtVDOP = QLabel(self.centralwidget)
|
||||
self.txtVDOP.setObjectName(u"txtVDOP")
|
||||
self.txtVDOP.setGeometry(QRect(70, 200, 61, 16))
|
||||
self.txtVDOP.setFrameShape(QFrame.Panel)
|
||||
self.txtVDOP.setFrameShadow(QFrame.Sunken)
|
||||
self.txtAltitude = QLabel(self.centralwidget)
|
||||
self.txtAltitude.setObjectName(u"txtAltitude")
|
||||
self.txtAltitude.setGeometry(QRect(70, 120, 61, 16))
|
||||
self.txtAltitude.setFrameShape(QFrame.Panel)
|
||||
self.txtAltitude.setFrameShadow(QFrame.Sunken)
|
||||
self.label_9 = QLabel(self.centralwidget)
|
||||
self.label_9.setObjectName(u"label_9")
|
||||
self.label_9.setGeometry(QRect(130, 120, 81, 16))
|
||||
self.label_13 = QLabel(self.centralwidget)
|
||||
self.label_13.setObjectName(u"label_13")
|
||||
self.label_13.setGeometry(QRect(130, 160, 49, 16))
|
||||
self.txtMode = QLabel(self.centralwidget)
|
||||
self.txtMode.setObjectName(u"txtMode")
|
||||
self.txtMode.setGeometry(QRect(130, 40, 49, 16))
|
||||
self.txtMode.setFrameShape(QFrame.Panel)
|
||||
self.txtMode.setFrameShadow(QFrame.Sunken)
|
||||
self.label_6 = QLabel(self.centralwidget)
|
||||
self.label_6.setObjectName(u"label_6")
|
||||
self.label_6.setGeometry(QRect(10, 220, 49, 16))
|
||||
self.txtGrid = QLabel(self.centralwidget)
|
||||
self.txtGrid.setObjectName(u"txtGrid")
|
||||
self.txtGrid.setGeometry(QRect(70, 220, 61, 16))
|
||||
self.txtGrid.setFrameShape(QFrame.Panel)
|
||||
self.txtGrid.setFrameShadow(QFrame.Sunken)
|
||||
self.txtSatellites = QTextEdit(self.centralwidget)
|
||||
self.txtSatellites.setObjectName(u"txtSatellites")
|
||||
self.txtSatellites.setGeometry(QRect(230, 10, 220, 280))
|
||||
font = QFont()
|
||||
font.setFamilies([u"Courier"])
|
||||
self.txtSatellites.setFont(font)
|
||||
self.toggleLogging = QPushButton(self.centralwidget)
|
||||
self.toggleLogging.setObjectName(u"toggleLogging")
|
||||
self.toggleLogging.setGeometry(QRect(130, 250, 84, 32))
|
||||
self.label_12 = QLabel(self.centralwidget)
|
||||
self.label_12.setObjectName(u"label_12")
|
||||
self.label_12.setGeometry(QRect(10, 250, 111, 20))
|
||||
self.viewSatellites = QGraphicsView(self.centralwidget)
|
||||
self.viewSatellites.setObjectName(u"viewSatellites")
|
||||
self.viewSatellites.setGeometry(QRect(450, 10, 280, 280))
|
||||
brush = QBrush(QColor(0, 0, 0, 255))
|
||||
brush.setStyle(Qt.NoBrush)
|
||||
self.viewSatellites.setBackgroundBrush(brush)
|
||||
brush1 = QBrush(QColor(255, 255, 255, 255))
|
||||
brush1.setStyle(Qt.NoBrush)
|
||||
self.viewSatellites.setForegroundBrush(brush1)
|
||||
self.label_14 = QLabel(self.centralwidget)
|
||||
self.label_14.setObjectName(u"label_14")
|
||||
self.label_14.setGeometry(QRect(10, 10, 221, 16))
|
||||
font1 = QFont()
|
||||
font1.setPointSize(10)
|
||||
font1.setBold(True)
|
||||
self.label_14.setFont(font1)
|
||||
self.txtCount = QLabel(self.centralwidget)
|
||||
self.txtCount.setObjectName(u"txtCount")
|
||||
self.txtCount.setGeometry(QRect(150, 10, 61, 16))
|
||||
self.txtCount.setFrameShape(QFrame.Panel)
|
||||
self.txtCount.setFrameShadow(QFrame.Sunken)
|
||||
self.txtCount.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)
|
||||
MainWindow.setCentralWidget(self.centralwidget)
|
||||
self.menubar = QMenuBar(MainWindow)
|
||||
self.menubar.setObjectName(u"menubar")
|
||||
self.menubar.setGeometry(QRect(0, 0, 737, 28))
|
||||
MainWindow.setMenuBar(self.menubar)
|
||||
self.statusbar = QStatusBar(MainWindow)
|
||||
self.statusbar.setObjectName(u"statusbar")
|
||||
MainWindow.setStatusBar(self.statusbar)
|
||||
|
||||
self.retranslateUi(MainWindow)
|
||||
|
||||
QMetaObject.connectSlotsByName(MainWindow)
|
||||
# setupUi
|
||||
|
||||
def retranslateUi(self, MainWindow):
|
||||
MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"QtGPS", None))
|
||||
self.label_2.setText(QCoreApplication.translate("MainWindow", u"Longitude:", None))
|
||||
self.label.setText(QCoreApplication.translate("MainWindow", u"Latitude:", None))
|
||||
self.label_3.setText(QCoreApplication.translate("MainWindow", u"Speed:", None))
|
||||
self.txtLongitude.setText(QCoreApplication.translate("MainWindow", u"0", None))
|
||||
self.txtSpeed.setText(QCoreApplication.translate("MainWindow", u"0", None))
|
||||
self.txtLatitude.setText(QCoreApplication.translate("MainWindow", u"0", None))
|
||||
self.label_4.setText(QCoreApplication.translate("MainWindow", u"Heading:", None))
|
||||
self.exitButton.setText(QCoreApplication.translate("MainWindow", u"Exit", None))
|
||||
self.txtHeading.setText(QCoreApplication.translate("MainWindow", u"0", None))
|
||||
self.txtTime.setText("")
|
||||
self.label_7.setText(QCoreApplication.translate("MainWindow", u"Time:", None))
|
||||
self.label_5.setText(QCoreApplication.translate("MainWindow", u"Altitude:", None))
|
||||
self.label_8.setText(QCoreApplication.translate("MainWindow", u"Fix:", None))
|
||||
self.txtStatus.setText(QCoreApplication.translate("MainWindow", u"0", None))
|
||||
self.label_10.setText(QCoreApplication.translate("MainWindow", u"HDOP:", None))
|
||||
self.label_11.setText(QCoreApplication.translate("MainWindow", u"VDOP:", None))
|
||||
self.txtHDOP.setText(QCoreApplication.translate("MainWindow", u"0", None))
|
||||
self.txtVDOP.setText(QCoreApplication.translate("MainWindow", u"0", None))
|
||||
self.txtAltitude.setText(QCoreApplication.translate("MainWindow", u"0", None))
|
||||
self.label_9.setText(QCoreApplication.translate("MainWindow", u"m (WGS84)", None))
|
||||
self.label_13.setText(QCoreApplication.translate("MainWindow", u"m/sec", None))
|
||||
self.txtMode.setText(QCoreApplication.translate("MainWindow", u"0", None))
|
||||
self.label_6.setText(QCoreApplication.translate("MainWindow", u"Grid:", None))
|
||||
self.txtGrid.setText("")
|
||||
self.toggleLogging.setText(QCoreApplication.translate("MainWindow", u"Start", None))
|
||||
self.label_12.setText(QCoreApplication.translate("MainWindow", u"GPX Data Logging:", None))
|
||||
self.label_14.setText(QCoreApplication.translate("MainWindow", u"GPS Tool (gpsd client)", None))
|
||||
self.txtCount.setText(QCoreApplication.translate("MainWindow", u"0", None))
|
||||
# retranslateUi
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
|
||||
MainWindow.py : mainwindow.ui
|
||||
pyside2-uic -o $@ $<
|
||||
@ -1,2 +0,0 @@
|
||||
# QtGPS
|
||||
Qt5 Version of xgps (from gpsd clients)
|
||||
@ -1,14 +0,0 @@
|
||||
|
||||
SETUP
|
||||
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install gps simpleaudio gpxpy pyyaml PySide6
|
||||
pip list > requirements.txt
|
||||
|
||||
RUN
|
||||
|
||||
source venv/bin/activate
|
||||
python gps_tool.py &
|
||||
deactivate
|
||||
@ -1,9 +0,0 @@
|
||||
|
||||
gps_tool TODO
|
||||
|
||||
Theta labels wind up inside track, not outside.
|
||||
Use N, NE, E, SE, S, SW, W, NW labels
|
||||
|
||||
Error running on Raspberry Pi (shiboken2 is broken shit)
|
||||
|
||||
Click on point for more info
|
||||
@ -1,14 +0,0 @@
|
||||
# Default settings for the gpsd init script and the hotplug wrapper.
|
||||
|
||||
# Start the gpsd daemon automatically at boot time
|
||||
START_DAEMON="true"
|
||||
|
||||
# Use USB hotplugging to add new USB devices automatically to the daemon
|
||||
USBAUTO="true"
|
||||
|
||||
# Devices gpsd should collect to at boot time.
|
||||
# They need to be read/writeable, either by user gpsd or the group dialout.
|
||||
DEVICES="/dev/ttyACM0"
|
||||
|
||||
# Other options you want to pass to gpsd
|
||||
GPSD_OPTIONS="-G"
|
||||
@ -1,15 +0,0 @@
|
||||
[Unit]
|
||||
Description=GPS (Global Positioning System) Daemon
|
||||
Requires=gpsd.socket
|
||||
# Needed with chrony SOCK refclock
|
||||
After=chronyd.service
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
EnvironmentFile=-/etc/default/gpsd
|
||||
ExecStart=/usr/sbin/gpsd $GPSD_OPTIONS $DEVICES
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Also=gpsd.socket
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
[Unit]
|
||||
Description=GPS (Global Positioning System) Daemon Sockets
|
||||
|
||||
[Socket]
|
||||
ListenStream=/var/run/gpsd.sock
|
||||
ListenStream=[::1]:2947
|
||||
ListenStream=0.0.0.0:2947
|
||||
SocketMode=0600
|
||||
|
||||
[Install]
|
||||
WantedBy=sockets.target
|
||||
@ -1,323 +0,0 @@
|
||||
#! /usr/bin/python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
import yaml
|
||||
|
||||
from math import radians
|
||||
from datetime import datetime
|
||||
from time import strftime, time
|
||||
from pprint import pprint
|
||||
|
||||
from gps import *
|
||||
import gpxpy
|
||||
|
||||
from PySide6.QtGui import *
|
||||
from PySide6.QtWidgets import QApplication, QMainWindow, QGraphicsEllipseItem, QFileDialog, QGraphicsScene, QGraphicsProxyWidget
|
||||
from PySide6.QtCore import QObject, Slot, Signal, QThread, QDir, QRect
|
||||
|
||||
import matplotlib as mp
|
||||
import matplotlib.pyplot as plot
|
||||
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
|
||||
from matplotlib.figure import Figure
|
||||
from matplotlib.backends.qt_compat import QtCore, QtWidgets
|
||||
from matplotlib import cm
|
||||
|
||||
from MainWindow import Ui_MainWindow
|
||||
|
||||
import maidenhead as mh
|
||||
|
||||
from utils.configs import *
|
||||
|
||||
##############################################################################
|
||||
# log
|
||||
##############################################################################
|
||||
|
||||
#if not os.path.isdir("logs"):
|
||||
# os.mkdir("logs")
|
||||
|
||||
fix_status = [
|
||||
'Normal', 'DGPS', 'RTK FixPt', 'RTK Float', 'DR Fix', 'GNSSDR', 'Surveyed', 'Simulated', 'P(Y) Fix'
|
||||
];
|
||||
|
||||
fix_mode = [
|
||||
'0=None', '1=No', '2=2D', '3=3D'
|
||||
];
|
||||
|
||||
gpsd_host="127.0.0.1"
|
||||
gpsd_report = ()
|
||||
|
||||
##############################################################################
|
||||
# thread
|
||||
##############################################################################
|
||||
|
||||
class DataSignal(QObject):
|
||||
sig = Signal(int)
|
||||
|
||||
class DataThread(QThread):
|
||||
def __init__(self, parent=None):
|
||||
super(DataThread, self).__init__(parent)
|
||||
self.new_data = DataSignal()
|
||||
|
||||
def run(self):
|
||||
global gpsd_host, gpsd_report
|
||||
gpsd = gps(host=gpsd_host, mode=WATCH_ENABLE|WATCH_NEWSTYLE)
|
||||
|
||||
while not self.isInterruptionRequested():
|
||||
gpsd_report = gpsd.next() # wait for next packet
|
||||
self.new_data.sig.emit(1)
|
||||
|
||||
def stop(self):
|
||||
self.requestInterruption()
|
||||
self.wait()
|
||||
|
||||
##############################################################################
|
||||
# plot
|
||||
##############################################################################
|
||||
|
||||
##############################################################################
|
||||
# main
|
||||
##############################################################################
|
||||
|
||||
class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
def __init__(self, *args, obj=None, **kwargs):
|
||||
super(MainWindow, self).__init__(*args, **kwargs)
|
||||
self.setupUi(self)
|
||||
|
||||
class QtGPSWindow(MainWindow):
|
||||
def __init__(self, *args, obj=None, **kwargs):
|
||||
super(QtGPSWindow, self).__init__(*args, **kwargs)
|
||||
|
||||
self.exitButton.clicked.connect(self.exit_button)
|
||||
self.toggleLogging.clicked.connect(self.toggle_logging)
|
||||
|
||||
# GPS log
|
||||
self.gpx = gpxpy.gpx.GPX()
|
||||
# Create first track in our GPX:
|
||||
self.gpx_track = gpxpy.gpx.GPXTrack()
|
||||
self.gpx.tracks.append(self.gpx_track)
|
||||
# Create first segment in our GPX track:
|
||||
self.gpx_segment = gpxpy.gpx.GPXTrackSegment()
|
||||
self.gpx_track.segments.append(self.gpx_segment)
|
||||
|
||||
self.log_enabled = 0
|
||||
self.dirname = "."
|
||||
self.num_count = 0
|
||||
self.num_points = 0
|
||||
|
||||
self.my_thread = DataThread()
|
||||
|
||||
self.txtSatellites.setReadOnly(True)
|
||||
self.black = QColor(0,0,0)
|
||||
self.gray = QColor(128,128,128)
|
||||
self.red = QColor(255,0,0)
|
||||
self.orange = QColor(255,80,0)
|
||||
self.yellow = QColor(255,211,0)
|
||||
self.green = QColor(0,255,0)
|
||||
self.blue = QColor(0,0,255)
|
||||
self.white = QColor(255,255,255)
|
||||
|
||||
self.scene = QtWidgets.QGraphicsScene()
|
||||
self.viewSatellites.setScene(self.scene)
|
||||
self.viewSatellites.scale(0.65, 0.65)
|
||||
|
||||
@Slot(list)
|
||||
def update_data(self, x):
|
||||
global gpsd_report
|
||||
report = gpsd_report
|
||||
|
||||
# make sure is good report
|
||||
try:
|
||||
if not 'class' in report:
|
||||
return
|
||||
except:
|
||||
return
|
||||
|
||||
# GPS messages
|
||||
if report['class'] == 'TPV':
|
||||
status = getattr(report, 'status', 0)
|
||||
mode = getattr(report, 'mode', 0)
|
||||
time = getattr(report, 'time', 0)
|
||||
lat = getattr(report, 'lat', 0.0)
|
||||
lon = getattr(report, 'lon', 0.0)
|
||||
elev = getattr(report, 'altHAE', 0.0) # meters
|
||||
heading = getattr(report, 'track', 0.0)
|
||||
speed = getattr(report, 'speed', 0.0) # m/sec
|
||||
|
||||
self.txtStatus.setText(fix_status[status])
|
||||
self.txtMode.setText(fix_mode[mode])
|
||||
self.txtTime.setText(time)
|
||||
self.txtLatitude.setText("%10.7f" %(lat))
|
||||
self.txtLongitude.setText("%10.7f" % (lon))
|
||||
self.txtAltitude.setText("%7.2f" % (elev))
|
||||
self.txtHeading.setText("%7.2f" % (heading))
|
||||
self.txtSpeed.setText("%7.2f" % (speed))
|
||||
|
||||
self.txtGrid.setText(mh.to_maiden(lat, lon))
|
||||
|
||||
if self.log_enabled:
|
||||
point = gpxpy.gpx.GPXTrackPoint(lat, lon, elevation=elev)
|
||||
point.time = datetime.now()
|
||||
self.gpx_segment.points.append(point)
|
||||
self.num_points += 1
|
||||
self.num_count += 1
|
||||
self.txtCount.setText(str(self.num_count))
|
||||
|
||||
elif report['class'] == 'SKY':
|
||||
self.txtHDOP.setText(str(getattr(report, 'hdop', 0.0)))
|
||||
self.txtVDOP.setText(str(getattr(report, 'vdop', 0.0)))
|
||||
|
||||
try:
|
||||
satellites = report['satellites']
|
||||
|
||||
txt = "%4s %4s %4s %3s %1s" % ('PRN', 'Azim', 'Elev', 'SNR', 'Used')
|
||||
self.txtSatellites.setStyleSheet("background-color: rgb(0, 0, 0)")
|
||||
self.txtSatellites.setTextColor(self.white)
|
||||
self.txtSatellites.setFontWeight(QFont.Bold)
|
||||
self.txtSatellites.setText(txt)
|
||||
|
||||
prns = []
|
||||
radius = []
|
||||
theta = []
|
||||
colors = []
|
||||
markers = []
|
||||
|
||||
for satellite in satellites:
|
||||
prn = int(satellite['PRN'])
|
||||
azim = int(satellite['az'])
|
||||
elev = int(satellite['el'])
|
||||
snr = int(satellite['ss'])
|
||||
used = int(satellite['used'])
|
||||
# health = satellite['health']
|
||||
|
||||
# don't show if not visible
|
||||
if azim >= 360 or elev < -10 or elev > 90:
|
||||
continue;
|
||||
|
||||
cname = '#000000'
|
||||
color = self.black
|
||||
if snr < 12:
|
||||
cname = '#808080'
|
||||
color = self.gray
|
||||
elif snr < 30:
|
||||
cname = '#ff0000'
|
||||
color = self.red
|
||||
elif snr < 36:
|
||||
cname = '#ffd300'
|
||||
color = self.yellow
|
||||
elif snr < 42:
|
||||
cname = '#00ff00'
|
||||
color = self.green
|
||||
else:
|
||||
cname = '#0000ff'
|
||||
color = self.blue
|
||||
|
||||
txt = "%4u %4u %4u %3u %1u" % (prn, azim, elev, snr, used)
|
||||
self.txtSatellites.setTextColor(color)
|
||||
if used:
|
||||
self.txtSatellites.setFontWeight(QFont.Bold)
|
||||
else:
|
||||
self.txtSatellites.setFontWeight(QFont.Normal)
|
||||
self.txtSatellites.append(txt)
|
||||
|
||||
prns.append(prn)
|
||||
theta.append(radians(float(azim)))
|
||||
radius.append(float(elev))
|
||||
colors.append(cname)
|
||||
if used:
|
||||
markers.append(ord('P'))
|
||||
else:
|
||||
markers.append(ord('+'))
|
||||
|
||||
area = 100
|
||||
figure = Figure()
|
||||
polar = figure.add_subplot(111, projection='polar')
|
||||
polar.scatter(theta, radius, c=colors, s=area, cmap=None, alpha=0.75)
|
||||
polar.set_rorigin(90.0)
|
||||
polar.set_xticklabels([])
|
||||
polar.set_yticklabels([])
|
||||
for i, prn in enumerate(prns):
|
||||
polar.annotate(str(prn), (theta[i], radius[i]))
|
||||
|
||||
polar.set_theta_direction(-1)
|
||||
polar.set_theta_zero_location('N', offset=0)
|
||||
|
||||
canvas = FigureCanvas(figure)
|
||||
self.scene.clear()
|
||||
self.scene.addWidget(canvas)
|
||||
h = float(self.scene.height()) / 2.0
|
||||
w = float(self.scene.width()) / 2.0
|
||||
self.viewSatellites.centerOn(w,h)
|
||||
self.viewSatellites.show()
|
||||
|
||||
except:
|
||||
pass
|
||||
|
||||
self.show()
|
||||
|
||||
def toggle_logging(self):
|
||||
if self.log_enabled:
|
||||
self.log_enabled = 0
|
||||
# self.dir_dialog()
|
||||
self.save_log()
|
||||
self.toggleLogging.setText("Start")
|
||||
else:
|
||||
self.log_enabled = 1
|
||||
self.toggleLogging.setText("Stop")
|
||||
|
||||
def dir_dialog(self):
|
||||
dirdialog = QFileDialog(self)
|
||||
dirdialog.setDirectory(QDir.currentPath())
|
||||
dirdialog.setDefaultSuffix("gpx")
|
||||
dirdialog.setFileMode(QFileDialog.Directory)
|
||||
dirdialog.setOption(QFileDialog.ShowDirsOnly, True)
|
||||
selected = dirdialog.exec()
|
||||
if selected:
|
||||
dirname = dirdialog.selectedFiles()[0]
|
||||
# self.outputDir.setText(dirname)
|
||||
self.dirname = dirname
|
||||
|
||||
def save_log(self):
|
||||
if self.num_points:
|
||||
self.num_points = 0
|
||||
log = open(strftime(self.dirname + "/track-%Y%m%d-%H%M.gpx"), 'w')
|
||||
log.write(self.gpx.to_xml())
|
||||
log.close()
|
||||
self.gpx_segment = gpxpy.gpx.GPXTrackSegment()
|
||||
|
||||
def start_thread(self):
|
||||
if not self.my_thread.isRunning():
|
||||
self.my_thread.new_data.sig.connect(self.update_data)
|
||||
self.my_thread.start()
|
||||
self.my_thread.setTerminationEnabled(True)
|
||||
|
||||
def stop_thread(self):
|
||||
self.my_thread.stop()
|
||||
self.my_thread.wait(3)
|
||||
self.save_log()
|
||||
|
||||
def closeEvent(self, event):
|
||||
self.stop_thread()
|
||||
event.accept()
|
||||
sys.exit(0)
|
||||
|
||||
def exit_button(self):
|
||||
self.stop_thread()
|
||||
if self.log_enabled:
|
||||
self.toggle_logging()
|
||||
self.log_enabled = 0
|
||||
sys.exit(0)
|
||||
|
||||
cfg = ConfigurationFile(__file__)
|
||||
config = cfg.read_config()
|
||||
if 'gpsd_host' in config:
|
||||
gpsd_host = config['gpsd_host']
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
window = QtGPSWindow()
|
||||
window.show()
|
||||
window.start_thread()
|
||||
ret = app.exec()
|
||||
sys.exit(ret)
|
||||
@ -1 +0,0 @@
|
||||
gpsd_host: pi-flight
|
||||
@ -1,12 +0,0 @@
|
||||
[Unit]
|
||||
Description=x11vnc service
|
||||
After=display-manager.service network.target syslog.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/x11vnc -forever -display :0 -auth guess -passwd car-ntcna
|
||||
ExecStop=/usr/bin/killall x11vnc
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@ -1,521 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>737</width>
|
||||
<height>359</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>QtGPS</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>100</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Longitude:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>80</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Latitude:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>160</y>
|
||||
<width>51</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Speed:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="txtLongitude">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>100</y>
|
||||
<width>81</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="txtSpeed">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>160</y>
|
||||
<width>61</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="txtLatitude">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>80</y>
|
||||
<width>81</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>140</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Heading:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="exitButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>640</x>
|
||||
<y>300</y>
|
||||
<width>84</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Exit</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="txtHeading">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>140</y>
|
||||
<width>61</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="txtTime">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>60</y>
|
||||
<width>151</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>60</y>
|
||||
<width>51</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Time:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>120</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Altitude:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>51</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Fix:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="txtStatus">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>40</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>180</y>
|
||||
<width>49</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>HDOP:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>200</y>
|
||||
<width>49</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>VDOP:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="txtHDOP">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>180</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="txtVDOP">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>200</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="txtAltitude">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>120</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>120</y>
|
||||
<width>81</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>m (WGS84)</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>160</y>
|
||||
<width>49</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>m/sec</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="txtMode">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>40</y>
|
||||
<width>49</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>220</y>
|
||||
<width>49</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Grid:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="txtGrid">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>220</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextEdit" name="txtSatellites">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>230</x>
|
||||
<y>10</y>
|
||||
<width>220</width>
|
||||
<height>280</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Courier</family>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="toggleLogging">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>250</y>
|
||||
<width>84</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>250</y>
|
||||
<width>111</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>GPX Data Logging:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGraphicsView" name="viewSatellites">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>450</x>
|
||||
<y>10</y>
|
||||
<width>280</width>
|
||||
<height>280</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="backgroundBrush">
|
||||
<brush brushstyle="NoBrush">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</property>
|
||||
<property name="foregroundBrush">
|
||||
<brush brushstyle="NoBrush">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>221</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>GPS Tool (gpsd client)</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="txtCount">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<y>10</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>737</width>
|
||||
<height>28</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@ -1,25 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Python 3
|
||||
echo "Python 3 Software:"
|
||||
sudo apt-get -y --ignore-missing install python3-all python3-dev python3-tk idle3 python3-pip python3-pyqt5 python3-serial python3-can python3-protobuf python3-numpy python3-pil.imagetk python3-gi
|
||||
sudo apt-get -y --ignore-missing install spyder3 python3-pyside2.*
|
||||
sudo apt-get -y --ignore-missing install gpsd gpsd-clients gpsbabel libgps-dev
|
||||
|
||||
# Python addons
|
||||
echo "Python 3 Packages:"
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install --upgrade pyserial matplotlib numpy scipy gps gpxpy maidenhead virtualenv virtualenvwrapper
|
||||
|
||||
# enable and start gpsd service
|
||||
sudo systemctl enable gpsd.service
|
||||
|
||||
# gpsd startup
|
||||
sudo cp -r etc/* /etc/
|
||||
sudo cp -r lib/* /lib/
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
# enable and start gpsd service
|
||||
sudo systemctl start gpsd.service
|
||||
sudo systemctl enable x11vnc.service
|
||||
sudo systemctl start x11vnc.service
|
||||
Reference in New Issue
Block a user