def _post_goal(self): """Post new waypoint to subsystem""" print('Posting new goal to agent') self.tableWidget.setItem(self.table_row_tracker, 0, QtWidgets.QTableWidgetItem(str(datetime.datetime.fromtimestamp(rospy.get_time())))) self.tableWidget.setItem(self.table_row_tracker, 1, QtWidgets.QTableWidgetItem('N/A')) self.tableWidget.setItem(self.table_row_tracker, 2, QtWidgets.QTableWidgetItem('Move to new waypoint')) self.tableWidget.setItem(self.table_row_tracker, 3, QtWidgets.QTableWidgetItem('Sent')) self.tableWidget.setItem(self.table_row_tracker, 4, QtWidgets.QTableWidgetItem('N/A')) self.tableWidget.setItem(self.table_row_tracker, 5, QtWidgets.QTableWidgetItem('N/A')) self.tableWidget.setItem(self.table_row_tracker, 6, QtWidgets.QTableWidgetItem('N/A')) self.runningTaskLabel.setText('Move to new waypoint') self.table_row_tracker += 1 command = 'python post_goal.py %s' % self.num_goal_reached subprocess.call(command, shell=True)
def result_callback(self, data): """Goal reached callback""" if data.data: self.runningTaskProgressBar.setValue(self.num_goal_reached) self.num_goal_reached += 1 print(self.num_goal_reached) print("Goal Reached, ready for new one") self.tableWidget.setItem(self.table_row_tracker, 0, QtWidgets.QTableWidgetItem(str(datetime.datetime.fromtimestamp(rospy.get_time())))) self.tableWidget.setItem(self.table_row_tracker, 1, QtWidgets.QTableWidgetItem('N/A')) self.tableWidget.setItem(self.table_row_tracker, 2, QtWidgets.QTableWidgetItem('Reached waypoint')) self.tableWidget.setItem(self.table_row_tracker, 3, QtWidgets.QTableWidgetItem('Success')) self.tableWidget.setItem(self.table_row_tracker, 4, QtWidgets.QTableWidgetItem('N/A')) self.tableWidget.setItem(self.table_row_tracker, 5, QtWidgets.QTableWidgetItem('N/A')) self.tableWidget.setItem(self.table_row_tracker, 6, QtWidgets.QTableWidgetItem('N/A')) self.runningTaskLabel.setText('Reached waypoint') self.table_row_tracker += 1
def api_callback(self, data): """API callback from cloud""" print("Robot in position") self.tableWidget.setItem(self.table_row_tracker, 0, QtWidgets.QTableWidgetItem(str(datetime.datetime.fromtimestamp(rospy.get_time())))) self.tableWidget.setItem(self.table_row_tracker, 1, QtWidgets.QTableWidgetItem('N/A')) self.tableWidget.setItem(self.table_row_tracker, 2, QtWidgets.QTableWidgetItem('Move to new waypoint')) self.tableWidget.setItem(self.table_row_tracker, 3, QtWidgets.QTableWidgetItem('Sent')) self.tableWidget.setItem(self.table_row_tracker, 4, QtWidgets.QTableWidgetItem('N/A')) self.tableWidget.setItem(self.table_row_tracker, 5, QtWidgets.QTableWidgetItem('N/A')) self.tableWidget.setItem(self.table_row_tracker, 6, QtWidgets.QTableWidgetItem('N/A')) self.runningTaskLabel.setText('Move to new waypoint') self.table_row_tracker += 1 command = 'python post_goal.py %s' % self.num_goal_reached _id = rospy.get_caller_id() _class = self.plan[self.num_goal_reached-1] print(_class) if len(_class) > 3: self.tableWidget.setItem(self.table_row_tracker, 0, QtWidgets.QTableWidgetItem(str(datetime.datetime.fromtimestamp(rospy.get_time())))) self.tableWidget.setItem(self.table_row_tracker, 1, QtWidgets.QTableWidgetItem('N/A')) self.tableWidget.setItem(self.table_row_tracker, 2, QtWidgets.QTableWidgetItem('Move head to position')) self.tableWidget.setItem(self.table_row_tracker, 3, QtWidgets.QTableWidgetItem('Ongoing')) self.tableWidget.setItem(self.table_row_tracker, 4, QtWidgets.QTableWidgetItem('N/A')) self.tableWidget.setItem(self.table_row_tracker, 5, QtWidgets.QTableWidgetItem('N/A')) self.tableWidget.setItem(self.table_row_tracker, 6, QtWidgets.QTableWidgetItem('N/A')) self.runningTaskLabel.setText('Move head to position') self.table_row_tracker += 1 time.sleep(10) self.tableWidget.setItem(self.table_row_tracker-1, 3, QtWidgets.QTableWidgetItem('Complete')) self.post_goal() print("New goal sent, waiting for database to update") time.sleep(8) URL = 'http://dr0nn1.ddns.net:5000/%s/1' % _class response = requests.get(URL) content = response.json() tag = 'N/A' value = 'N/A' warning = 'N/A' alarm = 'N/A' value = 'N/A' if _class == 'manometers': value = float(content['value']) warning_low = float(content['low_warning_limit']) warning_high = float(content['high_warning_limit']) alarm_low = float(content['low_alarm_limit']) alarm_high = float(content['high_alarm_limit']) if value > warning_high and value < alarm_high: warning = 'Warning high' elif value < warning_low and value > alarm_low: warning = 'Warning low' elif value > alarm_high: alarm = 'Alarm high' elif value < alarm_low: alarm = 'Alarm low' tag = content['tag'] if _class == 'valve': normal_condition = content['normal_condition'] should_be = content['is_open'] tag = content['tag'] if value is not should_be: warning = 'Not in position' IMG = content['img'].encode('latin1') rgb_image = np.fromstring(IMG, dtype=np.uint8).reshape((480, 640, 3)) height, width, channel = rgb_image.shape bytesPerLine = 3 * width qImg = QtGui.QImage(rgb_image.data, width, height, bytesPerLine, QtGui.QImage.Format_RGB888) self.column_images[self.column_image_counter].setPixmap(QtGui.QPixmap(qImg)) self.tableWidget.setItem(self.table_row_tracker, 0, QtWidgets.QTableWidgetItem(str(datetime.datetime.fromtimestamp(rospy.get_time())))) self.tableWidget.setItem(self.table_row_tracker, 1, QtWidgets.QTableWidgetItem(tag)) self.tableWidget.setItem(self.table_row_tracker, 2, QtWidgets.QTableWidgetItem('Inspecting equipment')) self.tableWidget.setItem(self.table_row_tracker, 3, QtWidgets.QTableWidgetItem('Complete')) self.tableWidget.setItem(self.table_row_tracker, 4, QtWidgets.QTableWidgetItem(value)) self.tableWidget.setItem(self.table_row_tracker, 5, QtWidgets.QTableWidgetItem(warning)) self.tableWidget.setItem(self.table_row_tracker, 6, QtWidgets.QTableWidgetItem(alarm)) self.runningTaskLabel.setText('Inspecting equipment') self.table_row_tracker += 1 self.column_image_counter += 1 if self.column_image_counter > 2: self.column_image_counter = 0 else: time.sleep(2) self.post_goal()
def start_mission(self): """Start selected mission""" choice = QtWidgets.QMessageBox.question(self, 'Warning', 'Start new mission?', QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) if choice == QtWidgets.QMessageBox.Yes: self.load_mission() self.startMissionBtn.setDisabled(True) self.refreshSelectMissionAreaBtn.setDisabled(True) self.refreshSelectMissionBtn.setDisabled(True) self.selectMissionAreaComboBox.setDisabled(True) self.selectMissionComboBox.setDisabled(True) self.runninMissionLabel.setText(self.selectMissionComboBox.currentText()) self.currentRunningMissionLabel.setText(self.selectMissionComboBox.currentText()) self.tableWidget.setItem(0,0, QtWidgets.QTableWidgetItem(str(datetime.datetime.fromtimestamp(rospy.get_time())))) self.tableWidget.setItem(0,1, QtWidgets.QTableWidgetItem('N/A')) self.tableWidget.setItem(0,2, QtWidgets.QTableWidgetItem('Starting Mission')) self.tableWidget.setItem(0,3, QtWidgets.QTableWidgetItem('Init')) self.tableWidget.setItem(0,4, QtWidgets.QTableWidgetItem('Success')) self.tableWidget.setItem(0,5, QtWidgets.QTableWidgetItem('N/A')) self.tableWidget.setItem(0,6, QtWidgets.QTableWidgetItem('N/A')) self.tableWidget.setItem(0,7, QtWidgets.QTableWidgetItem('N/A')) self.runningTaskLabel.setText('Starting Mission') self.tableWidget.setItem(1,0, QtWidgets.QTableWidgetItem(str(datetime.datetime.fromtimestamp(rospy.get_time())))) self.tableWidget.setItem(1,1, QtWidgets.QTableWidgetItem('N/A')) self.tableWidget.setItem(1,2, QtWidgets.QTableWidgetItem('Move to new waypoint')) self.tableWidget.setItem(1,3, QtWidgets.QTableWidgetItem('Sent')) self.tableWidget.setItem(1,4, QtWidgets.QTableWidgetItem('Ongoing')) self.tableWidget.setItem(1,5, QtWidgets.QTableWidgetItem('N/A')) self.tableWidget.setItem(1,6, QtWidgets.QTableWidgetItem('N/A')) self.tableWidget.setItem(1,7, QtWidgets.QTableWidgetItem('N/A')) self.tableWidget.setItem(2,0, QtWidgets.QTableWidgetItem('')) self.runningTaskLabel.setText('Move to new waypoint') self.post_goal() else: pass