Added watchdog for drive coordinator. Removed background from compass. Tuned some stuff on ground station drive sender.

This commit is contained in:
2018-03-01 19:50:45 -08:00
parent 6d9ed5d438
commit 2a37f6fe2e
4 changed files with 234 additions and 73 deletions

View File

@@ -19,7 +19,7 @@ DEFAULT_DRIVE_COMMAND_TOPIC = "/rover_control/command_control/ground_station_dri
DRIVE_COMMAND_HERTZ = 15
Y_AXIS_DEADBAND = 0.015
Y_AXIS_DEADBAND = 0.025
X_AXIS_DEADBAND = 0.025
THROTTLE_MIN = 0.05
@@ -104,7 +104,6 @@ class LogitechJoystick(QtCore.QThread):
def __setup_controller(self):
for device in devices.gamepads:
print device
if device.name == GAME_CONTROLLER_NAME:
self.gamepad = device

View File

@@ -85,8 +85,29 @@
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_44">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<property name="spacing">
<number>0</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label_44">
<property name="font">
@@ -502,6 +523,13 @@
</property>
</spacer>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@@ -549,6 +577,13 @@
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="1">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing">
@@ -565,55 +600,6 @@
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="font">
<font>
<pointsize>17</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Heading</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="next_goal_label">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>258°</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_10">
<property name="font">
<font>
<pointsize>17</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Next Goal</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="current_heading_label">
<property name="font">
@@ -642,24 +628,138 @@
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="font">
<font>
<pointsize>17</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Heading</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_10">
<property name="font">
<font>
<pointsize>17</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Next Goal</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="next_goal_label">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>258°</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="compass_label">
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<spacer name="horizontalSpacer_4">
<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="QLabel" name="heading_compass_label">
<property name="minimumSize">
<size>
<width>275</width>
<height>275</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>275</width>
<height>275</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<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>
</item>
<item>
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
@@ -687,7 +787,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>6</number>
<number>0</number>
</property>
<property name="leftMargin">
<number>6</number>
@@ -720,6 +820,9 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_2">
<property name="font">
@@ -749,6 +852,19 @@
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="font">
@@ -791,6 +907,19 @@
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="font">
@@ -810,6 +939,9 @@
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="horizontalSpacing">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="font">
@@ -876,6 +1008,19 @@
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>

View File

@@ -105,7 +105,7 @@ class GroundStation(QtCore.QObject):
self.start_threads_signal.emit()
compass_image = PIL.Image.open("Resources/Images/compass.png").resize((300, 300)) # PIL.Image
self.shared_objects["screens"]["right_screen"].compass_label.setPixmap(QtGui.QPixmap.fromImage(ImageQt(compass_image)))
self.shared_objects["screens"]["right_screen"].heading_compass_label.setPixmap(QtGui.QPixmap.fromImage(ImageQt(compass_image)))
def ___ros_master_running(self):
checker = ROSMasterChecker.ROSMasterChecker()

View File

@@ -25,6 +25,8 @@ UINT16_MAX = 65535
DEFAULT_HERTZ = 15
WATCHDOG_TIMEOUT = 0.3
#####################################
# ControlCoordinator Class Definition
@@ -57,10 +59,19 @@ class DriveCoordinator(object):
self.right_bogie_publisher = rospy.Publisher(self.right_bogie_topic, DriveControlMessage, queue_size=1)
# Other Vars TODO: fix this later
self.drive_commands = {
"iris": DriveCommandMessage(),
"ground_station": DriveCommandMessage()
self.drive_command_data = {
"iris": {
"message": DriveCommandMessage(),
"last_time": time()
},
"ground_station": {
"message": DriveCommandMessage(),
"last_time": time()
}
}
self.last_message_time = time()
# ########## Run the Class ##########
self.run()
@@ -79,12 +90,18 @@ class DriveCoordinator(object):
sleep(max(self.wait_time - time_diff, 0))
def process_drive_commands(self):
if not self.drive_commands["iris"].ignore_drive_control:
self.send_drive_control_command(self.drive_commands["iris"])
if not self.drive_command_data["iris"]["message"].ignore_drive_control:
self.send_drive_control_command(self.drive_command_data["iris"])
else:
self.send_drive_control_command(self.drive_commands["ground_station"])
self.send_drive_control_command(self.drive_command_data["ground_station"])
def send_drive_control_command(self, drive_command_data):
if (time() - drive_command_data["last_time"]) > WATCHDOG_TIMEOUT:
drive_command = DriveCommandMessage()
else:
drive_command = drive_command_data["message"]
def send_drive_control_command(self, drive_command):
rear_drive = DriveControlMessage()
left_drive = DriveControlMessage()
right_drive = DriveControlMessage()
@@ -118,12 +135,12 @@ class DriveCoordinator(object):
self.right_bogie_publisher.publish(right_drive)
def iris_drive_command_callback(self, drive_command):
self.drive_commands["iris"] = drive_command
return
self.drive_command_data["iris"]["message"] = drive_command
self.drive_command_data["iris"]["last_time"] = time()
def ground_station_drive_command_callback(self, drive_command):
self.drive_commands["ground_station"] = drive_command
return
self.drive_command_data["ground_station"]["message"] = drive_command
self.drive_command_data["ground_station"]["last_time"] = time()
if __name__ == '__main__':