Working readout for beacon frequency thanks to Dylan!

This commit is contained in:
2018-08-09 22:21:18 -07:00
parent d9e8458797
commit c3a98cc0a7
6 changed files with 293 additions and 202 deletions

View File

@@ -14,9 +14,9 @@ import paramiko
#####################################
THREAD_HERTZ = 5
IP = "192.168.1.10"
USER = "nvidia"
PASS = "nvidia"
IP = "192.168.1.127"
USER = "caperren"
PASS = "ult1m2t3!"
#####################################
@@ -36,6 +36,9 @@ class BashConsole(QtCore.QThread):
self.console_text_edit = self.left_screen.console_line_edit # type: QtWidgets.QTextEdit
self.ssh_console_command_line_edit = self.left_screen.ssh_console_command_line_edit # type:QtWidgets.QLineEdit
self.ssh_scan_for_hosts_button = self.left_screen.ssh_scan_for_hosts_button # type: QtWidgets.QPushButton
self.ssh_host_line_edit = self.left_screen.ssh_host_line_edit # type: QtWidgets.QLineEdit
self.ssh_list_wifi_button = self.left_screen.ssh_list_wifi_button # type: QtWidgets.QPushButton
self.ssh_equipment_login_button = self.left_screen.ssh_equipment_login_button # type: QtWidgets.QPushButton
self.ssh_equipment_logout_button = self.left_screen.ssh_equipment_logout_button # type: QtWidgets.QPushButton
@@ -118,25 +121,44 @@ class BashConsole(QtCore.QThread):
self.new_command = True
def on_login_button_pressed__slot(self):
self.new_command_text = "python equipment_servicing_interface.py 'task.cstag.ca' 'LOGIN MTECH GITRDONE' HELP"
current_ip = self.ssh_host_line_edit.text()
self.new_command_text = "python equipment_servicing_interface.py '%s' 'LOGIN MTECH GITRDONE' HELP" % current_ip
print self.new_command_text
self.new_command = True
def on_logout_button_pressed__slot(self):
self.new_command_text = "python equipment_servicing_interface.py 'task.cstag.ca' LOGOUT"
current_ip = self.ssh_host_line_edit.text()
self.new_command_text = "python equipment_servicing_interface.py '%s' LOGOUT" % current_ip
self.new_command = True
def on_status_button_pressed__slot(self):
self.new_command_text = "python equipment_servicing_interface.py 'task.cstag.ca' STATUS"
current_ip = self.ssh_host_line_edit.text()
self.new_command_text = "python equipment_servicing_interface.py '%s' STATUS" % current_ip
self.new_command = True
def on_start_button_pressed__slot(self):
self.new_command_text = "python equipment_servicing_interface.py 'task.cstag.ca' START"
current_ip = self.ssh_host_line_edit.text()
self.new_command_text = "python equipment_servicing_interface.py '%s' START" % current_ip
self.new_command = True
def on_stop_button_pressed__slot(self):
self.new_command_text = "python equipment_servicing_interface.py 'task.cstag.ca' STOP"
current_ip = self.ssh_host_line_edit.text()
self.new_command_text = "python equipment_servicing_interface.py '%s' STOP" % current_ip
self.new_command = True
def on_ssh_scan_for_hosts_pressed__slot(self):
current_ip = self.ssh_host_line_edit.text()
find_dot = current_ip.rfind(".")
if find_dot > 0:
current_ip = current_ip[:find_dot + 1] + "0"
self.new_command_text = "nmap -sP %s/24 -oG - | awk '/Up$/{print $2}'" % current_ip
self.new_command = True
else:
self.set_text_contents += "IP address for range search not valid. Try again."
self.text_update_ready__signal.emit(self.set_text_contents)
def on_connect_ssid_button_pressed__slot(self):
ssid_text = self.ssh_ssid_line_edit.text()
@@ -156,6 +178,8 @@ class BashConsole(QtCore.QThread):
self.ssh_console_command_line_edit.editingFinished.connect(self.on_text_editing_finished__slot)
self.console_text_edit.textChanged.connect(self.on_text_readout_updated__slot)
self.ssh_scan_for_hosts_button.clicked.connect(self.on_ssh_scan_for_hosts_pressed__slot)
self.ssh_equipment_login_button.clicked.connect(self.on_login_button_pressed__slot)
self.ssh_equipment_logout_button.clicked.connect(self.on_logout_button_pressed__slot)
self.ssh_equipment_status_button.clicked.connect(self.on_status_button_pressed__slot)

View File

@@ -7,6 +7,8 @@ from PyQt5 import QtCore, QtWidgets
import logging
import rospy
from time import time
import scipy.fftpack
import numpy
from std_msgs.msg import Float64MultiArray
@@ -23,7 +25,8 @@ THREAD_HERTZ = 5
#####################################
class RDF(QtCore.QThread):
lcd_number_update_ready__signal = QtCore.pyqtSignal(int)
rssi_lcd_number_update_ready__signal = QtCore.pyqtSignal(int)
beacon_lcd_number_update_ready__signal = QtCore.pyqtSignal(float)
def __init__(self, shared_objects):
super(RDF, self).__init__()
@@ -33,6 +36,7 @@ class RDF(QtCore.QThread):
self.left_screen = self.shared_objects["screens"]["left_screen"]
self.rssi_lcdnumber = self.left_screen.rssi_lcdnumber # type:QtWidgets.QLCDNumber
self.beacon_frequency_lcd_number = self.left_screen.beacon_frequency_lcd_number # type:QtWidgets.QLCDNumber
# ########## Get the settings instance ##########
self.settings = QtCore.QSettings()
@@ -48,9 +52,11 @@ class RDF(QtCore.QThread):
self.rdf_subscriber = rospy.Subscriber(RDF_DATA_TOPIC, Float64MultiArray, self.new_rdf_message_received__callback)
self.data = []
self.data_limit = 100
self.moving_average_raw_data = []
self.raw_data = numpy.array([])
self.raw_data_timestamps = numpy.array([])
self.data_window_size = 200
def run(self):
self.logger.debug("Starting RDF Thread")
@@ -58,10 +64,40 @@ class RDF(QtCore.QThread):
while self.run_thread_flag:
start_time = time()
temp = list(self.data)
temp = list(self.moving_average_raw_data)
if temp:
average = sum(temp) / len(temp)
self.lcd_number_update_ready__signal.emit(average)
self.rssi_lcd_number_update_ready__signal.emit(average)
if self.raw_data.size >= self.data_window_size and self.raw_data_timestamps.size >= self.data_window_size:
try:
time_step_array = numpy.array([])
for n in range(0, self.data_window_size - 1):
time_step_array = numpy.append(time_step_array, self.raw_data_timestamps[n + 1] - self.raw_data_timestamps[n])
T = numpy.average(time_step_array)
yf = scipy.fftpack.fft(self.raw_data)
xf = numpy.linspace(0.0, 1.0 / (2.0 * T), self.data_window_size / 2)
valid_range = []
for n in range(0, len(xf)):
if (xf[n] > 0.5) and (xf[n] < 5.0):
valid_range.append(n)
yf = numpy.take(yf, valid_range)
xf = numpy.take(xf, valid_range)
max_index = numpy.argmax(numpy.abs(yf))
freq = xf[max_index]
self.beacon_lcd_number_update_ready__signal.emit(freq)
except:
pass
self.raw_data = numpy.array([])
self.raw_data_timestamps = numpy.array([])
time_diff = time() - start_time
@@ -70,17 +106,18 @@ class RDF(QtCore.QThread):
self.logger.debug("Stopping RDF Thread")
def new_rdf_message_received__callback(self, data):
if len(self.data) >= self.data_limit:
del self.data[0]
if len(self.moving_average_raw_data) >= self.data_window_size:
del self.moving_average_raw_data[0]
# if len(self.times) >= self.data_limit:
# del self.times[0]
self.moving_average_raw_data.append(data.data[0])
self.data.append(data.data[0])
# self.times.append(data.data[1])
if self.raw_data.size != self.data_window_size and self.raw_data_timestamps.size != self.data_window_size:
self.raw_data = numpy.append(self.raw_data, data.data[0])
self.raw_data_timestamps = numpy.append(self.raw_data_timestamps, data.data[1])
def connect_signals_and_slots(self):
self.lcd_number_update_ready__signal.connect(self.rssi_lcdnumber.display)
self.rssi_lcd_number_update_ready__signal.connect(self.rssi_lcdnumber.display)
self.beacon_lcd_number_update_ready__signal.connect(self.beacon_frequency_lcd_number.display)
def setup_signals(self, start_signal, signals_and_slots_signal, kill_signal):
start_signal.connect(self.start)

View File

@@ -1390,15 +1390,98 @@ N/A</string>
</size>
</property>
<property name="currentIndex">
<number>3</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string>RDF</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_16">
<item row="1" column="0">
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>111</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLCDNumber" name="rssi_lcdnumber"/>
<layout class="QVBoxLayout" name="verticalLayout_20">
<item>
<layout class="QVBoxLayout" name="verticalLayout_21">
<item>
<widget class="QLabel" name="label_31">
<property name="font">
<font>
<pointsize>16</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Raw Data</string>
</property>
</widget>
</item>
<item>
<widget class="QLCDNumber" name="rssi_lcdnumber">
<property name="minimumSize">
<size>
<width>400</width>
<height>150</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_22">
<item>
<widget class="QLabel" name="label_32">
<property name="font">
<font>
<pointsize>16</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Beacon Frequency</string>
</property>
</widget>
</item>
<item>
<widget class="QLCDNumber" name="beacon_frequency_lcd_number">
<property name="minimumSize">
<size>
<width>400</width>
<height>150</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_19">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
@@ -2206,17 +2289,80 @@ Permittivity</string>
</widget>
</item>
<item>
<widget class="QLabel" name="label_23">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Preset Commands</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_19">
<item>
<widget class="QLabel" name="label_27">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Preset Commands</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_18">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="ssh_scan_for_hosts_button">
<property name="text">
<string>Scan For Hosts</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_11">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_23">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Host</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="ssh_host_line_edit">
<property name="minimumSize">
<size>
<width>125</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>125</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>task.cstag.ca</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_18">
@@ -2749,29 +2895,6 @@ Permittivity</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="manual_waypoint_degrees_longitude_spin_box">
<property name="suffix">
<string>° </string>
</property>
<property name="minimum">
<number>-180</number>
</property>
<property name="maximum">
<number>180</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="manual_waypoint_minutes_longitude_spin_box">
<property name="suffix">
<string>'</string>
</property>
<property name="maximum">
<number>60</number>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QComboBox" name="manual_waypoint_cardinal_lattitude_combo_box">
<item>
@@ -2791,6 +2914,19 @@ Permittivity</string>
</item>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="manual_waypoint_degrees_longitude_spin_box">
<property name="suffix">
<string>° </string>
</property>
<property name="minimum">
<number>-180</number>
</property>
<property name="maximum">
<number>180</number>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QComboBox" name="manual_waypoint_cardinal_longitude_combo_box">
<item>
@@ -2810,6 +2946,16 @@ Permittivity</string>
</item>
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="manual_waypoint_minutes_longitude_spin_box">
<property name="suffix">
<string>'</string>
</property>
<property name="maximum">
<number>60</number>
</property>
</widget>
</item>
</layout>
</item>
<item>