こんにちは
お盆も終わりましたね。でも朝方気温が下がって冷房のない2階の私の部屋でもようやく寝ることができるようになりました。昔からお盆までとはよくいったものです。
さて今回は、トラ技 2019.2で紹介されていたTouchRTKStationのプログラムについてです。
すでに紹介しているように「[blog-日々のこと] Raspberry Piでrtklib_2.4.3をqmakeする」でオリジナルのTouchRTKStation.pyにPowerOFFとrtkplot_qtを追加しました。
pythonのプログラムもまともに書いたことがないので、どこに追加したらよいのかよくわかりませんでしたが、なんとかなった というのが本音です。 まだ一部のデータは固定のままですしね。このへんはこれから時間が出来たら修正したいと思っています。
プログラムのパッチ
最近Gitを少しだけ触ることに。 これを使ってpatchを作ってみました。
実はwindows用のgitに関係するアプリは沢山あるようで、私はSouceTreeとWinMergeを使い始めました。
以下のパッチはSourceTreeを使って得られたものです。
base_lat, basepos_latとbase_lon, basepos_lonの値が当て字になっているのでこのままでは使えません。正確な値をいれてください。 というか本来ならば送られてきたデータを入れるべきですが、今はまだ対応していません。
patch.diff
From fe53dda715ff8537930a43a9b380eacb0da2fc11 Mon Sep 17 00:00:00 2001 From: kk <chappy@chappy.net> Date: Sun, 18 Aug 2019 08:25:53 +0900 Subject: [PATCH] add PowerOFF and rtkplot_qt --- TouchRTKStation.py | 141 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 120 insertions(+), 21 deletions(-) diff --git a/TouchRTKStation.py b/TouchRTKStation.py index c0a80d6..d5aaeb6 100644 --- a/TouchRTKStation.py +++ b/TouchRTKStation.py @@ -2,14 +2,15 @@ """ @author: Yusuke Takahashi, Taro Suzuki, Waseda University """ -import sys,os,shlex,glob,time,re -from subprocess import Popen,PIPE,check_output +import sys,os,shlex,glob,time,re,signal +import subprocess +from subprocess import Popen,PIPE,check_output,check_call from PyQt5.QtWidgets import (QWidget, QPushButton,QHBoxLayout, QVBoxLayout,QCheckBox,QGroupBox,QScrollArea, QApplication,QSizePolicy,QMainWindow,QMessageBox,QDialog,QTabWidget,QComboBox,QLabel,QLineEdit,QFormLayout,QGridLayout) from PyQt5.QtGui import QFont,QColor,QPixmap from PyQt5 import QtCore import telnetlib - +import pymap3d as pm # Main Window class MainWindow(QMainWindow): @@ -26,13 +27,12 @@ class MainWindow(QMainWindow): # ublox command file for Base/Rover mode ubxcmd = dirtrs+'/conf/ubx_m8t_bds_raw_1hz.cmd' - # Default Base position configuration basepos_type = (['LLH','RTCM']) # for Rover basepos_itype = 1 # for Rover - basepos_lat = '35.0' - basepos_lon = '139.0' - basepos_hgt = '50.0' + basepos_lat = '36.xx' + basepos_lon = '139.xx' + basepos_hgt = '85.32205' # Default Input stream configration input_iport= 2 # ttyACM0 @@ -49,25 +49,25 @@ class MainWindow(QMainWindow): corr_format = (['RTCM2','RTCM3','BINEX','UBX']) corr_iformat = 1 corr_user = 'user' - corr_addr = 'test.net' - corr_port = '2101' + corr_addr = '192.168.100.11' + corr_port = '52001' corr_pw = 'password' corr_mp = 'RTCM' # Default Correction(Serial) stream configration - corr2_flag = False + corr2_flag = True corr2_format = (['RTCM2','RTCM3','BINEX','UBX']) - corr2_iformat = 3 + corr2_iformat = 1 corr2_iport= 4 # ttyUSB0 - corr2_ibitrate = 9 # 115200 bps + corr2_ibitrate = 6 # 115200 bps corr2_ibytesize = 1 # 8 bit corr2_iparity = 0 # None corr2_istopbits = 0 # 1 bit corr2_iflowcontrol = 0 # None # Default Log/Solution stream configration - log_flag = True - sol_flag = True + log_flag = False + sol_flag = False dir = glob.glob('/media/*/*/') # Find USB memory if len(dir)==0: dir = [dirtrs+'/'] @@ -111,15 +111,15 @@ class MainWindow(QMainWindow): self.setCentralWidget(self.main_w) self.setWindowFlags(QtCore.Qt.FramelessWindowHint) - # self.setGeometry(100, 100, 480, 320) # For debug - self.showFullScreen() + self.setGeometry(0, 0, 480, 280) # For debug + #self.showFullScreen() self.show() # Dispaly status in rover mode def updateRover(self): rawsol=self.main_w.rtkrcvCommand(self.main_w.tn,'solution') - print(rawsol) + #print(rawsol) if len(rawsol)>34: soltypes=re.findall(r'\(.*\)',rawsol) soltype=soltypes[0][1:-1].strip() @@ -135,10 +135,40 @@ class MainWindow(QMainWindow): self.main_w.lLat.setText(sols[1]) self.main_w.lLon.setText(sols[2]) self.main_w.lAlt.setText(sols[3]) + resolt = re.findall(r'\d*\.\d*', rawsol) + #print(rawsol) + #print(resolt[1]) + + base_lat = float(36.xx) + base_lon = float(139.xx) + base_hgt = float(85.32205) + lat_resolt=float(resolt[1]) + lon_resolt=float(resolt[2]) + alt_resolt=float(resolt[3]) + + #x,y,z =pm.geodetic2ecef(lat_resolt, lon_resolt, alt_resolt) + #print("%d [m], %d [m], %d [m]" % (x, y, z)) + #print("la=%.8f, lo=%.8f, hgt=%.3f " % (base_lat, base_lon, base_hgt)) + #az,el,range = pm.geodetic2aer(base_lat, base_lon, base_hgt, lat_resolt, lon_resolt, alt_resolt) + az,el,range = pm.geodetic2aer(lat_resolt, lon_resolt, alt_resolt, base_lat, base_lon, base_hgt) + #print("p= %.3f [deg], y= %.3f [deg], d= %.3f [m]" % (az, el, range)) + az1 = round(az, 2) + el1 = round(el, 2) + range1 = round(range, 3) + az2 = str("{:.2f}".format(az1)) + el2 = str("{:.2f}".format(el1)) + range2 = str("{:.3f}".format(range1)) + + #az1=str(az)[:6] + #el1=str(el)[:6] + #range1=str(range)[:6] + str1="" + str1=str1+" AZ= "+az2+" EL= "+el2+" Range= "+range2 + self.main_w.status_rov.setText(str1) rawstream=self.main_w.rtkrcvCommand(self.main_w.tn,'stream') rawstreams=rawstream.split('\n') - # print(rawstream) + #print(rawstream) statstr='' for stream in rawstreams: @@ -153,8 +183,8 @@ class MainWindow(QMainWindow): pass else: statstr=statstr+streams[0]+':'+streams[8]+'bps ' - self.main_w.status_rov.setText(statstr) - + #self.main_w.status_rov.setText(statstr) + # Dispaly status in base mode def updateBase(self): rawstream = self.p.stderr.readline().decode('utf-8') @@ -189,18 +219,87 @@ class MainWidget(QWidget): self.tabRover=QWidget() self.tabBase=QWidget() + self.tabOther=QWidget() self.tabs.addTab(self.tabRover,'Rover') self.tabs.addTab(self.tabBase,'Base') + self.tabs.addTab(self.tabOther,'Other') self.tabRoverUI() self.tabBaseUI() + self.tabOtherUI() vbox=QVBoxLayout() vbox.addWidget(bannar) vbox.addWidget(self.tabs) self.setLayout(vbox) + def tabOtherUI(self): + # Start button + self.start_other = QPushButton('Power ON',self) + self.start_other.setCheckable(True) + self.start_other.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding) + self.start_other.toggled.connect(self.StartOtherToggled) + self.start_other.setFont(QFont('Helvetica',16)) + # Other button + self.other_other = QPushButton('rtkplot_qt run',self) + self.other_other.setCheckable(True) + self.other_other.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding) + self.other_other.toggled.connect(self.OtherOtherToggled) + self.other_other.setFont(QFont('Helvetica',16)) + # Layout + hbox1 = QHBoxLayout() + hbox2 = QHBoxLayout() + vbox = QVBoxLayout() + # hbox1 + hbox1.addSpacing(10) + #hbox1.addWidget(icon) + hbox1.addSpacing(10) + hbox1.addWidget(self.start_other) + hbox1.addWidget(self.other_other) + # Add to layout + vbox.addLayout(hbox1,1) + vbox.addLayout(hbox2) + # Show layout + self.tabOther.setLayout(vbox) + + # Power OFF button + def StartOtherToggled(self,checked): + if checked: + self.start_other.setText('Power ON') + self.tabs.setTabEnabled(0, True) + print("ON") + else: + self.start_other.setText('Power OFF') + self.tabs.setTabEnabled(0, False) + print("off") + subprocess.run(['/sbin/shutdown','-h','1']) + + # rtkplot_qt start button + def OtherOtherToggled(self,checked): + if checked: + self.other_other.setText('rtkplot_qt run') + self.tabs.setTabEnabled(1, True) + self.other_other.setText('rtkplot_qt stop') + print("run") + cmd2 = ('/home/pi/bin/rtkplot_qt') + pro2 = subprocess.Popen(cmd2, stdout=subprocess.PIPE) + global pro2 + print("process id pro2= %s" %pro2.pid) + + else: + self.other_other.setText('rtkplot_qt stop') + self.tabs.setTabEnabled(1, False) + print("stop") + self.other_other.setText('rtkplot_qt run') + #cmd2 = ('/home/pi/bin/rtkplot_qt') + #pro3 = subprocess.Popen(cmd2, stdout=subprocess.PIPE) + + print("process id pro2 = %s" %pro2.pid) + #os.killpg(os.getpgid(pro3.pid), signal.SIGKILL) + os.kill(pro2.pid, signal.SIGKILL) + + # Rover tab def tabRoverUI(self): # Start button @@ -649,7 +748,7 @@ class RoverConfigWindow: self.w.setFont(QFont('Helvetica',11)) self.w.setWindowFlags(QtCore.Qt.FramelessWindowHint) - self.w.setGeometry(0, 0, 480, 320) + self.w.setGeometry(0, 0, 480, 270) self.parent = parent -- 2.22.0.windows.1
今使用中のTouchRTKStationではさらに修正をかけていて
patch-1.diff
From 5f5c3c42b9b53d2d11a8fe04de008f21539d8e02 Mon Sep 17 00:00:00 2001 From: kk <chappy@chappy.net> Date: Sun, 18 Aug 2019 10:45:51 +0900 Subject: [PATCH] TouchRTKStation-Real --- TouchRTKStation.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/TouchRTKStation.py b/TouchRTKStation.py index d5aaeb6..ebb41cf 100644 --- a/TouchRTKStation.py +++ b/TouchRTKStation.py @@ -49,7 +49,7 @@ class MainWindow(QMainWindow): corr_format = (['RTCM2','RTCM3','BINEX','UBX']) corr_iformat = 1 corr_user = 'user' - corr_addr = '192.168.100.11' + corr_addr = '192.168.100.13' corr_port = '52001' corr_pw = 'password' corr_mp = 'RTCM' @@ -111,7 +111,7 @@ class MainWindow(QMainWindow): self.setCentralWidget(self.main_w) self.setWindowFlags(QtCore.Qt.FramelessWindowHint) - self.setGeometry(0, 0, 480, 280) # For debug + self.setGeometry(0, 0, 460, 300) # For debug #self.showFullScreen() self.show() @@ -236,7 +236,7 @@ class MainWidget(QWidget): def tabOtherUI(self): # Start button - self.start_other = QPushButton('Power ON',self) + self.start_other = QPushButton('Power OFF',self) self.start_other.setCheckable(True) self.start_other.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding) self.start_other.toggled.connect(self.StartOtherToggled) @@ -266,31 +266,32 @@ class MainWidget(QWidget): # Power OFF button def StartOtherToggled(self,checked): if checked: - self.start_other.setText('Power ON') - self.tabs.setTabEnabled(0, True) - print("ON") - else: self.start_other.setText('Power OFF') - self.tabs.setTabEnabled(0, False) - print("off") - subprocess.run(['/sbin/shutdown','-h','1']) + self.tabs.setTabEnabled(0, True) + #print("ON") + subprocess.run('/sbin/poweroff') + #else: + #self.start_other.setText('Power OFF') + #self.tabs.setTabEnabled(0, False) + #print("off") + #subprocess.run('/sbin/poweroff') # rtkplot_qt start button def OtherOtherToggled(self,checked): + global pro2 if checked: self.other_other.setText('rtkplot_qt run') self.tabs.setTabEnabled(1, True) self.other_other.setText('rtkplot_qt stop') - print("run") + #print("run") cmd2 = ('/home/pi/bin/rtkplot_qt') pro2 = subprocess.Popen(cmd2, stdout=subprocess.PIPE) - global pro2 print("process id pro2= %s" %pro2.pid) else: self.other_other.setText('rtkplot_qt stop') self.tabs.setTabEnabled(1, False) - print("stop") + #print("stop") self.other_other.setText('rtkplot_qt run') #cmd2 = ('/home/pi/bin/rtkplot_qt') #pro3 = subprocess.Popen(cmd2, stdout=subprocess.PIPE) -- 2.22.0.windows.1
となっています。
TouchRTKStation.pyのプログラムはトラ技で紹介されているgithub.comにあります。
コメント