Rover arm now moves one axis via topics. Close to having the rest moving tomorrow.

This commit is contained in:
2018-08-04 01:28:21 -07:00
parent d62fdd45b3
commit 7f80f44b96
10 changed files with 406 additions and 111 deletions

View File

@@ -35,51 +35,59 @@ class XBOXController(QtCore.QThread):
self.gamepad = None # type: GamePad
self.controller_states = {
"x_axis": 512,
"y_axis": 512,
"z_axis": 128,
"throttle_axis": 128,
"left_x_axis": 0,
"left_y_axis": 0,
"left_stick_button": 0,
"right_x_axis": 0,
"right_y_axis": 0,
"right_stick_button": 0,
"left_trigger": 0,
"left_bumper": 0,
"right_trigger": 0,
"right_bumper": 0,
"hat_x_axis": 0,
"hat_y_axis": 0,
"trigger_pressed": 0,
"thumb_pressed": 0,
"three_pressed": 0,
"four_pressed": 0,
"five_pressed": 0,
"six_pressed": 0,
"back_button": 0,
"start_button": 0,
"xbox_button": 0,
"seven_pressed": 0,
"eight_pressed": 0,
"nine_pressed": 0,
"ten_pressed": 0,
"eleven_pressed": 0,
"twelve_pressed": 0,
"x_button": 0,
"a_button": 0,
"b_button": 0,
"y_button": 0
}
self.raw_mapping_to_class_mapping = {
"ABS_X": "x_axis",
"ABS_Y": "y_axis",
"ABS_RZ": "z_axis",
"ABS_THROTTLE": "throttle_axis",
"ABS_X": "left_x_axis",
"ABS_Y": "left_y_axis",
"BTN_THUMBL": "left_stick_button",
"ABS_RX": "right_x_axis",
"ABS_RY": "right_y_axis",
"BTN_THUMBR": "right_stick_button",
"ABS_Z": "left_trigger",
"BTN_TL": "left_bumper",
"ABS_RZ": "right_trigger",
"BTN_TR": "right_bumper",
"ABS_HAT0X": "hat_x_axis",
"ABS_HAT0Y": "hat_y_axis",
"BTN_TRIGGER": "trigger_pressed",
"BTN_THUMB": "thumb_pressed",
"BTN_THUMB2": "three_pressed",
"BTN_TOP": "four_pressed",
"BTN_TOP2": "five_pressed",
"BTN_PINKIE": "six_pressed",
"BTN_SELECT": "back_button",
"BTN_START": "start_button",
"BTN_MODE": "xbox_button",
"BTN_BASE": "seven_pressed",
"BTN_BASE2": "eight_pressed",
"BTN_BASE3": "nine_pressed",
"BTN_BASE4": "ten_pressed",
"BTN_BASE5": "eleven_pressed",
"BTN_BASE6": "twelve_pressed"
"BTN_NORTH": "x_button",
"BTN_SOUTH": "a_button",
"BTN_EAST": "b_button",
"BTN_WEST": "y_button"
}
self.ready = False
@@ -109,8 +117,12 @@ class XBOXController(QtCore.QThread):
events = self.gamepad.read()
for event in events:
print event.code
# For seeing codes you haven't added yet...
# if event.code not in self.raw_mapping_to_class_mapping and event.code != "SYN_REPORT":
# print event.code, ":", event.state
if event.code in self.raw_mapping_to_class_mapping:
# print event.code, ":", event.state
self.controller_states[self.raw_mapping_to_class_mapping[event.code]] = event.state
self.ready = True
@@ -136,7 +148,7 @@ class ControllerControlSender(QtCore.QThread):
self.logger = logging.getLogger("groundstation")
# ########## Thread Flags ##########
self.run_thread_flag = False
self.run_thread_flag = True
self.controller = XBOXController()
@@ -150,6 +162,8 @@ class ControllerControlSender(QtCore.QThread):
while self.run_thread_flag:
start_time = time()
# print self.controller.controller_states
time_diff = time() - start_time
self.msleep(max(int(self.wait_time - time_diff), 0))

View File

@@ -6,29 +6,26 @@
from PyQt5 import QtCore, QtWidgets
import logging
from time import time
import paramiko
#####################################
# Global Variables
#####################################
ACCESS_POINT_IP = "192.168.1.20" # The channel only has to be set on the access point. The staion will adjust.
ACCESS_POINT_USER = "ubnt"
ACCESS_POINT_PASSWORD = "rover4lyfe^" # We don't care about this password, don't freak out. Wifi is open anyways...
THREAD_HERTZ = 5
#####################################
# UbiquitiRadioSettings Class Definition
#####################################
class SSHConsole(QtCore.QThread):
class BashConsole(QtCore.QThread):
def __init__(self, shared_objects):
super(SSHConsole, self).__init__()
super(BashConsole, self).__init__()
# ########## Reference to class init variables ##########
self.shared_objects = shared_objects
self.left_screen = self.shared_objects["screens"]["left_screen"]
self.ubiquiti_channel_spin_box = self.left_screen.ssh_console_widget # type: QtWidgets.QSpinBox
self.ubiquiti_channel_apply_button = self.left_screen.ubiquiti_channel_apply_button # type: QtWidgets.QPushButton
self.ssh_widget = self.left_screen.ssh_console_widget # type: QtWidgets.QSpinBox
# ########## Get the settings instance ##########
self.settings = QtCore.QSettings()
@@ -40,8 +37,23 @@ class SSHConsole(QtCore.QThread):
self.run_thread_flag = True
# ########## Class Variables ##########
self.wait_time = 1.0 / THREAD_HERTZ
self.connect_signals_and_slots()
def run(self):
while self.run_thread_flag:
start_time = time()
time_diff = time() - start_time
self.msleep(max(int(self.wait_time - time_diff), 0))
def connect_signals_and_slots(self):
pass
pass
def setup_signals(self, start_signal, signals_and_slots_signal, kill_signal):
start_signal.connect(self.start)
signals_and_slots_signal.connect(self.connect_signals_and_slots)
kill_signal.connect(self.on_kill_threads_requested__slot)
def on_kill_threads_requested__slot(self):
self.run_thread_flag = False

View File

@@ -25,6 +25,7 @@ import Framework.StatusSystems.UbiquitiStatusCore as UbiquitiStatusCore
import Framework.SettingsSystems.UbiquitiRadioSettings as UbiquitiRadioSettings
import Framework.InputSystems.SpaceNavControlSender as SpaceNavControlSender
import Framework.MiscSystems.MiningCore as MiningCore
import Framework.MiscSystems.BashConsoleCore as BashConsoleCore
#####################################
# Global Variables
@@ -117,6 +118,7 @@ class GroundStation(QtCore.QObject):
self.__add_thread("Ubiquiti Radio Settings", UbiquitiRadioSettings.UbiquitiRadioSettings(self.shared_objects))
self.__add_thread("Waypoints Coordinator", WaypointsCoordinator.WaypointsCoordinator(self.shared_objects))
self.__add_thread("Spacenav Sender", SpaceNavControlSender.SpaceNavControlSender(self.shared_objects))
self.__add_thread("Bash Console", BashConsoleCore.BashConsole(self.shared_objects))
self.connect_signals_and_slots_signal.emit()
self.__connect_signals_to_slots()