Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Steph imu widget refactor #247

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4dae317
Added imu widget to a larger section of the dash, and added some notes
steph1111 Jun 10, 2024
19c8306
Files i forgot to add
steph1111 Jun 10, 2024
d80e480
MORE STUFF I FORGOT TO ADD
steph1111 Jun 10, 2024
cbd145f
attempted to center painting to no avail
tinymassi Jun 10, 2024
eb67583
Add style sheet parameter
steph1111 Jun 10, 2024
2238fa5
Add style sheet parameter to constructor on dash
steph1111 Jun 10, 2024
8937762
Apply style sheet on init
steph1111 Jun 10, 2024
3043281
Merge branch 'steph-imu-widget-refactor' of github.com:CabrilloRoboti…
steph1111 Jun 10, 2024
b1a69e9
imu-widget is displayed on center of screen
tinymassi Jun 11, 2024
dd70399
added arrow svgs to dash styling and color_palette.py
tinymassi Jun 11, 2024
eb56380
dont remeber what i changed but something is different
tinymassi Jun 11, 2024
bad39be
Fix a few errors
Ronin2837 Jun 12, 2024
130b24e
Merge branch 'main' of https://github.com/CabrilloRoboticsClub/cabril…
tinymassi Jun 12, 2024
c2dd3cf
Merge branch 'steph-imu-widget-refactor' of https://github.com/Cabril…
tinymassi Jun 12, 2024
bc493b3
optimized imu_widget with colors dictionary values
tinymassi Jun 12, 2024
a9e2cf1
forgot to change sub topic back to bno085
tinymassi Jun 12, 2024
34c0c95
pushing any small changes
tinymassi Jun 12, 2024
96a04fd
imu_widget works with light mode
tinymassi Jun 13, 2024
0b6f918
removed useless code and swapped x & y vectors to match imu direction
tinymassi Jun 13, 2024
87afd15
overlayed the vector on top of the coordinate system
tinymassi Jun 13, 2024
035326d
swapped colors of coord system and vector
tinymassi Jun 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 33 additions & 16 deletions src/seahawk/seahawk_deck/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@
from rclpy.publisher import Publisher
from std_msgs.msg import String
from rcl_interfaces.msg import ParameterEvent
from sensor_msgs.msg import Image
from sensor_msgs.msg import Image, Imu

from seahawk_deck.dash_styling.color_palette import DARK_MODE, LIGHT_MODE
from seahawk_deck.dash_widgets.countdown_widget import CountdownWidget
from seahawk_deck.dash_widgets.numeric_data_widget import NumericDataWidget
from seahawk_deck.dash_widgets.state_widget import StateWidget
from seahawk_deck.dash_widgets.throttle_curve_widget import ThrtCrvWidget
from seahawk_deck.dash_widgets.term_widget import TermWidget
from seahawk_deck.set_remote_params import SetRemoteParams
from seahawk_deck.dash_widgets.tri_numeric_data_widget import TriNumericDataWidget
from seahawk_deck.dash_widgets.dynamic_plot_widget import DynamicPlotWidget
from seahawk_deck.dash_widgets.imu_widget import ImuWidget
from seahawk_deck.set_remote_params import SetRemoteParams
from seahawk_msgs.msg import InputStates, DebugInfo, Bme280

PATH = path.dirname(__file__)
Expand All @@ -44,6 +45,7 @@ class RosQtBridge(qtw.QWidget):
new_com_param_sgl = qtc.pyqtSignal()
new_debug_sgl = qtc.pyqtSignal()
new_bme280_sgl = qtc.pyqtSignal()
new_linear_accel_msg_sgl = qtc.pyqtSignal()
new_publisher_sgl = qtc.pyqtSignal()
new_set_params_sgl = qtc.pyqtSignal()

Expand All @@ -60,6 +62,7 @@ def __init__(self):
self.com = [0.0] * 3
self.debug_msg = None
self.bme280_msg = None
self.linear_accel_msg = None
self.keystroke_pub = None
self.pilot_input_set_params = None

Expand Down Expand Up @@ -152,6 +155,18 @@ def callback_bme280(self, msg: Bme280):
self.bme280_msg = msg
self.new_bme280_sgl.emit()

def callback_bno085(self, msg: Imu):
"""
Called for each time a message is published to the `bno085` topic.
Collects the contents of the message sent and emits a `new_linear_accel_msg_sgl`
signal which is received by Qt.

Args:
msg: Linear acceleration values camera/top/h264from the `bno085` topic
"""
self.linear_accel_msg = msg
self.new_linear_accel_msg_sgl.emit()

def add_publisher(self, pub: Publisher):
"""
Gives Qt access to a ROS publisher and emits a `new_publisher_sgl`.
Expand Down Expand Up @@ -306,6 +321,7 @@ def update_colors(self, new_colors: dict):
self.tab_widget.temp_widget.set_colors(self.colors)
self.tab_widget.depth_widget.set_colors(self.colors)
self.tab_widget.countdown_widget.set_colors(self.colors)
self.tab_widget.imu_widget.set_colors(self.colors)
self.tab_widget.term_widget.set_colors(self.colors)
self.tab_widget.leak.set_colors(self.colors)
self.tab_widget.humidity.set_colors(self.colors)
Expand Down Expand Up @@ -352,6 +368,7 @@ def __init__(self, parent: MainWindow, ros_qt_bridge: RosQtBridge, style_sheet_f
self.ros_qt_bridge.new_cam_front_msg_sgl.connect(self.update_cam_front)
self.ros_qt_bridge.new_debug_sgl.connect(self.update_debug)
self.ros_qt_bridge.new_bme280_sgl.connect(self.update_bme280)
self.ros_qt_bridge.new_linear_accel_msg_sgl.connect(self.update_linear_accel_msg)

# Define layout of tabs
layout = qtw.QVBoxLayout(self)
Expand Down Expand Up @@ -394,7 +411,7 @@ def set_colors(self, new_colors: dict):
new_colors: Hex codes to color widget with.
"""
self.setStyleSheet(self.style_sheet.format(**new_colors))
self.demo_map.setPixmap(qtg.QPixmap(new_colors["MAP_IMG"]))
# self.demo_map.setPixmap(qtg.QPixmap(new_colors["MAP_IMG"]))

def create_pilot_tab(self, tab: qtw.QWidget):
"""
Expand Down Expand Up @@ -427,36 +444,31 @@ def create_pilot_tab(self, tab: qtw.QWidget):
self.depth_widget = NumericDataWidget(tab, "Depth", PATH + "/dash_styling/numeric_data_widget.txt", self.colors)
self.countdown_widget = CountdownWidget(tab, PATH + "/dash_styling/countdown_widget.txt", self.colors, minutes=15, seconds=0)

# Initial value of CoM shift
self.com_shift_widget.update([0.0, 0.0, 0.0])

# Add widgets to side vertical layout
# Stretch modifies the ratios of the widgets (must add up to 100)
vert_widgets_layout.addWidget(self.state_widget, stretch=18)
vert_widgets_layout.addWidget(self.com_shift_widget, stretch=8)
vert_widgets_layout.addWidget(self.com_shift_widget, stretch=10)
vert_widgets_layout.addWidget(self.thrt_crv_widget, stretch=18)
vert_widgets_layout.addWidget(self.temp_widget, stretch=11)
vert_widgets_layout.addWidget(self.depth_widget, stretch=11)
vert_widgets_layout.addWidget(self.temp_widget, stretch=17)
vert_widgets_layout.addWidget(self.depth_widget, stretch=17)
vert_widgets_layout.addWidget(self.countdown_widget, stretch=20)

# Setup cameras
self.cam_down = VideoFrame()
self.cam_back = VideoFrame()
self.cam_front = VideoFrame()

# Product demo map image
self.demo_map = qtw.QLabel()
# Dynamically sized, endures the image fits any aspect ratio. Will resize image to fit
self.demo_map.setScaledContents(True)
self.demo_map.setSizePolicy(qtw.QSizePolicy.Ignored, qtw.QSizePolicy.Ignored)

# Initial value of CoM shift
self.com_shift_widget.update([0.0, 0.0, 0.0])
self.imu_widget = ImuWidget(tab, PATH + "/dash_styling/imu_widget.txt", self.colors)

# (0, 0) (0, 1)
# (1, 0) (1, 1)

cam_layout.addWidget(self.cam_back.label, 0, 0)
cam_layout.addWidget(self.cam_front.label, 0, 1)
cam_layout.addWidget(self.cam_down.label, 1, 0)
cam_layout.addWidget(self.demo_map, 1, 1)
cam_layout.addWidget(self.imu_widget, 1, 1)

home_window_layout.addLayout(vert_widgets_layout, stretch=1)
home_window_layout.addLayout(cam_layout, stretch=9)
Expand Down Expand Up @@ -538,6 +550,10 @@ def update_pilot_tab_input_states(self):
self.state_widget.update(input_state_dict)
self.thrt_crv_widget.update(self.ros_qt_bridge.input_state_msg.thrt_crv)

@qtc.pyqtSlot()
def update_linear_accel_msg(self):
self.imu_widget.update(self.ros_qt_bridge.linear_accel_msg)

def create_debug_tab(self, tab: qtw.QWidget):
# Setup layouts
debug_layout = qtw.QHBoxLayout(tab)
Expand Down Expand Up @@ -628,6 +644,7 @@ def __init__(self, ros_qt_bridge: RosQtBridge):
self.create_subscription(Image, "camera/back/image", ros_qt_bridge.callback_cam_back, 10)
self.create_subscription(Image, "camera/front/image", ros_qt_bridge.callback_cam_front, 10)
self.create_subscription(ParameterEvent, "parameter_events", ros_qt_bridge.callback_param_event, 10)
self.create_subscription(Imu,"bno085", ros_qt_bridge.callback_bno085, 10)

ros_qt_bridge.add_publisher(self.create_publisher(String, "keystroke", 10))

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading