RemoteLaunch.py
Go to the documentation of this file.
00001 import rospkg
00002 
00003 __author__ = 'tom1231'
00004 from PyQt4.QtGui import *
00005 from GUI.Schemes.RemoteLaunch import Ui_Dialog
00006 from os.path import basename
00007 import os
00008 import shlex
00009 import subprocess
00010 
00011 class RemoteLaunch(QDialog, Ui_Dialog):
00012     def __init__(self, parent=None):
00013         super(RemoteLaunch, self).__init__(parent)
00014         self.setupUi(self)
00015         self._file = ''
00016 
00017         self.launchButton.clicked.connect(self.launchRemote)
00018         self.browse.clicked.connect(self.browseLaunch)
00019         self.TestButton.clicked.connect(self.ping)
00020         self.newTerm.clicked.connect(self.newTermLaunch)
00021 
00022         self.isLaunch = False
00023 
00024     def launchRemote(self):
00025         if self._file is None or self._file == '' or str(self.hostIpAdd.text()) == '' or str(self.hostUser.text()) == '' or str(self.hostPassword.text()) == '' or str(self.localIP.text()) == '' or str(self._file) == '':
00026             QMessageBox.critical(self, "Error", "Please fill all the fields to launch a from remote.")
00027             return
00028         subprocess.Popen(shlex.split('gnome-terminal -e "rosrun ric_base_station remote_robot.sh %s %s %s %s %s"' % (str(self.hostIpAdd.text()),str(self.localIP.text()), str(self.hostUser.text()), str(self.hostPassword.text()), str(self._file))))
00029         print "rosrun ric_base_station remote_robot.sh %s %s %s %s %s" % (str(self.hostIpAdd.text()),str(self.localIP.text()), str(self.hostUser.text()), str(self.hostPassword.text()), str(self._file))
00030         self.isLaunch = True
00031 
00032     def newTermLaunch(self):
00033         if not self.isLaunch:
00034             QMessageBox.critical(self, "Error", "Please start the launch first.")
00035             return
00036 
00037         pkg = rospkg.RosPack().get_path('ric_board')
00038         subprocess.Popen(shlex.split('gnome-terminal -e "%s/scripts/envGui.sh %s %s"' % (pkg, str(self.hostIpAdd.text()), str(self.localIP.text()))))
00039 
00040     def browseLaunch(self):
00041         self._file = basename(str(QFileDialog.getOpenFileName(self, self.tr("Choose remote launch"), '.', self.tr("Launch file (*.launch)"))))
00042         if self._file is None or self._file == '': return
00043         self.path.setText(self._file)
00044 
00045     def ping(self):
00046         if str(self.hostIpAdd.text()) == '':
00047             QMessageBox.critical(self, "Error", "Please fill robot ip first.")
00048             return
00049         code = os.system('ping -c 1 %s' % (self.hostIpAdd.text()))
00050         if code > 0:
00051             QMessageBox.information(self, "Ping info", "Robot is unreachable")
00052             return
00053         QMessageBox.information(self, "Ping info", "Robot is reachable")
00054 
00055 


ric_board
Author(s): RoboTiCan
autogenerated on Fri Oct 27 2017 03:02:30