-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update pre-commit dependencies to latest versions
- Loading branch information
Showing
10 changed files
with
133 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,15 +11,33 @@ | |
from roboteq_msgs.msg import Feedback | ||
from std_msgs.msg import Float32 | ||
|
||
# Display voltage from battery_monitor and the four motors to a GUI | ||
|
||
|
||
__author__ = "Joseph Brooks" | ||
__email__ = "[email protected]" | ||
__license__ = "MIT" | ||
|
||
|
||
class voltageGUI(Plugin): | ||
""" | ||
Display voltage from battery_monitor and the four motors to a GUI | ||
Attributes: | ||
height (int): defines the height of the screen | ||
fontSize(int): sets the font size of the screen | ||
warningCounter(int): prints the number of warning signs | ||
paramCounter(int): the number of times "updateLabel" function is called | ||
heightRatio(int): the ratio change in height that is caused by the resize | ||
gotParams(bool): this checks to see whether the parameters are set | ||
lowThreshold(int): colors values which include Good (Green), Warning (Yellow), and Critical (Red) | ||
criticalThreshold(int): colors values which include Good (Green), Warning (Yellow), and Critical (Red) | ||
paramCounter(int): number of parameters that are called by function | ||
battery_voltage(int): the amount of voltage that is stored in the battery | ||
voltageFL(int): the voltage that is being supplied from dataFL | ||
voltageFR(int): the voltage that is being supplied from dataFR | ||
voltageBL(int): the voltage that is being supplied from dataBL | ||
voltageBR(int): the voltage that is being supplied from dataBR | ||
""" | ||
|
||
def __init__(self, context): | ||
super().__init__(context) | ||
self.setObjectName("voltage_gui") | ||
|
@@ -33,8 +51,10 @@ def __init__(self, context): | |
context.add_widget(self.myWidget) | ||
self.runGUI() | ||
|
||
# Updates Values displayed in GUI every second | ||
def runGUI(self) -> None: | ||
""" | ||
Updates Values displayed in GUI every second | ||
""" | ||
app = QApplication(sys.argv) | ||
self.myWidget.show() | ||
while 0 == 0: | ||
|
@@ -57,12 +77,12 @@ def __init__(self): | |
# Whenever the screen is resized the resizeFont function is called | ||
self.resized.connect(self.resizeFont) | ||
|
||
self.height = VoltageWidget.frameGeometry(self).height() | ||
self.height = VoltageWidget.frameGeometry(self).height() # done | ||
|
||
self.fontSize = 40 | ||
self.fontSize = 40 # done | ||
|
||
self.warningCounter = 0 | ||
self.paramCounter = 0 | ||
self.warningCounter = 0 # done | ||
self.paramCounter = 0 # done | ||
|
||
self.initThresh() | ||
|
||
|
@@ -80,27 +100,67 @@ def __init__(self): | |
|
||
# The functions that the subscribers call in order to get new data | ||
def updateMain(self, mainData: Float32) -> None: | ||
""" | ||
It is one of the functions that the subscribers call in order to get new data. | ||
Args: | ||
mainData: it is a float value that is being passed in for a variable to be set to. | ||
""" | ||
self.battery_voltage = mainData | ||
|
||
def update_FL(self, dataFL: Feedback) -> None: | ||
""" | ||
It is one of the functions that the subscribers call in order to get new data. | ||
Args: | ||
dataFL: it is a feedback value that is being passed in for a variable to be set to. | ||
""" | ||
self.voltageFL = dataFL.supply_voltage | ||
|
||
def update_FR(self, dataFR: Feedback) -> None: | ||
""" | ||
It is one of the functions that the subscribers call in order to get new data. | ||
Args: | ||
dataFR: it is a feedback value that is being passed in for a variable to be set to. | ||
""" | ||
self.voltageFR = dataFR.supply_voltage | ||
|
||
def update_BL(self, dataBL: Feedback) -> None: | ||
""" | ||
It is one of the functions that the subscribers call in order to get new data. | ||
Args: | ||
dataBL: it is a feedback value that is being passed in for a variable to be set to. | ||
""" | ||
self.voltageBL = dataBL.supply_voltage | ||
|
||
def update_BR(self, dataBR: Feedback) -> None: | ||
""" | ||
It is one of the functions that the subscribers call in order to get new data. | ||
Args: | ||
dataBR: it is a feedback value that is being passed in for a variable to be set to. | ||
""" | ||
self.voltageBR = dataBR.supply_voltage | ||
|
||
# Part of signal that notifies program whenever window is resized | ||
def resizeEvent(self, event): | ||
def resizeEvent(self, event): # done | ||
""" | ||
Part of signal that notifies program whenever window is resized | ||
Args: | ||
event: an event object is being passed in. | ||
Returns: | ||
An event was being returned with a different size. | ||
""" | ||
self.resized.emit() | ||
return super().resizeEvent(event) | ||
|
||
# Increase/decrease size of fonts based on window resize | ||
def resizeFont(self) -> None: | ||
def resizeFont(self) -> None: # done | ||
""" | ||
Increase/decrease size of fonts based on window resize | ||
""" | ||
# gets new window dimensions, the self is needed because we are referencing | ||
# our VoltageWidget class | ||
height = VoltageWidget.frameGeometry(self).height() | ||
|
@@ -126,6 +186,9 @@ def resizeFont(self) -> None: | |
|
||
# Sets the text of the thrshold info box | ||
def initThresh(self) -> None: | ||
""" | ||
Sets the text of the threshold info box | ||
""" | ||
# Low and Critical decide what colors the boxes take for | ||
# Good (Green), Warning (Yellow), and Critical (Red) | ||
# If the parameter server has not set these values then we use the DEFAULT | ||
|
@@ -159,8 +222,10 @@ def initThresh(self) -> None: | |
threshFont = QtGui.QFont("Times", (self.fontSize) / 3, QtGui.QFont.Bold) | ||
self.labelThresh.setFont(threshFont) | ||
|
||
# If self.gotParams is False, the updateLabel function calls testParams every 5 seconds | ||
def testParams(self) -> None: | ||
def testParams(self) -> None: # done | ||
""" | ||
If self.gotParams is False, the updateLabel function calls testParams every 5 seconds | ||
""" | ||
try: | ||
self.lowThreshold = rospy.get_param("battery-voltage/low") | ||
self.criticalThreshold = rospy.get_param("battery-voltage/critical") | ||
|
@@ -180,8 +245,13 @@ def testParams(self) -> None: | |
) | ||
self.labelThresh.setText(threshText) | ||
|
||
# sets colors of boxes based on current values of voltages for each box | ||
def setColors(self, numMain: float) -> None: | ||
def setColors(self, numMain: float) -> None: # done | ||
""" | ||
sets colors of boxes based on current values of voltages for each box | ||
Args: | ||
numMain(float): box object that stores current values | ||
""" | ||
if numMain > self.lowThreshold: | ||
self.labelMain.setStyleSheet( | ||
"QLabel { background-color : green; color : white; }", | ||
|
@@ -260,7 +330,9 @@ def setColors(self, numMain: float) -> None: | |
) | ||
|
||
def updateLabel(self) -> None: | ||
# Tries self.gotParams every 3 function calls | ||
""" | ||
Tries self.gotParams every 3 function calls | ||
""" | ||
self.paramCounter = self.paramCounter + 1 | ||
if self.gotParams is False and self.paramCounter >= 3: | ||
self.testParams() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters