Skip to content

Commit

Permalink
Update pre-commit dependencies to latest versions
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrxyz committed May 12, 2023
2 parents 7791f49 + 547fecc commit 078ee8a
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 34 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ ci:

repos:
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.30.0
rev: v1.31.0
hooks:
- id: yamllint
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v16.0.0
rev: v16.0.2
hooks:
- id: clang-format
- repo: https://github.com/PyCQA/autoflake
rev: v2.0.2
rev: v2.1.1
hooks:
- id: autoflake
args: [--remove-all-unused-imports, --ignore-init-module-imports]
Expand All @@ -40,7 +40,7 @@ repos:
exclude: ^docker|deprecated|NaviGator/simulation/VRX
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: 'v0.0.260'
rev: 'v0.0.263'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def raised(self, alarm):
rospy.logwarn("BAG_ALWAYS or BAG_KILL not set. Not making kill bag.")
else:
goal = BagOnlineGoal(bag_name="kill.bag")
goal.topics = os.environ["BAG_ALWAYS"] + " " + os.environ["bag_kill"]
goal.topics = os.environ["BAG_ALWAYS"] + " " + os.environ["BAG_KILL"]
self.bag_client.send_goal(goal, done_cb=self._online_bagger_cb)
self.task_client.run_mission("Killed", done_cb=self._kill_task_cb)

Expand Down
106 changes: 89 additions & 17 deletions NaviGator/utils/voltage_gui/src/voltage_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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:
Expand All @@ -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()

Expand All @@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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; }",
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions SubjuGator/command/subjugator_alarm/alarm_handlers/kill.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def bagger_dump(self):
rospy.logwarn("BAG_ALWAYS or BAG_KILL not set. Not making kill bag.")
return
goal = BagOnlineGoal(bag_name="kill.bag")
goal.topics = os.environ["BAG_ALWAYS"] + " " + os.environ["bag_kill"]
goal.topics = os.environ["BAG_ALWAYS"] + " " + os.environ["BAG_KILL"]
self.bag_client.send_goal(goal, done_cb=self._bag_done_cb)

def meta_predicate(self, meta_alarm, sub_alarms):
Expand Down Expand Up @@ -170,5 +170,5 @@ def meta_predicate(self, meta_alarm, sub_alarms):

# Raised if any alarms besides the two above are raised
return any(
[alarm.raised for name, alarm in sub_alarms.items() if name not in ignore],
alarm.raised for name, alarm in sub_alarms.items() if name not in ignore
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from axros import Subscriber
from mil_misc_tools import text_effects
from sensor_msgs.msg import MagneticField
from std_msgs.msg import Bool
from tf.transformations import *

from .sub_singleton import SubjuGatorMission
Expand All @@ -19,14 +20,12 @@
DIST_AFTER_GATE = 1
WAIT_SECONDS = 1

RIGHT_OR_LEFT = 1


class StartGate2022(SubjuGatorMission):
async def current_angle(self):
imu_sub: Subscriber[MagneticField] = self.nh.subscribe(
"/imu/mag",
MagneticField,
name="/imu/mag",
message_type=MagneticField,
)
async with imu_sub:
reading = await imu_sub.get_next_message()
Expand All @@ -39,6 +38,15 @@ async def current_angle(self):
+ declination
)

async def is_left(self):
side_sub: Subscriber[Bool] = self.nh.subscribe(
name="/getside",
message_type=Bool,
)
async with side_sub:
result = await side_sub.get_next_message()
return result.data

async def run(self, args):
fprint("Waiting for odom")
await self.tx_pose()
Expand All @@ -63,5 +71,20 @@ async def run(self, args):
down = self.move().down(1)
await self.go(down, speed=SPEED)

forward = self.move().forward(4)
fprint("Waiting for side")
IS_LEFT = await self.is_left()

side = "left" if IS_LEFT else "right"

msg = "Found side: " + side
fprint(msg)

if IS_LEFT:
left = self.move().left(1)
await self.go(left, speed=SPEED)
else:
right = self.move().right(1)
await self.go(right, speed=SPEED)

forward = self.move().forward(5)
await self.go(forward, speed=SPEED)
2 changes: 1 addition & 1 deletion docs/extensions/attributetable.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def process_cppattributetable(app, doctree: Node, fromdocname):
],
)

elif all([c in node.attributes["classes"] for c in ["cpp", "function"]]):
elif all(c in node.attributes["classes"] for c in ["cpp", "function"]):
# Get the signature line of the function, where its name is stored
try:
descriptions = [
Expand Down
3 changes: 1 addition & 2 deletions mil_common/gnc/rawgps_common/src/rawgps_common/gps.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,7 @@ def predict_pos_deltat_r(self, t):
assert abs(t_k) < week_length / 2
if not (abs(t_k) < 6 * 60 * 60):
print(
"ERROR: ephemeris predicting more than 6 hours from now (%f hours)"
% (t_k / 60 / 60,),
f"ERROR: ephemeris predicting more than 6 hours from now ({t_k / 60 / 60:f} hours)",
)
n = n_0 + self.Deltan
M_k = self.M_0 + n * t_k
Expand Down
2 changes: 1 addition & 1 deletion mil_common/ros_alarms/ros_alarms/handler_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ def meta_predicate(self, meta_alarm: Alarm, alarms) -> Union[bool, Alarm]:
should be raised, or a new Alarm object which the calling alarm
should update itself to.
"""
return any([alarm.raised for name, alarm in alarms.items()])
return any(alarm.raised for name, alarm in alarms.items())
6 changes: 5 additions & 1 deletion scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,15 @@ mil_user_install_dependencies() {
git \
tmux \
vim \
htop \
tmuxinator \
awscli \
net-tools \
cifs-utils \
nmap \
tmuxinator
fd-find \
ripgrep \
fzf
}

# Add line to user's bashrc which source the repo's setup files
Expand Down
1 change: 1 addition & 0 deletions scripts/setup.bash
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ alias search_root='sudo find / \
-print | grep -i'

alias search='find . -print | grep -i'
alias fd="fdfind"

# Gazebo aliases
alias gazebogui="rosrun gazebo_ros gzclient __name:=gzclient"
Expand Down

0 comments on commit 078ee8a

Please sign in to comment.