Skip to content

Commit

Permalink
Added exception for if BLF is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
nicktrem committed May 17, 2024
1 parent 0b033ba commit f8b88fa
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
13 changes: 10 additions & 3 deletions robot_log_visualizer/file_reader/signal_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from robot_log_visualizer.utils.utils import PeriodicThreadState, RobotStatePath
import idyntree.swig as idyn

import bipedal_locomotion_framework.bindings as blf

# for real-time logging
import yarp
Expand Down Expand Up @@ -40,6 +39,13 @@ class SignalProvider(QThread):
def __init__(self, period: float):
QThread.__init__(self)

self.blfInstalled = True
try:
import bipedal_locomotion_framework.bindings as blf
self.blf = blf
except ImportError:
self.blfInstalled = False

# set device state
self._state = PeriodicThreadState.pause
self.state_lock = QMutex()
Expand Down Expand Up @@ -78,7 +84,8 @@ def __init__(self, period: float):

# for networking with the real-time logger
self.realtime_network_init = False
self.vector_collections_client = blf.yarp_utilities.VectorsCollectionClient()
if self.blfInstalled:
self.vector_collections_client = blf.yarp_utilities.VectorsCollectionClient()
self.trajectory_span = 200
self.rt_metadata_dict = {}

Expand Down Expand Up @@ -207,7 +214,7 @@ def maintain_connection(self):
if not self.realtime_network_init:
yarp.Network.init()

param_handler = blf.parameters_handler.YarpParametersHandler()
param_handler = self.blf.parameters_handler.YarpParametersHandler()
param_handler.set_parameter_string("remote", "/rtLoggingVectorCollections") # you must have some local port as well
param_handler.set_parameter_string("local", "/visualizerInput") # remote must match the server
param_handler.set_parameter_string("carrier", "udp")
Expand Down
8 changes: 7 additions & 1 deletion robot_log_visualizer/ui/autogenerated/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ def setupUi(self, MainWindow):

# Add a GUI action for connecting to the YARP port
# for real-time logging

self.actionConnect = QtWidgets.QAction(MainWindow)
self.actionConnect.setObjectName("actionConnect")

Expand Down Expand Up @@ -284,8 +285,13 @@ def retranslateUi(self, MainWindow):
self.actionQuit.setText(_translate("MainWindow", "&Quit"))
self.actionQuit.setShortcut(_translate("MainWindow", "Ctrl+Q"))
self.actionOpen.setText(_translate("MainWindow", "&Open"))
self.actionConnect.setText(_translate("MainWindow", "Realtime Connect"))
try:
import bipedal_locomotion_framework.bindings as blf
self.actionConnect.setText(_translate("MainWindow", "Realtime Connect"))
except ImportError:
self.actionConnect.setText(_translate("MainWindow", "Install BLF for RT Connect Functionality"))
self.actionOpen.setShortcut(_translate("MainWindow", "Ctrl+O"))
self.actionAbout.setText(_translate("MainWindow", "About"))
self.actionSet_Robot_Model.setText(_translate("MainWindow", "Set Robot Model"))

from PyQt5 import QtWebEngineWidgets
4 changes: 3 additions & 1 deletion robot_log_visualizer/ui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ def __init__(self, signal_provider, meshcat_provider, animation_period):
# connect action
self.ui.actionQuit.triggered.connect(self.close)
self.ui.actionOpen.triggered.connect(self.open_mat_file)
self.ui.actionConnect.triggered.connect(self.connect_realtime_logger)

if self.signal_provider.blfInstalled:
self.ui.actionConnect.triggered.connect(self.connect_realtime_logger)
self.ui.actionAbout.triggered.connect(self.open_about)
self.ui.actionSet_Robot_Model.triggered.connect(self.open_set_robot_model)

Expand Down

0 comments on commit f8b88fa

Please sign in to comment.